1
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$ May 21, 2017 at 21:00
  • $\begingroup$ Related: (75786), (124706), (135855) $\endgroup$
    – Michael E2
    May 22, 2017 at 2:19

1 Answer 1

1
$\begingroup$

If you had looked at the output of

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]
With[{t = 5., dt = .05},
  data = Table[{u, NIntegrate[Cos[f[x]], {x, -t, u}]}, {u, -t, t, dt}];
  ListLinePlot[data, AxesLabel -> {"x", "y"}]]

plot

$\endgroup$
0

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