# Why Plot does not work with a computed integral?

I have been following the examples of the official W|A documentation; exactly:

http://reference.wolfram.com/language/tutorial/UsingANotebookInterface.html

The Plot command generates the x and axes, but it does not show the corrersponding plot:

See this screenshot: • Isn't the value of the function -Infinity at 1 and an imaginary number at 2? – bobthechemist Feb 12 '15 at 18:52
• I think you found a bizarre error (or two) in the documentation. – george2079 Feb 12 '15 at 20:35

f[x_] = Integrate[1/(x^3 - 1), x]


-(ArcTan[(1 + 2 x)/Sqrt]/Sqrt) + 1/3 Log[1 - x] - 1/6 Log[1 + x + x^2]

If you look at some values of the function you will see that it is complex. You must plot a real-valued function.

Table[{x, f[x]}, {x, 1., 2., .25}]


{{1., Indeterminate}, {1.25, -1.32673 + 1.0472 I}, {1.5, -1.16171 + 1.0472 I}, {1.75, -1.084 + 1.0472 I}, {2., -1.03869 + 1.0472 I}}

Plot[{Re[f[x]], Im[f[x]], Abs[f[x]]}, {x, 1, 2},
PlotLegends -> "Expressions"] • Really interesting would be an idea what was the version of the system evaluating here Examples of Integrals – Artes Feb 12 '15 at 19:08
• @Artes - It is not a version issue but rather an error in the documentation. The graph in the documentation show the x axis from 0 to 1 even though the Plot is supposed to be from 1 to 2. – Bob Hanlon Feb 12 '15 at 19:13
• Indeed, however neither this works as they claimed: Integrate[1/(x^3 - 1), x] then Plot[%, {x, 0, 1}] yields something different. – Artes Feb 12 '15 at 19:24

Let's have a look at Plot: If you specify xmin and xmax, the function f is calculated with these values ​​and plotted. Actually, you plug xmin and xmax in the function f and get the corresponding result.The plot corresponds to your specifications.

The integral is given the name f:

f = ∫1/(x^3 - 1) \[DifferentialD]x
(*
-(ArcTan[(1 + 2 x)/Sqrt]/Sqrt) + 1/3 Log[1 - x] - 1/6 Log[1 + x + x^2]
*)


If we generate some plots with different xmin and xmax we can represent the behavior of xmin and xmax like so:

po0 = Plot[f, {x, 1, 2}];
po1 = Plot[f, {x, -1, 1}];
po2 = Plot[f, {x, -5, 5}];
po3 = Plot[f, {x, -5, 5}, PlotRange -> All]; This means: a plot of f as a function of x from xmin to xmax is not equal to the PlotRange.

You can check FunctionDomain and FunctionRange with:

{FunctionDomain[f, x], FunctionRange[f, x, y]}


$\left\{x<1,y<\frac{\pi }{2 \sqrt{3}}\right\}$

To check if expression contains a complex expression you can use:

FreeQ[f, _Complex]
(*
True
*)


or

FunctionDomain[f, x, Complexes]


$(x-1) \left(2 \sqrt{3} x-3 i+\sqrt{3}\right) \left(2 \sqrt{3} x+3 i+\sqrt{3}\right) \left(x^2+x+1\right)\neq 0$

And now we can plot the function f with real part, imaginary part and absolute value:

Plot[{Re[f], Im[f], Abs[f]}, {x, -4, 4}, PlotRange -> All,
PlotTheme -> "Detailed"] 