2
$\begingroup$

I study the following equation:

f[x_] := (Exp[2*x] - Log[E + x])/(x^3 + Sin[x]*Cos[x])

Plot[f[x], {x, -10, 2}]

When I observe the plot of this function, It seems that there is no problem on 0. However, the denominator of the function can not be nul.

Indeed, if I solve the following equation, i see that the denominator can be nul at 0.

NSolve[(x^3 + Sin[x]*Cos[x]) == 0, x, Reals]

May you give ideas about my misunderstanding? Is it because of Mathematica or do I make stupid mathematical mistakes ?

$\endgroup$
4
  • 2
    $\begingroup$ The limit as x -> 0 exists, and Mathematica is fine with that. Do Limit[f[x], x -> 0]. $\endgroup$
    – march
    Nov 5, 2015 at 18:43
  • 1
    $\begingroup$ Have a look Finding Limits $\endgroup$
    – user9660
    Nov 5, 2015 at 18:51
  • $\begingroup$ Great!!! Very clear and interesting for me! I just don't understand why the discrete plot produces an error message and the continous plot doesn't produce error messages. May you clarify me this point ? It may be because you say that both "skips" at zero $\endgroup$
    – Bendesarts
    Nov 5, 2015 at 19:41
  • 1
    $\begingroup$ One thing that happens is the continuous Plot only samples your function at a finite number of points and in this case it never happens to evaluate f[0]. Since the function is smooth near zero the adaptive algorithm doesn't see the issue. In the unlikely event it hits your limit point it is robust enough to ignore the single-point error. $\endgroup$
    – george2079
    Nov 5, 2015 at 21:24

1 Answer 1

6
$\begingroup$

With Version 10.x there is FunctionDomain:

fun = (Exp[2*x] - Log[E + x])/(x^3 + Sin[x]*Cos[x])

FunctionDomain[fun, x, Reals]

-E < x < 0 || x > 0

fun /. x :> 0

Indeterminate

`Table[{x, fun}, {x, -1, 1, 0.1}] // ListPlot

enter image description here

produces error messages and "skips" the point at x = 0

Plot[fun, {x, -1, 1}]

enter image description here

doesn't produce error messages since it "skips" the singularitiy at x = 0

Visualize the two discontinuities:

fun /. x :> -E // FullForm

DirectedInfinity[-1]

point = Table[{x, fun}, {x, -0.005, 0.005, 0.0001}] /. {__, {_, a_}, {_, Indeterminate}, {_, b_}, __} :> Point[{0, (a + b)/2}] // Quiet

Plot[Re@fun, {x, -E - 1, 1},
 Axes -> False,
 Epilog -> {Red, Dashed, Line[{{-E, 4}, {-E, -1}}], PointSize[0.02], point},
 Prolog -> {Inset["Directed Infinity at x = -E", {-2.3, 0.5}], 
   Inset["Indeterminate at x = 0", {0.4, 1.4}]},
 Frame -> True,
 GridLines -> Automatic,
 ImageSize -> Large,
 PlotRange -> Full]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.