# NSolve and NIntegrate, or a better approach

I need to define and plot the following function

$$a(t) := \exp\left(\int Z(t)\; dt\right)$$

where $$Z(t)$$ is the solution to the equation

$$0 = t - 2 \int^Z_1 F(x)\; dx$$

with $$F = F(x)$$ being a known (but complicated and non-integrable) function.

How do I define and plot the function $$a(t)$$ in Mathematica?

Here is my attempt with a particular function $$F(x)$$ that I need to work with:

A = 0;
F[x_] = - ((4*A*x^(9/2) + 64*x^6 - 4*Sqrt[A*x^9*(32*x^(3/2) + A)])^(1/3)/(16*x^4 - 4*x^2*(4*A*x^(9/2) + 64*x^6 - 4*Sqrt[A*x^9*(32*x^(3/2) + A)])^(1/3) - (4*A*x^(9/2) + 64*x^6 - 4*Sqrt[A*x^9*(32*x^(3/2) + A)])^(2/3)));

A = 0;
Int[Z_?NumericQ] := NIntegrate[F[x], {x, 1, Z}]
S[t_?NumericQ] := NSolve[t - 2*Int[Z] == 0, Z]
a[t_] := Exp[Integrate[S[t], t]]


However, when trying to evaluate for example $$a(2)$$ I get the following error:

• When you said non-integrable you meant to say that it doesn't have a closed-form expression right? Commented Mar 14, 2021 at 13:14
• @AnswerMyQuestion yes Commented Mar 14, 2021 at 14:41

Edit

Maybe use NDSolve. Here we differential the original equation and get two ODEs.

If we set $$a(t)=\exp\left(\int_{0}^tZ(s)\,\mathrm{d}s\right)$$ then $$a(0)=1$$ and $$a'(t)=a(t)Z(t)$$

vice versa

DSolve[{a'[t] == a[t]*Z[t], a[0] == 1}, a[t], t]


$$a(t)\to \exp \left(\int _0^tZ(s)\,\mathrm{d}s\right)$$

A = 0;
F[x_] := -((4*A*x^(9/2) + 64*x^6 - 4*Sqrt[A*x^9*(32*x^(3/2) + A)])^(1/
3)/(16*x^4 -
4*x^2*(4*A*x^(9/2) + 64*x^6 -
4*Sqrt[A*x^9*(32*x^(3/2) + A)])^(1/3) - (4*A*x^(9/2) +
64*x^6 - 4*Sqrt[A*x^9*(32*x^(3/2) + A)])^(2/3)));
sol = NDSolve[{a'[t] == a[t]*Z[t], 1 == 2 F[Z[t]]*Z'[t], a[0] == 1,
Z[0] == 1}, {a, Z}, {t, 0, .4}]
Plot[{a[t], Z[t]} /. First[sol] // Evaluate, {t, 0, .4}]


• How do you know that a[0]==1? Commented Mar 14, 2021 at 9:07
• @yarchik integrating from 0 to 0 gives always 0, no?
– Sito
Commented Mar 14, 2021 at 13:56
• @Yes, right, I have seen you updated your post. The original question is somewhat ambiguous. Commented Mar 14, 2021 at 14:22
• @yarchik how so? Commented Mar 14, 2021 at 14:43
• @SNC92 Have a look at your definition of $a(t)$, there is an indefinite integral on the rhs, which is defined up to a constant. cvgmt properly writes a definite integral on the rhs, which is uniquely defined. Commented Mar 14, 2021 at 15:02