Harnessing symbolic functionality one can get a glimpse of beauty of the mathematical world and a quantum of deeper understanding, therefore often it is of high importance and preferable to exploit symbolic rather than numeric tools, even though in certain cases the latter would yield more. Thus it is a reasonable practice to put forward exact methods and use approximate ones only if symbolic functionality fails.
We'll demonstrate that the function to be minimized is quite involved
$$y(t,a)=6\;\wp\bigg(t-1+\wp^{-1}\Big(\frac{a}{6};\;0,\frac{a^3}{54}-\frac{1}{36}\Big);\;0,\frac{a^3}{54}-\frac{1}{36}\bigg)$$
where $\wp$ is the Weierstrass elliptic function and it can be done with NMinimize
as well as with FindMinimum
, however getting the actual result involves some insight into the matter because of suboptimal handling of elliptic functions and integrals in Mathematica (a marvelous trademark figured out by J.M.). Encountering this issue wherever below one will be warned with this sign $**$.
Let's start with a few quite natural observations. Having equations of the form y''[t] == y[t]^2
it is a good idea to multiply it by y'[t]
and integrate it once using initial (boundary) conditions.
$0=y''(t)-y(t)^2\; $ thus $\;0=y'(t) y''(t)-y(t)^2 y'(t)\;$ i.e. $\;0=1/2 \;y'(t)^2 -1/3\; y(t)^3 +c$ and using initial conditions we find: $\;c=-1/2 + a^3/3 $. Rewriting $\;y(t)=6 w(t)$ one obtains:
$$w'(t)^2-4w(t)^3+ \frac{a^3}{54} - \frac{1}{36}=0$$
This is a standard form of a differential equation for the Weierstrass elliptic function $w'(t)^2-4w(t)^3+ g_2 w(t)+g_3=0\;$ with $\;g_2=0$ and $g_3= \frac{a^3}{54} - \frac{1}{36}$.
Mathematica can $**$ solve this more general form on the symbolic level without specifying initial conditions:
w[t]/. DSolve[ w'[t]^2 - 4 w[t]^3 + g2 w[t] + g3 == 0, w[t], t]
{ WeierstrassP[ t - C[1], {g2, g3}], WeierstrassP[ t + C[1], {g2, g3}]}
however one might be misled using it $**$ with $g_2=0$.
Now, using once more the initial conditions we find
C[1] == 1 - InverseWeierstrassP[ a/6, {0, a^3/54 - 1/36}]
and finally:
y[t_, a_] := 6 WeierstrassP[ t - 1 + InverseWeierstrassP[ a/6, {0, a^3/54 - 1/36}],
{0, a^3/54 - 1/36}]
when plotting this function $**$ one uses Re[ y[2,a]]
rather than y[2,a]
alone, since the latter produces $**$ some nonvanishing imaginary perturbations.
Plot[ Re @ y[2, a], {a, -3, 0}, AxesOrigin -> {0, 0}, PlotStyle -> Thick]
$**$ Minimize[{y[2, a], -3 < a < 0}, a]
doesn't work, however $**$ NMinimize[{ Re @ y[2, a], -3 < a < 0}, a]
works fine and alternatively an excellent approximation $**$ with FindMinimum
as you liked can be found:
FindMinimum[ Re @ y[2, a], {a, 0}] // Quiet
{0.0964433, {a -> -1.65429}}
If we'd like studying full complexity of the function y
, a useful tool might be e.g.
Manipulate[ Plot[ Re @ y[t, a], {a, -10, 10}, AxesOrigin -> {0, 0}, PlotStyle -> Thick],
{t, -30, 30}]
which wouldn't be readily available with a numerical approach.
Another nice application and a bit more detailed explanation of a few issues related to elliptic functions one can find in e.g. Integrate yields complex value, while after variable transformation the result is real. Bug?. Elliptic functions are solutions to certain nonlinear ordinary differential equations and being implemented in Mathematica 1.0 they might be slightly revised, although some useful functionality like WeierstrassHalfPeriodW1
is implemented also in verion 11.2.