This is a modification of a post I made to the usenet newsgroup sci.math in autumn 1995. Please send suggestions for further modifications to rusin@math.niu.edu. This file currently resides at: http://www.math.niu.edu/~rusin/teaching-math/calc.errors but a more up-to-date version is at http://www.math-atlas.org/99/calc_errors I had written to sci.math: >What I _do_ want is a collection of examples which _appear_ appropriate for >calculator use but in which the calculator will err. I received a number of helpful replies, and found an old post on the subject. I will summarize the examples below. They're sorted according to the error or trap rather than the application, since the mathematicians in this group are likely to be able to think of novel ways of re-using or re-presenting them. The examples are all pretty obvious once you think to look for them, but it's not me who thought to look for them. For the most part they're adapted from examples mailed, posted, or published in calc books already (including those of Stewart, Finney/Thomas, and Hughes-Hallett/Gleason) Thanks to those who contributed. Have fun, dave DEFICIENCIES OF CALCULATORS ESPECIALLY AS USED IN CALCULUS COURSES I. Limitations to reasonable, numerical data and common functions A. Machines can't graph y = A x^2 for symbolic A (not even y=(A^2+1) x^2, whose graph is arguably "the same" for all real A.) B. Simple machines can't find e.g. extrema of y=A x^2 + B x + C expressed symbolically in terms of literal variables A, B, C. Warning: computers with symbolic algebra programs _can_ do this, and calculators with such capabilities are now on the market. C. I am not aware of any hand-held machine which can handle numbers larger than 10^100, so of course any problem in which 70! can be made to appear will defy calculator users. (It's not a calculus problem, but several of us instructors have wept in abstract algebra classes when students compute, say, 5^16 mod 17 by first computing 5^16, ...) D. Some machines cannot graph or compute functions defined in parts (e.g. f(x)=f1(x) for x< 0, =f2(x) for x > 0.) In particular, some cannot handle the greatest integer function. E. As far as I am aware the handhelds now available cannot graph functions defined implicitly, unless the curves can be rewritten explicitly or parametrically. I have had PC programs purport to graph these functions but miss multiple branches. (e.g., x^3+5x^2+6xy^2+y^3=1) Of course, there is no difficulty creating more conceptual questions which will forever be just beyond the machine's reach, e.g. "Suppose f is a function whose graph is sketched below..." II. Loss-of-precision errors. I used to call this "overflow" or "underflow" but really the problem is that two or more quantities of wildly different magnitudes are being combined, resulting in loss of (sometimes important) precision. Here are some examples. 1) Find lim (x->0) of (1-cos(x^6))/x^12; do this by examining the graph. (As soon as x^6 is less than 10^-6, cos(x^6) will be reported as 1 on a 12-digit calculator.) 2) Find lim (x->0) 1/(1-cos (x^4)) - 2/x^8 graphically (the x^(-8) terms quickly swamp the O(1) terms which you really need). 3) Calculate the derivative of sqrt(x) at x=10^6 numerically from the definition. If you try to push (sqrt(10^6+h)-1000)/h for h around 10^-6 the h's get lost; of course this can better be computed as 1/(sqrt(10^6+h)+1000). 4) Find lim (x->0+) x/(x^x-1). The correct limit is zero, but after a couple of zooms the student is still looking at the point (0.00625, -.2). 5) Sketch the graph of (x-50)^3*exp(-x) on [0,60] (Here the problem is that the scales on the x- and y- axes are very different.) 6) A standard for calculus classes is the computation of (1+1/n)^n for large n. Try taking for n the first few powers of 1000; the limit appears to be 1 ! 7) Numerical limit experiments can be deceiving. For example, lim(h->0) [sqrt(1000000+h)-1000]/h quickly strains the accuracy of the calculator. The same difficulty can be more creatively masked using identities with gross cancellation, such as 8721 * 3^(1/2) - 10681 * 2^(1/2) = 1 / (8721 * 3^(1/2) + 10681 * 2^(1/2)) There is a lesson to be learned about Taylor series, too, if the students try to evaluate lim(x->0) 1/(sin x)^2 - 1/x^2 by substituting x=10^(-n) for n>3 or 4 say. (The limit is 1/3). Consider these limits as x->0: x/(x^(sin x) -1) and |sin(1/x)|^(1/x^2); both numerically and graphically these are nightmares; the first approaces 0 and the second does not. 8) Of course there are whole fields (e.g. Numerical Analysis) devoted to the handling of difficult cases, which can be a source of classically unstable problems. There are also plenty of examples in analysis of functions or sequences whose behaviour is unclear except in the very large or very small (e.g. sum(1/(n log(n)), n=2..\infty).) III. Discretization errors A. In singularities like y=sin(1/x) I find the pixelated graph to be much less informative than the hand-drawn one. Likewise, the graph of y=sin(10^8 * x) shows no apparent pattern. (Interestingly, my TI-82 with the standard window shows a very definite pattern for the graph of y=sin(10^7 * x) !) B. Of course there are plenty of numerical examples, fooling students who think the calculator is secretly carrying infinitely many places of accuracy. They may be convinced that e^(pi*sqrt(43)) is an integer (if they use a computer, have them check e^(pi*sqrt(163)) instead). If you succeed in convincing them pi is not 22/7, try 355/113; or ask them for the positive root of 242 x^4 + 113 x - 23928, and see how many make a leap of faith. Likewise with cos(5 pi/16) = .5555702... which isn't really 5/9 but rather sqrt(2 - sqrt(2 - sqrt(2)))/2. My TI-82 also appears to know that pi is a special number, but reports sin(4*pi)=2*10^(-13), so evidently it is not treated symbolically after all. [Another fun example of misleading sequences: solve numerically log(x^4+x^5)=6] C. I was recently floored by a student making a discretization error related to the graphing display. The student graphed y=1-x/12 on a TI-82 (standard window: [-10,10] x [-10,10] ) and happily transcribed to her paper a step function... D. Ask the students whether or not f(x)= 1000 + |x|/x + x is continuous. The default display will show none of the graph (see next section); a clever student might think to zoom out. But if a big enough window is chosen, then the discontinuity is lost to view. E. Likewise no calculator's display can show the absence of one point in a curve; we may all agree that f(x) = (x^2-1)/(x-1) has a domain which excludes {1}, but the calculator cannot show it. IV. Graphing-window traps Students, naturally, begin with the default window on the graph of a function (typically showing the behaviour on [-10,10], say). It's easy to make examples in which this --- shows none of the graph (e.g. y=40+ln(x) ) --- fails to show large-scale behaviour (e.g. y=10^(-6)(x-1000)^3 ) --- misses extrema (e.g. f(x)=(x^2)exp(-.004x) ) --- suggests false limits (e.g. lim x-->-oo x^3/(x^3+10 x^2) is a particularly good trap on the TI default window [-10,10]! ) These problems can be fixed by zooming out far enough. Others require zooming in, especially --- failing to show small-scale variation (e.g. y=x^4-x^2+0.2 has 3 roots) Of course you can combine these into examples for which both zooming in and zooming out are necessary to get a complete picture. Here's a polynomial I once cooked up for students who were studying different techniques of root-finding: f(x)=4 x^7-10 x^6-5 x^5+(53/2)x^4 -22 x^3 + (59/2)x^2 -(69/2)x + 9 (its roots are -1.8794..., 0.3473..., 1.5, 1.5, 1.5321..., and -.25 +- sqrt(-15)/4 ; the successive extrema between the real roots are roughly +191.37, -16.22, and -.0003 -- not at all easy for a graphing calculator to display!) Likewise, I'm not even really sure what I wold _like_ students or the calculator would do in some cases: what is the graph of x^25/1.0001^x ? Its maximum (around x=10^6/4) is about 10^124, but the function decays to 0 as x-> oo. Is it really "right" to use Cartesian coordinates here? I'm not sure how zooming could really identify asymptotes. Ask your students to discuss the dips in the graph of y = ln(|cos(x)|), for example, or x^4+ln(1+cos(x)) (which approaches -\infty at pi, but which is positive for xThe TI-82 and -85 use adaptive Gauss-Kronrod integration (check out >http://archive.ppp.ti.com/pub/graph-ti/calc-apps/info/numinter.txt ). > >Some experimentation shows that the '85 uses 7 nodes while the '82 uses >(if I remember correctly) 15. > >So an error you can catch the '85 at: > >Integrate ( x(5x^2-3)(891x^4-990x^2+155) )^2 on [-1,1] and get 0. > >The HP-48GX seems to use a change of variables and a Romberg method >that dates back to some much earlier HP calculators. ("Handheld >Calculator Evaluates Integrals", William M. Kahan, Hewlett-Packard >Journal, August 1980) The handheld referred to in the title is the >HP-34C; it's a detailed article and tests lead me to believe the same >integrator is still in place in HP's latest machines. > >An error you can catch the HP-48G at: > >Integrate (cos(512 Pi x))^2 on [0,1] and get 1. > [Just try to graph the integrand on any calculator and have some fun]. > >As the HP Journal article points out, any numerical integration routine >has an Achilles' heel. This fact is pointed out in most numerical >integration texts. ============================================================================== From: Michael Hanke Newsgroups: sci.math.num-analysis Subject: Reference wanted Date: Mon, 16 Jun 1997 11:31:25 +0200 Hello, for more than 10 years I am using a special example in an undergraduate course on Numerical Analysis in order to demonstrate the effect of roundoff errors in an numerically unstable algorithmn. I found this example in a simple textbook for pupils showing the danger in believing the results of an electronic calculator without critical doubt. Unfortunately, no source was given. I heard some rumour that this example belongs to L. Fox, but I was not able to find a citation. Please help me to find the original reference. Thank you. The example: Compute the integral $I_n:=\int_0^1 x^ne^{x-1} dx$. $I_0$ can be easily computed analytically. By partial integration we obtain $I_n=1-nI_{n-1}$. This recursion is unstable, roundoff error accumulates as n-factorial. This is very impressive for students since after a very few steps the computed $I_n$ is exploding while the exact value is between 0 and 1. Michael Hanke ============================================================================== Date: Fri, 1 Nov 1996 08:43:41 -0500 (EST) To: rusin@vesuvius.math.niu.edu Newsgroups: sci.math.symbolic Subject: Re: Bugs wanted ! From: jacques.gelinas@drev.dnd.ca (Jacques Gelinas) A surprising example of computer software bug is the so-called 15-digit number bug of Microsoft Excel 7.0 for Windows 95 (and earlier versions), involving multiples of 2**(-49), 2**(-50) and 2**(-51). Enter 1.40737488355328 in a cell of this spreadsheet and you get ... 0.64 exactly! A patch is available. ============================================================================== From: israel@math.ubc.ca (Robert Israel) Newsgroups: sci.math.symbolic Subject: Re: Maple "int" Errors? Date: 6 Feb 1997 17:38:11 GMT In article <32F9D163.41C6@cip.mathematik.uni-stuttgart.de>, Thomas Haeberlen writes: |> can anyone give some examples for functions where the Maple int-command |> (either definite or indefinite integrtion) gives wrong results? I |> remember one thread about a related question but that was some time |> ago... . If not for "int", where else do wrong results occur? It's for a |> demonstration of the capabilities and limitations/"dangers" of a |> symbolic math package so the context should be explicable to |> "non-experts". There are lots of examples where the antiderivative is a multivalued function in the complex plane, and the path of integration crosses the branch cut that Maple uses. This is difficult for a program to detect, and very often causes an error in the definite integral. In Release 3, > int(sin(x)/(1+x^2), x = -infinity .. infinity) I sinh(1) Pi The correct answer, of course, is 0. This one has been corrected in Release 4, but you still have > int(exp(-I*t)/(1+t^2),t=-infinity .. infinity); 0 where the correct answer is Pi/e. Another is > int(exp(I*t)/(exp(I*t)+1/2), t=0..2*Pi); 0 where the correct answer is 2 Pi. Indefinite integration generally gives correct results, but sometimes not simplified very well, e.g. (this was pointed out by Sjoerd Rienstra) > int(1/(1+cos(x)^2), x); The result looks horrible, but should be arctan( tan(x)/sqrt(2) ) /sqrt(2). Also, despite having implemented the Risch algorithm, there are still cases where Maple fails to find an elementary antiderivative, e.g.: > int(2^x/sqrt(1 + 4^x), x); The reason seems to be that Maple doesn't realize that 4^x = (2^x)^2. Robert Israel israel@math.ubc.ca Department of Mathematics (604) 822-3629 University of British Columbia fax 822-6074 Vancouver, BC, Canada V6T 1Y4 ============================================================================== From: jpg@math.math.unm.edu (Jeffrey P. Golden) Newsgroups: sci.math.symbolic Subject: Re: Article on Wolfram/Mathematica in Wall St Journal Date: 1 Oct 1996 01:57:18 GMT > (the Beta 3 version only) and I like it better than 2.2.3. Aside from > being more robust in terms of integration, it is able to give conditional > answers (taking certain integrals, for example you would get different > solutions for different ranges, Mma 3 provides these). > > [...] It is surprising to me that given these conditional answers for integration that Mathematica 3.0 still gets Integrate[x^n,x] wrong. It still gives x^(n+1)/(n+1) when one might have expected perhaps If[n != -1, x^(n+1)/(n+1), Log[x]] . It is also hard to get real answers for real integrals sometimes with Mathematica 3.0 . E.g. sometimes you want Integrate[1/x,x] to give Log[Abs[x]] instead of Log[x] ; or Integrate[1/(x^2+a),x] to give a real answer when symbolic a<0 . You might like Integrate[Sqrt[1-Cos[x]],x] to give a continuous answer without spurious discontinuities since the integrand is continuous over real intervals. And should Integrate[Abs[x],x] give an answer? Mathematica 3.0 doesn't think so. (I hope all of my observations of Mathematica 3.0 are correct. The Mathematica 3.0 "Vision of Mathematica" came to M.I.T. today.) From: Jeffrey P. Golden Organization: Macsyma Inc. Reply-To: jpg@macsyma.com URL: http://www.macsyma.com ============================================================================== Excerpts from: From: A.Esser@Mailer.Uni-Marburg.DE (Alex Esser) Newsgroups: sci.math.symbolic Subject: Maple V R4 can't solve 3 simple problems Date: Fri, 23 Aug 1996 18:42:51 +0200 I have just started working with Maple V R4 and stumbled over three very simple problems which Maple couldn't solve: # Example 1 > assume(n,even); > additionally(n>0); > is(n,odd); FAIL # Why doesn't Maple return "false" ?! # Example 2 > assume(n>0); > limit(x^(n+1),x=0,left); (n~ + 1) lim x x -> 0- # Here is the problem! # Example 3 > f := piecewise(x<=0,0,x); > readlib(discont): > discont(f,x); {0} # Although this is only a list of possible discontinuities... > limit(f,x=0); 0 # ...Maple should know that f is continuous ============================================================================== More Maple errors, all presumably problems with branch-cut choices: #1: > int(1/((x^2 + x)^2 + 1),x=-infinity..infinity); #Obviously positive 0 #2: > evalf(int(log(5+cos(x)),x=0..1)); #Obviously real 16.16847078 + 19.73920880 I #Maple requires the slightly different > evalf(Int(log(5+cos(x)),x=0..1)); # to get 1.764697791 #3: > sum(m*Z^m,m=1..infinity); #correctly gets Z/(Z-1)^2 > sum(m*Z^m,m=0..infinity); #gets a complicated expression; simplify with > factor("); taylor(",Z); #to see it missed the terms with m=0,1: 2 3 4 5 6 2 Z + 3 Z + 4 Z + 5 Z + O(Z ) #4: > maximize(x1^2, {x1}, {x1=0..1}); #correct 1 > maximize(x1^2+x2^2, {x1,x2}, {x1=0..1, x2=0..1}); #incorrect 0 > maximize(x1^2+x2^2+x3^2, {x1,x2,x3}, {x1=0..1, x2=0..1, x3=0..1}); > #No answer, which is incorrect too I guess. #5: Not really Maple's error, I suppose: > x*y/(x+y-1); x y --------- x + y - 1 > subs(x=1,y=0,"); 1 > subs(y=0,x=1,""); 0 #6: Mathematica can't Solve[] : From: bruck@math.usc.edu (Ronald Bruck) Newsgroups: sci.math.num-analysis Subject: Re: Mathematica & f(x)=0 Date: 14 Nov 1998 12:59:35 -0800 [...]That said, I do wish Mathematica would improve its symbolic computation abilities. For example, surely the solver could be taught that Solve[Sin[x] == 0,x] should have x = n * Pi as a solution, not just x = 0. If it knew even THAT much, it could solve a whole raft of other problems. I warn my students to be very cautious of the Solve command, even when it seems to work, and to pay ATTENTION to those warnings. Try solving f'[x] == 0 for f[x_] = (1 + Sin[x]^2)/(2 + Cos[x]). Mathematica returns five solutions, and when you plot the function on [0,2 Pi] you see five local maxima and local minima; but TWO of its solutions aren't real! Still, to its credit, it does attempt to take ArcCos. It entirely misses the solution at x = Pi. ============================================================================== Date: Thu, 31 Oct 1996 09:12:05 -0500 From: David Hart To: Dave Rusin Subject: Re: Bugs wanted ! [sci.math.symbolic] [deletia -- djr] Incidentally, regarding the errors that you point out for Maple: - int(x*(1-x), x=0..1); returns -1/6 was fixed by a patch almost immediately after release 3 came out, two years ago [and is not present in release 4]. - int( sqrt(cos(x))^2, x=0 .. Pi); returns 0 seems to me correct; for example sqrt(cos(2))=I*sqrt(-cos(2))~=.64I, ( sqrt(cos(2)) )^2=cos(2)~= -.42, and (sqrt(cos(x)))^2 = cos(x). By the way, int( sqrt(cos(x)^2), x=0..Pi); returns 2, which seems to be correct, also. Also, the error that you list for Mathematica: - Integrate[ 1/x^2, {x,-1,1}] returns -2 is not present in version 2.2.2 [and presumeably not in 3.0, currently being released], which is all that I have currently available. I get "Integrate::idiv: Integral does not converge". I realize that these softwares are a moving target, and that there could still be [and probably are] less flagrant errors; but I believe that the situation regarding these particular examples was the same a year ago [when you posted your note]. I appreciate your effort to serve the community, and encourage you to correct these points [if you agree that you were mistaken] [agreed! -- djr. Further deletia...] David Hart [later addenda received -- djr] After looking some more, I see that I have been confused about different versions. "integrate( sqrt( (cos(x))^2 ), x=0..Pi);" used to return 0, [in rel 3], now returns 2 [in rel 4]. ============================================================================== Date: Thu, 31 Oct 96 08:41:03 CST From: rusin (Dave Rusin) To: dhart@indiana.edu Subject: Re: Bugs wanted ! [sci.math.symbolic] Thanks, I'll take a fresh look at the file. Even if some of the bugs are fixed in newer releases, there are older copies in use so that care is needed even to avoid the old errors. The situation for sqrt(cos(x)^2) is perhaps a matter of preference. If you want the composite to be analytic, and to take the value cos(x) for some specific x, then the composite must equal cos(x) for all x. This would cause the integral to be zero, as reported by that early version of Maple. On the other hand, it seems a little disingenuous to refer to the sqrt at all if it's not a function (this use of sqrt(u) requires knowning not only u but also the value of x for which u=cos(x). That is, sqrt(1)= 1 if x=0, sqrt(1)= -1 if x=Pi). If you define sqrt in the traditional way (as the _positive_ square root for real numbers, or the _principal value_ for complex numbers) then one can only conclude sqrt(cos(x)^2) = |cos(x)|. In particular, the integral of this function must be positive. At some point the "bug vs feature" debate takes over, which is why I consider the CASs to be a great tool but not a substitute for "real" calculation. For example, would you agree that (x^a)^b = x^(a/b) ? Then isn't (x^2)^(1/6) = x^(2/6) = x^(1/3) ? But for x<0, these functions aren't equal. Well, I can't imagine which step of this process I want a CAS not to do automatically, so I have to be prepared for such a system to give me answers I disagree with sometimes. [deletia -- djr] ============================================================================== From: Peter Newsgroups: sci.math.symbolic Subject: Maple Bugs?? Date: Sun, 30 Nov 1997 21:11:58 -0800 > eq1:=x+1+1/(x-2)=3+1/(x-2); 1 1 eq1 := x + 1 + ----- = 3 + ----- x - 2 x - 2 > solve(eq1,x); 2 eq1 should have NO solution. x = 2 is NOT a solution since 1/(x-2) is undefined for x = 2. > eq2:=1/(2^x-1)-4/(2^x+1)=(2*(2-4^x))/(4^x-1); x 1 4 2 - 4 eq2 := ------ - ------ = 2 ------ x x x 2 - 1 2 + 1 4 - 1 > solve(eq2,x); _Z _Z _Z _Z _Z 2 _Z 2 _Z RootOf(-3 2 4 + 3 2 + 3 4 - 1 - 4 (2 ) + 2 (2 ) 4 ) > allvalues("); 0 The solution of eq2 is x = -1. x = 0 is NOT a solution since 1/(2^x-1) is undefined for x = 0. ============================================================================== New Maple goof: > limit(ln(-2+a*t^2),t=0); #Causes some kind of infinite loop. Note that... > limit(ln(-2+(3+2*I)*t^2),t=0); ln(2) + I Pi > limit(ln(-2+(3-2*I)*t^2),t=0); ln(2) - I Pi > limit(ln(-2+a*t),t=0); lim ln(-2 + a t) t -> 0 #...are all handled in the mathematically appropriate way New example hard for calculators: graph (x-1)/(x-3)^2