# Domain definition of a function

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 ?

• The limit as x -> 0 exists, and Mathematica is fine with that. Do Limit[f[x], x -> 0]. Nov 5, 2015 at 18:43
• Have a look Finding Limits
– user9660
Nov 5, 2015 at 18:51
• 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 Nov 5, 2015 at 19:41
• 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. 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. Nov 5, 2015 at 21:24

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 produces error messages and "skips" the point at x = 0

Plot[fun, {x, -1, 1}] 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]
` 