## 721 Reputation

15 years, 140 days

I have a degree in Mathematics and Physics from the Danish University Aarhus, comparable to a masters degree with thesis - majoring in Mathematics. In 1991-92 I was a visting scholar at UCLA, Los Angeles, following graduate courses in Applied Mathematics. Since 1992 I have been a teacher in a high school (gymnasium) in Denmark. Special interests: Applied mathematics, graphics and popularizing Mathematics.

## Hi Christopher The help pages say that ...

Hi Christopher

The help pages say that if no range is provided with the numeric option, the range -10 to 10 is chosen by default, so we were just plain lucky there :)

But you are right that it is odd that Maple find less solutions in a bigger interval. I guess Maple choses some fixed number of points to apply the fsolve command to keep the amount of computation limited, in order to deliver the result within a reasonable timeframe. A bigger interval then means larger distance between the points, which can easily have an influence on the number of roots found - the output of the fsolve command depend on the initial value ... This is just a guess. I don't know if the Roots command is implemented in this way. It could explain the mystery at least.

Erik

## Testing on a nasty equation...

Thanks Acer for your investigations. I appriciate them. The NextZero command is interesting. It suggest a way to "pick up" the solutions one after the other from left to right. Unfortunately this built-in Maple command does not even succeed in the current example.

RootFinding[NextZero](x -> x^3-3*2^x+3,-1000)

will give a FAIL as result. If the starting point is -100 NextZero will find a solution.

I tested your nice findroots procedure on the very nasty example f := x-> sin(1/x)-x, having infinitely many solutions in any open interval around 0, and compared it to how the Roots command from the student package performed. It turns out the results depend a lot on the interval chosen:

Interval -100 to 100:
findroots: No solution
Roots: 5 solutions

Interval -10 to 10:
findroots: 50 solutions
Roots: 7 solutions

Interval -0.1 to 0.1:
findroots: 50 solutions
Roots: 50 solutions

So none of them win :)

I guess whatever method we use, we should not rely solely on the Maple output. One will need to look at a plot too!

NB! When I write Maple code in this forum, I have been uploading screen shots most of the time. Obviously that is not a nice way to do it. I tried using the Maple Math button in this forum and copy & pasted a section from my Maple document into it, but it didn't work. How do you do? :) I use Math 2D notation!

Regards,

Erik

## Testing on a nasty equation...

Thanks Acer for your investigations. I appriciate them. The NextZero command is interesting. It suggest a way to "pick up" the solutions one after the other from left to right. Unfortunately this built-in Maple command does not even succeed in the current example.

RootFinding[NextZero](x -> x^3-3*2^x+3,-1000)

will give a FAIL as result. If the starting point is -100 NextZero will find a solution.

I tested your nice findroots procedure on the very nasty example f := x-> sin(1/x)-x, having infinitely many solutions in any open interval around 0, and compared it to how the Roots command from the student package performed. It turns out the results depend a lot on the interval chosen:

Interval -100 to 100:
findroots: No solution
Roots: 5 solutions

Interval -10 to 10:
findroots: 50 solutions
Roots: 7 solutions

Interval -0.1 to 0.1:
findroots: 50 solutions
Roots: 50 solutions

So none of them win :)

I guess whatever method we use, we should not rely solely on the Maple output. One will need to look at a plot too!

NB! When I write Maple code in this forum, I have been uploading screen shots most of the time. Obviously that is not a nice way to do it. I tried using the Maple Math button in this forum and copy & pasted a section from my Maple document into it, but it didn't work. How do you do? :) I use Math 2D notation!

Regards,

Erik

## What interval to choose?...

Axel Vogt:
Thanks for your suggestion. I think however that the commands necessary are too involved and not suited for High School students. I will remember the RootFinding possibility for my own sake, though.

Markiyan:
Thanks for your reply. I was surprised to see that it makes a difference, which interval to look for solutions. When choosing the big interval from -1000 to 1000, one solution was missing, whereas the interval from -20 to 20 made Maple find all four solutions. I assume the reason for this apparently strange situation is that Maple needs to cut down on calculations in order to be able to find the solutions in a decent time ...

Conclusion:
As I can see, the best way to tell the students how to find numeric solutions to a given equation in one variable is the following: Plot the graph of the associated function in a resonable large interval. Look for zeros. If they are concentrated in a much smaller interval, plot the function in that smaller interval, until it is possible to point out approximative values of all zeros by simple inspection. Now use the fsolve command to find one zero a time, using the approximate values as a first guess. Alternatively the Roots command can be used to find all zeros. If this command deliver the same number of zeros as registered on the plot, those are all the solutions to the original equation. Of course there is still a possibility that there might be a solution outside the large interval, though ...

Any comments to this procedure will be appreciated.

Erik

## No simplification of units when using th...

Thanks for your reply, Georgios. I think however that you misunderstood my question. I don't understand why the Units are not being simplified automatically when the Units[Standard] package is called. This is the whole reason why I am using this package, so I will not need to simplify again and again. But is doesn't work when equations are being solved, only when expressions are being computed!

Erik

## No simplification of units when using th...

Thanks for your reply, Georgios. I think however that you misunderstood my question. I don't understand why the Units are not being simplified automatically when the Units[Standard] package is called. This is the whole reason why I am using this package, so I will not need to simplify again and again. But is doesn't work when equations are being solved, only when expressions are being computed!

Erik

## eval and uneval...

