# Getting Integrate::ilim error while plotting [closed]

I am a beginner in Mathematica. I want to plot for

t = 5

f[x_] = Integrate[Sqrt[ Tanh[x]], x]

r[x_] = Integrate[Cos[f[x]], x]

Plot[r[x], {x, -t, t},
AxesLabel -> {"x"},
PlotLabel -> "y",
PlotRange -> All,
PlotPoints -> 500]


but I'm getting error messages:

Integrate::ilim: Invalid integration variable or limit(s) in -4.99998. >>
Integrate::ilim: Invalid integration variable or limit(s) in -4.97994. >>
Integrate::ilim: Invalid integration variable or limit(s) in -4.9599. >>

Anyone knows a solution?

• 1) You should do Clear[x] before this code. 2) A more general tip is to learn the difference between = and :=, especially for function definitions like f and r. 3) And finally, the RHS of r[x] is asking Mathematica to compute an antiderivative for Cos[-ArcTan[Sqrt[Tanh[x]]] - 1/2 Log[1 - Sqrt[Tanh[x]]] + 1/2 Log[1 + Sqrt[Tanh[x]]] (which is what I get for Cos[f[x]]), and this is probably too much to ask. So look into NIntegrate instead. May 21, 2017 at 21:00
• Related: (75786), (124706), (135855) May 22, 2017 at 2:19

r[x_] = Integrate[Cos[f[x]], x]

you would have seen that Mathematica returned the integral unevaluated because it couldn't find a closed-form solution. One way to proceed with solving your problem is to numerically integrate to make a table of points along r[x] in the interval of interest.
f[x_] = Integrate[Sqrt[Tanh[x]], x]