# Strange behavior when graphing a function (Maple)

I was doing a presentation on Limits and I was using this $$f(x)=\frac{x^2+2x-8}{x^2-4}$$ to explain different types of limits.

I know that the function is not defined at $x=-2$ or $x=2$. I showed the graph and everyone was ok with the graph at $x=-2$ but one member of the audience didn't like how the graph looked at $x=2$.

I think they didn't understand that a function doesn't need to be defined at the point to have a limit. I said there was a hole at $x=2$, not sure now because when I restricted the domain to be close to $x=2$ This was displayed. I used "discont=true" as an option of the plot command.

I computed both the left and right limits of $f(x), \; x\to 2$, both limits equal 3/2. I don't think there is any up and down behavior like $\sin(1/x)$

Is this a problem with maple or have I missed something about limits?

• Simplify: $$\frac{x^2+2x-8}{x^2-4} = \frac{(x^2-4) + 2(x-2)}{x^2-4} = 1 + \frac{2}{x+2}$$ is perfectly well-behaved near $2$. It's an artifact of floating-point arithmetic. – Daniel Fischer Sep 11 '14 at 10:01
• This doesn't happen to me, I get a nice, smooth curve with the generic command "plot". I use Maple 17. – user940 Sep 11 '14 at 12:12

Nope, that definitely shouldn't be happening. I think it must be an error with arithmetic with very small numbers, as computers only have so much precision. (You've used $|x-2|<10^{-7}$ so $|x^2-4|<10^{-14}$ which is the range you get problems in).

EDIT: the above is actually slightly wrong. $|x-2|<10^{-7}$ implies $|x^2-4|<4*10^{-7}$. Nonetheless, it's a problem with high precision arithmetic.

As mentioned, you are seeing artefacts of floating-point computation. These can be alleviated by increasing the working precision, by adjusting the Digits environment variable.

The default value of Digits is 10. Also, for an expression containing only arithmetic operations (and elementary functions) Maple's 'plot' command will try to use its faster evalhf double-precision interpreter if Digits is less than 15 which is trunc(evalhf(Digits)).

For your example the plot command's option discont=[showremovable] will mark the plot of the expression f at x=2 with a symbol. This works for your f which is an explicit expression, for which Maple uses its symbolic discont procedure to find the point discontinuity. It may not work if f were instead an operator (procedure), since in that case Maple would fall back to using its purely numeric fdiscont procedure.

restart:
f := (x^2+2*x-8)/(x^2-4):

Digits := 20: # increased working precision -- default is 10

plot( f, x=2-1e-6 .. 2+1e-6, discont=[showremovable] ); Using a wider domain the plotting command does not compute enough evaluations near x=2 to produce the artefacts you saw.

Digits := 10: # the default

plot( f, x=-3..3, discont=[showremovable] ); 