Great! This eval function made the trick. I didn't really understand the idea behind the ball procedure - just took it from the help page. I figure that when plotting and animating a function defined by a procedure, there should be a delay in evaluation (see http://www.maplesoft.com/support/help/errors/view.aspx?path=Error,%20(in%20f)%20cannot%20determine%20if%20this%20expression%20is%20true%20or%20false%3A%205%20%3C%20t) but when calling the ball procedure, an immediate evaluation of f(t) is necessary.

Erik

## eval and uneval...

Great! This eval function made the trick. I didn't really understand the idea behind the ball procedure - just took it from the help page. I figure that when plotting and animating a function defined by a procedure, there should be a delay in evaluation (see http://www.maplesoft.com/support/help/errors/view.aspx?path=Error,%20(in%20f)%20cannot%20determine%20if%20this%20expression%20is%20true%20or%20false%3A%205%20%3C%20t) but when calling the ball procedure, an immediate evaluation of f(t) is necessary.

Erik

## Animation specified by a function create...

Thanks Preben

It works as you describe. I have another problem in connection to the same thing: I want a ball to follow a certain curve parametriced by (4,f(t)). The first coordinate is fixed to the value 4, whereas the second coordinate is a function of one variable, t. The commands works well if f(t) is a simple expression, say sin(t). My function is however defined using a simple procedure. The animate command fails, as you can see below. I don't know why - I even remembered unevaluation quotes. I hope someone can tell me how to make it work.

> restart;
> with(plots);
> f := proc(t) if 5 < t then sin(t) else 0 end if end proc;
> ball := proc (x, y) plots[pointplot]([[x, y]], color = blue, symbol = solidcircle, symbolsize = 40) end proc;
> animate(ball, [4, 'f'(t)], t = 0 .. 10, frames = 200);
Error, (in plots/animate) incorrect specification of points data

Erik

## Animation specified by a function create...

Thanks Preben

It works as you describe. I have another problem in connection to the same thing: I want a ball to follow a certain curve parametriced by (4,f(t)). The first coordinate is fixed to the value 4, whereas the second coordinate is a function of one variable, t. The commands works well if f(t) is a simple expression, say sin(t). My function is however defined using a simple procedure. The animate command fails, as you can see below. I don't know why - I even remembered unevaluation quotes. I hope someone can tell me how to make it work.

> restart;
> with(plots);
> f := proc(t) if 5 < t then sin(t) else 0 end if end proc;
> ball := proc (x, y) plots[pointplot]([[x, y]], color = blue, symbol = solidcircle, symbolsize = 40) end proc;
> animate(ball, [4, 'f'(t)], t = 0 .. 10, frames = 200);
Error, (in plots/animate) incorrect specification of points data

Erik

## Another option...

Often people get confused about the expression "printing to a pdf", but that is in fact what happens. In principle everything which can be printed on paper can be printed to a pdf file. The original Adobe Acrobat is the most advanced to my knowledge. It has many settings, but is quite expensive. Several free programs creating pdf files do a nice job in many circumstances. Another option is

PrimoPDF

I have been using that one myself on my laptop to cut expenses, whereas I am using Adobe Acrobat on my stationary computer. PrimoPDF has some nice settings: You can choose quality settings for Web, for Print and more. The better quality the bigger file, so it is a matter of choosing the appropriate for ones purpose. If pdf files are to be printed on paper, it requires higher quality to look good compared to when the pdf files are just made for wieving on the computerscreen ...

## Pagan, I agree with you that it was enou...

Pagan, I agree with you that it was enough for you to split the expression into two parts to display the problem. Splitting into more parts will only make it worse. I remember reading some numerical mathematics many years ago, but I don't have the energy to get deeper into the subject of floating point arithmetic again. And I would also need to study how Maple are doing things. I did however save the document you linked to for eventually later study. Thanks.

I am using Maple in my physics class in high school, so things should not get too complicated. Now I need to warn my students to use the evalf command. I am even wondering what happens when my students are rightclicking on Maple output and choose Approximate > 5 (a very basic action). Do they really get the result to five digits of precision or are the answer "downgraded" to maybe 3 or 4 digits, meaning one might only count on 3 or 4 digits or so? Maybe I should advice my students to go for 10 digits to feel more safe? I am a little shaken ;)

Erik

## evalf is a sophisticated command...

I think we can summarize that the evalf[n](...) is a rather sophisticated command and I agree with Axel Vogt that Maple help is not delivering sufficient or proper documentation for it. When reading the help menu for evalf one get the impression it is a very simple command, although somewhat down the details page, there is an example "When not to use evalf", but it is rather special. I hope Maplesoft will clarify how really evalf works in the Help menu.

## Evalf then of limited value ......

I understand the problem now: Maple is rounding off to two digits of the individual factors, then make the computation and is rounding off again. This is kind of disappointing. I had expected Maple to calculate the parentheses with full precision and only round off to two digits in the end. As it seem to be now, the evalf command is of limited value to me. Now I can't save command lines: I need to calculate first and then add a new command line in the end to force Maple to do it the way I want.

Why has Maple implemented the evalf command in this way? I don't see any value in that choice? Probably there is a reason, though :)

pagan: Shouldn't you divide your evalf computation in even more parts? I mean 4*(1391000/2)^2 could be divided as well.

Thank you for all your replies. I appreciate it!

Erik

## Units versus variables...

OK, thank you! This makes it work indeed. But then it was a bad suggestion Maple posed in the dialog: kg/m^3. It should have been kg/'m'^3. But maybe it is too much to ask for that Maple should keep track of the variables already defined? I had hoped though that Units and variables did not interfere. I mean units are put in double brackets and should not be mistaken with variables. But obviously that is not the case!

Erik

 First 11 12 13 14 15 16 17 Page 13 of 17
﻿