Question: Plotting cos(x) - x

I regularly choose a function for my numerical analysis class that looks bad (i.e., has jumps) when graphed on a small domain.  For example,

plot(ln(1+x), x = -10^(-15) .. 10^(-15))

If I increase Digits or use a Taylor series to replace ln(1+x), the graph looks fine.

I tried this with cos(x) - x as follows:

plot(cos(x)-x, x = -10^(-16) .. 10^(-16))

(That's 10^-16, by the way.)  I got what appears to be a jump discontinuity.  However, I can't clear it up --- I've tried increasing Digits to 100, setting numpoints to 1000, setting adaptive to 50, and using a 50th degree Taylor polynomial in place of cos(x) - x.

 

Any ideas what's going on?  (Is there a fix?)

 

Thanks,

Mark

 

Please Wait...