![]() |
![]() |
|||
|
As you've seen so far, Mathematica is a very powerful, very full featured program. That does not mean, however, that it it not without faults. Take, for example, the infamous case of Sin[(E+Pi)^20]. If we wanted to know the numerical value of this expression, we would type N[Sin[(E+Pi)^20]]. and trusting Mathematica's 16 digits of precision, be quite happy with the answer it gives us.
Since I suggested calculating with different levels of precision to make sure that you have the right answer, lets try with one more decimal of precision. If the first answer is not exactly correct, we might expect a few of the last digits to change a small amount due to round off error and the like.
That's a lot different! A further check with more precision gives us:
As you'll notice, the last decimal in the second step was 6, and it has been changed to 5 in the more precise calculation. This is more along the lines of what we should have expected between the first two steps. Next, we will consider the family of graphs based around x+sin(x). If we ask Mathematica to Plot[x + Sin[2 Pi x], {x, 0, 24}] we get the following:
An interesting, fairly regular and periodic graph. A slight alteration of our function to Plot[1.5x + Sin[2 Pi x], {x, 0, 24}] should give us a similar, although slightly steeper, result. Mathematica draws the following:
Not exactly what we were expecting, is it? The reason behind this is that Mathematica uses 25 evenly spaced PlotPoints to try and see where the graph is going. It interpolates the remaining points when it goes to graph the line. In this case all of our sample points are nearly linear due to the periodic nature of the Sin function. Asking Mathematica to draw the graph with only 20 PlotPoints nearly solves the problem:
The true solution, however, is to ask Mathematica to work a little harder. With 30 PlotPoints it looks pretty good. If you wanted a more precise drawing you could ask Mathematica to use successively more PlotPoints until you were satisfied.
Obviously Mathematica can not know when it is wrong. Your job as the mathematician will be to push it to be sure you are getting good data. Sometimes, however, Mathematica doesn't know when it is right either. Consider the function f = (x^3 + y^3)/(x^2 + y^2). If we take the second derivative with respect to x times the second derivative with respect to y and subtract the first derivative with respect to x and y squared, we get:
Although what I said sounds pretty complicated, and the answer Mathematica gave us looks pretty complicated, if you think about it you are subtracting the second derivative with respect to x and y from itself, so the answer should be 0 right? Asking Mathematica to look at it again via Simplify should reveal the truth of the matter.
Some of these examples are a little contrived, but it is important to remember that Mathematica is not an infailable program. Use it with a healthy amount of skepticism and you should find many applications of this powerful mathematical tool.
|
||||
| Tutorial
Home Table of Contents About this Site |
||||
| Previous: An overview of some commonly used functions for everyday calculation | Next: About this Site |
Last updated:5/1/02
|
||