Lesson 3: Solving Equations; Floating-point Computationrestart;A hard equationLast time we were looking at this equation.eq := x * sin(x) = Pi/2;Maple didn't know the solutions.solve(eq,x,AllSolutions);Maple doesn't know the solutions, even though there are two that are easy to guess. It gave us a numerical valueevalf(%);and this turned out to be identify(%); The identify command is sometimes able to guess a formula that produces a decimal number. It isn't foolproof though. We can verify that this really is a solution by plugging it in to the equation, using eval.eval(eq, x = -1/2*Pi);Plotting Are there other solutions? It's almost always a good idea to draw a graph.plot(x*sin(x), x=-20..20);It would be handy to see the line LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JkYrLUYjNiYtRiw2JVEieUYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIj1GJy9GOlEnbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRkQvJSlzdHJldGNoeUdGRC8lKnN5bW1ldHJpY0dGRC8lKGxhcmdlb3BHRkQvJS5tb3ZhYmxlbGltaXRzR0ZELyUnYWNjZW50R0ZELyUnbHNwYWNlR1EsMC4yNzc3Nzc4ZW1GJy8lJ3JzcGFjZUdGUy1JJm1mcmFjR0YkNigtRiM2JC1GLDYlUScmIzk2MDtGJy9GN0ZERkBGQC1GIzYkLUkjbW5HRiQ2JFEiMkYnRkBGQC8lLmxpbmV0aGlja25lc3NHUSIxRicvJStkZW5vbWFsaWduR1EnY2VudGVyRicvJSludW1hbGlnbkdGZG8vJSliZXZlbGxlZEdGREZARitGQEYrRkA= too. Maple can plot several things in the same graph. You put the different items to plot within square brackets. plot([x*sin(x), Pi/2], x = -20 .. 20);It looks like there are infinitely many solutions.Click inside the plot, then right-click, choose "Probe Info" and "Cursor position" or "Nearest point on line", and you can see the coordinates of the "target" cursor. This lets you locate any point on the plot with better precision than you would have guessing "by eye", especially for points not on the axes.You can also resize the plot by grabbing and dragging the little boxes on the border of the plot window.By the way, notice that you don't plot an equation; what I plotted were the left and right sides of the equation. plot(eq, x=-20..20);I could have extracted the left or right side of the equation with the commands lhs and rhs.lhs(eq);rhs(eq);So I could have said something like this. While I'm at it, I'll change the colours.plot([lhs(eq), rhs(eq)], x = -20 .. 20, colour=[blue,black]);fsolveIn addition to solve which finds exact solutions (when possible), Maple has fsolve which finds a numerical approximation to a solution of an equation, even those that "solve" can't handle. Let's see how it handles our equation:fsolve(eq);That's the same solution we got before (probably not a coincidence: evalf used fsolve to get a value for the RootOf). If we want a different solution, we can specify an interval we want fsolve to look in. For example:fsolve(eq, x = 5 .. 10);Is there a formula for that one?identify(%);Probably not. If fsolve can't find a solution in the interval (usually because there isn't any), it returns unevaluated. For example, it looks like there won't be any solution between LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JkYrLUYjNiYtRiw2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIj1GJy9GOlEnbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRkQvJSlzdHJldGNoeUdGRC8lKnN5bW1ldHJpY0dGRC8lKGxhcmdlb3BHRkQvJS5tb3ZhYmxlbGltaXRzR0ZELyUnYWNjZW50R0ZELyUnbHNwYWNlR1EsMC4yNzc3Nzc4ZW1GJy8lJ3JzcGFjZUdGUy1JI21uR0YkNiRRIjVGJ0ZARkBGK0ZARitGQA== and LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JkYrLUYjNiYtRiw2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIj1GJy9GOlEnbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRkQvJSlzdHJldGNoeUdGRC8lKnN5bW1ldHJpY0dGRC8lKGxhcmdlb3BHRkQvJS5tb3ZhYmxlbGltaXRzR0ZELyUnYWNjZW50R0ZELyUnbHNwYWNlR1EsMC4yNzc3Nzc4ZW1GJy8lJ3JzcGFjZUdGUy1JI21uR0YkNiRRIjZGJ0ZARkBGK0ZARitGQA==.fsolve(eq, x = 5 .. 6);Usually fsolve returns one solution (if it can find one). The exception is for polynomials (or equations where both sides are polynomials in the variable), where fsolve returns all the real solutions (or all solutions in the specified interval). p := x^5 + x^3 - 3*x + 1;fsolve(p = 0, x);fsolve(p, x = 0 .. 1);If you do want complex solutions, you can add the option complex.fsolve(p, x, complex);Here's another difficult equation to solve.eq := sin(x)^2 = exp(-x)*cos(x);By the way, note that exp is the exponential function. In Maple input, it's exp(-x), not e^(-x); to Maple, e is nothing special, just another name. Maple shows exp(-x) as LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1JJW1zdXBHRiQ2JS1JI21vR0YkNi1RLyZFeHBvbmVudGlhbEU7RicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRJjAuMGVtRicvJSdyc3BhY2VHUSwwLjExMTExMTFlbUYnLUYjNiUtRjU2LVEqJnVtaW51czA7RidGOEY7Rj5GQEZCRkRGRkZIL0ZLUSwwLjIyMjIyMjJlbUYnL0ZORlYtRiw2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnL0Y5USdpdGFsaWNGJ0Y4LyUxc3VwZXJzY3JpcHRzaGlmdEdRIjBGJ0Y4RitGOA== in output, though if you look closely, you'll see that the e is in a different font than what it would use for the name e.e^(-x);Let's say I'm interested in positive solutions.plot([lhs(eq),rhs(eq)], x = 0 .. 25, colour=[red,blue]);It's a bit hard to see the blue curve because part of it is hidden by the x axis. We can get that out of the way.plot([lhs(eq),rhs(eq)], x = 0 .. 25, colour=[red,blue], axes = box);There's certainly one solution near x = .63, maybe some near x = 6.3, x = 9.4, etc, but it's hard to tell. We're interested in what happens near y = 0: most of the graph is wasted from that point of view. Notice that Maple automatically chooses the y interval to accommodate the curves it's plotting. But we can tell plot what y interval we want, if we don't like the one Maple chose.plot([lhs(eq),rhs(eq)], x = 0 .. 10, y = -0.01 .. 0.01, colour=[red,blue], axes = box);It looks like there are solutions near 6.3, but maybe not near 9.4. fsolve(eq, x = 6.1 .. 6.5);fsolve(eq, x = 9.2 .. 9.6);Actually a bit of thought and analysis explains why this is so. When LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUSJ4RicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnL0Y4USdub3JtYWxGJ0YrRjo= is more than 5 or so, the LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1JJW1zdXBHRiQ2JS1JI21vR0YkNi1RLyZFeHBvbmVudGlhbEU7RicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRJjAuMGVtRicvJSdyc3BhY2VHUSwwLjExMTExMTFlbUYnLUYjNiUtRjU2LVEqJnVtaW51czA7RidGOEY7Rj5GQEZCRkRGRkZIL0ZLUSwwLjIyMjIyMjJlbUYnL0ZORlYtRiw2JVEieEYnLyUnaXRhbGljR1EldHJ1ZUYnL0Y5USdpdGFsaWNGJ0Y4LyUxc3VwZXJzY3JpcHRzaGlmdEdRIjBGJ0Y4RitGOA== makes the right side very close to 0. The left side, being the square of something, is always LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYlLUkjbW9HRiQ2LVEvJkdyZWF0ZXJFcXVhbDtGJy8lLG1hdGh2YXJpYW50R1Enbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRjQvJSlzdHJldGNoeUdGNC8lKnN5bW1ldHJpY0dGNC8lKGxhcmdlb3BHRjQvJS5tb3ZhYmxlbGltaXRzR0Y0LyUnYWNjZW50R0Y0LyUnbHNwYWNlR1EsMC4yNzc3Nzc4ZW1GJy8lJ3JzcGFjZUdGQy1JI21uR0YkNiRRIjBGJ0YvRi8=, and = 0 only when LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUSJ4RicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnL0Y4USdub3JtYWxGJ0YrRjo= is a multiple of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JlEnJiM5NjA7RicvJSdpdGFsaWNHUSZmYWxzZUYnLyUwZm9udF9zdHlsZV9uYW1lR1ElVGV4dEYnLyUsbWF0aHZhcmlhbnRHUSdub3JtY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LUYsNi5RIj5GJy8lMGZvbnRfc3R5bGVfbmFtZUdRJVRleHRGJ0YvL0YzUSZmYWxzZUYnL0Y2RmVuL0Y4RmVuL0Y6RmVuL0Y8RmVuL0Y+RmVuL0ZARmVuL0ZCUSwwLjI3Nzc3NzhlbUYnL0ZFRl1vLUkjbW5HRiQ2JVEiMEYnRldGL0Yv; the right side is greater than the left side when LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUSJ4RicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnL0Y4USdub3JtYWxGJ0YrRjo= is exactly an even multiple of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUScmIzk2MDtGJy8lJ2l0YWxpY0dRJmZhbHNlRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnRjdGK0Y3, so they should be equal at some points on either side of those multiples of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUScmIzk2MDtGJy8lJ2l0YWxpY0dRJmZhbHNlRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnRjdGK0Y3. On the other hand, if LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUSJ4RicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnL0Y4USdub3JtYWxGJ0YrRjo= is near an odd multiple of LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUScmIzk2MDtGJy8lJ2l0YWxpY0dRJmZhbHNlRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnRjdGK0Y3, LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbW9HRiQ2LVEkY29zRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZ1bnNldEYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ2xzcGFjZUdRJjAuMGVtRicvJSdyc3BhY2VHRkMtSShtZmVuY2VkR0YkNiQtRiM2JC1JI21pR0YkNiVRInhGJy8lJ2l0YWxpY0dRJXRydWVGJy9GMFEnaXRhbGljRidGL0YvLUYsNi1RIjxGJ0YvL0YzUSZmYWxzZUYnL0Y2RlgvRjhGWC9GOkZYL0Y8RlgvRj5GWC9GQEZYL0ZCUSwwLjI3Nzc3NzhlbUYnL0ZFRmpuLUkjbW5HRiQ2JFEiMEYnRi9GLw== so there's no chance of a solution.Floating point computation and roundoff errorAs we saw in Lesson 1, Maple will write decimals or floating-point numbers with a certain number of significant digits, specified by the variable "Digits". Here are some floating-point numbers, with the default Digits = 10.evalf(Pi), evalf(exp(20)), evalf(exp(-7)), evalf(exp(-20));These are not exact values, they are approximations. To see more clearly what's going on, I'll use Digits = 3. Caution: Don't use small values of Digits if you really want to calculate something. We'll see why.Digits:= 3:
evalf(Pi), evalf(exp(20)), evalf(exp(-7)), evalf(exp(-20));The first and third could be represented as LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbW5HRiQ2JFElMy4xNEYnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy1JI21vR0YkNi1RIn5GJ0YvLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y4LyUpc3RyZXRjaHlHRjgvJSpzeW1tZXRyaWNHRjgvJShsYXJnZW9wR0Y4LyUubW92YWJsZWxpbWl0c0dGOC8lJ2FjY2VudEdGOC8lJ2xzcGFjZUdRJjAuMGVtRicvJSdyc3BhY2VHRkctSSVtc3VwR0YkNiUtRiw2JFEjMTBGJ0YvLUYjNiUtRiw2JFEiMEYnRi8vJSdpdGFsaWNHUSV0cnVlRicvRjBRJ2l0YWxpY0YnLyUxc3VwZXJzY3JpcHRzaGlmdEdGVEYv and LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbW5HRiQ2JFElOS4xMkYnLyUsbWF0aHZhcmlhbnRHUSdub3JtYWxGJy1JI21vR0YkNi1RMSZJbnZpc2libGVUaW1lcztGJ0YvLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y4LyUpc3RyZXRjaHlHRjgvJSpzeW1tZXRyaWNHRjgvJShsYXJnZW9wR0Y4LyUubW92YWJsZWxpbWl0c0dGOC8lJ2FjY2VudEdGOC8lJ2xzcGFjZUdRJjAuMGVtRicvJSdyc3BhY2VHRkctSSVtc3VwR0YkNiUtRiw2JFEjMTBGJ0YvLUYjNiUtRjM2LVEqJnVtaW51czA7RidGL0Y2RjlGO0Y9Rj9GQUZDL0ZGUSwwLjIyMjIyMjJlbUYnL0ZJRlYtRiw2JFEiNEYnRi9GLy8lMXN1cGVyc2NyaXB0c2hpZnRHUSIwRidGLw==, but Maple doesn't display numbers using "scientific notation" if the exponent is small.Roundoff error is the error that occurs in a calculation due to the fact that you're only using a finite number of digits. That's not "error" as in "mistake", it's just that the results of arithmetic with a finite number of digits can't be the same as what they would be in exact arithmetic, with arbitrarily many digits. The computer does the best it can with what is available: the result of each addition, multiplication, division etc. is as close as possible to the exact result of that operation on the same numbers, given that you only have Digits digits available. For example, to divide 1 by 3, the exact result is 1/3 = .333333..., but with Digits = 3 this must be rounded to just .333. And then if you multiply the result by 3, you get .999.1.0/3.0; % * 3.0;Many implementations of floating point actually store and calculate numbers in base 2 (converting to base 10 for output), but Maple actually uses base 10. Also, many calculators store more digits than they display, but Maple doesn't: with Maple floating point, what you see is what you get. This makes it useful for investigating the effects of roundoff error.Notice that floating-point arithmetic does not obey the usual rules of algebra. In algebra you would have (1/a)* a = 1. Not in floating-point.1 / 3.0 * 3.0;Similarly, in algebra you would have a + b - a = b. Not in floating point.9.99 + 6.66 - 9.99;How did that happen? Let's look at it in two steps.9.99 + 6.66; % - 9.99;The result of the first addition should be 16.65, but since Maple is using Digits = 3 it rounds that to 16.6.
Then it does 16.6 - 9.99 = 6.61.Often roundoff error only affects the last digit or two of a calculation, but sometimes it makes a big difference.Catastrophic cancellationOne case where roundoff error can be severe is if you subtract two numbers that are very close together. This is called "catastrophic cancellation".1.24 - 1.23;We subtracted two numbers with 3 significant digits, and the result has only one significant digit.For an example where this kind of thing can occur, think of the definition of derivative:LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYrLUkjbWlHRiQ2JVEiZkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIidGJy9GM1Enbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRj0vJSlzdHJldGNoeUdGPS8lKnN5bW1ldHJpY0dGPS8lKGxhcmdlb3BHRj0vJS5tb3ZhYmxlbGltaXRzR0Y9LyUnYWNjZW50R0Y9LyUnbHNwYWNlR1EsMC4xMTExMTExZW1GJy8lJ3JzcGFjZUdRJjAuMGVtRictSShtZmVuY2VkR0YkNiQtRiM2JC1GLDYlUSJhRidGL0YyRjlGOS1GNjYt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HRkQvJSdhY2NlbnRHRkQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZTLUkobWZlbmNlZEdGJDYkLUYjNiZGKy1GIzYmLUYsNiVRImFGJ0Y2RjktRj02LVEiK0YnRkBGQkZFRkdGSUZLRk1GTy9GUlEsMC4yMjIyMjIyZW1GJy9GVUZeby1GLDYlUSJoRidGNkY5RkBGK0ZARkBGQEYrRkBGK0ZA and LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JkYrLUYjNiYtRiw2JVEiZkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RMCZBcHBseUZ1bmN0aW9uO0YnL0Y6USdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGRC8lKXN0cmV0Y2h5R0ZELyUqc3ltbWV0cmljR0ZELyUobGFyZ2VvcEdGRC8lLm1vdmFibGVsaW1pdHNHRkQvJSdhY2NlbnRHRkQvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZTLUkobWZlbmNlZEdGJDYkLUYjNiQtRiw2JVEiYUYnRjZGOUZARkBGQEYrRkBGK0ZA that are typically very close together; the smaller LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1GLDYlUSJoRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnL0Y4USdub3JtYWxGJ0YrRjo= is, the worse the roundoff error will be. So actually trying this numerically is going to run into problems. Let's say you wanted LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2JVEiZkYnL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WxsZWRHRkZGQkYrRkJGK0ZC. The mathematical answer is -1/3. But try it with Digits = 3 and some values of h.Q:= (3.0/(3.0+h) - 3.0/3.0)/h;eval(Q,h=0.1);Not bad: try a smaller h.eval(Q,h=0.01);eval(Q,h=0.001);eval(Q,h=0.0001);With Digits = 10, things would go better for these values of h.Digits:= 10:eval(Q,h=0.1);
eval(Q,h=0.01);
eval(Q,h=0.001);
eval(Q,h=0.0001);But even then, if we continue to decrease h we eventually run into trouble.eval(Q,h=0.00001);eval(Q,h=0.0000001);eval(Q,h=0.000000001);Digits:= 3:One good way to think about this is in terms of absolute and relative errors. In approximating a "true value" T by an approximate value A, the absolute error is |T-A|. The relative error is
|T-A|/|T|.
In representing a number in floating point the relative error should be at most 5 * 10^(-Digits).When two numbers are multiplied or divided, the relative error of the result is at most (approximately) the sum of the two relative errors. This usually doesn't cause any problems.When two numbers are added or subtracted, the absolute error of the result is at most the sum of the two absolute errors. If the result is close to 0, this means the relative error can be much larger than the relative errors of the original numbers. The absolute error might be small, but if you multiply the result by a large number (as we did in approximating the derivative) it will multiply the absolute error also.Maple objects introduced in this lessonRootOfI%%%%%%AllSolutionsaboutevalidentifyplotlhsrhsexpcolourfsolve..complex