I wanted to know the exact solution to the following differential equation
$$ \frac{\mathrm{d}^2 y}{\mathrm{d} t^2} = - \frac{1}{y-1}, \quad \begin{aligned} y(0) &= 0 \\ \left. \frac{\mathrm{d} y}{\mathrm{d} t} \right|_{t = 0} &= 0 \end{aligned} $$
I expected some function that would increase with time until it hits one.
So I set up the DE in MMA
ClearAll[y];
DSolve[{y''[t] == -(1/(y[t] - 1)), y[0] == 0, y'[0] == 0}, y[t], t]
And the result is
{y[t] -> E^-InverseErf[-Sqrt[(2/\[Pi])] t]^2 (-1 + E^
InverseErf[-Sqrt[(2/\[Pi])] t]^2)}
So I try to plot it with derivatives
y[t] := E^-InverseErf[-Sqrt[(2/\[Pi])] t]^2 (-1 + E^
InverseErf[-Sqrt[(2/\[Pi])] t]^2);
Plot[Evaluate[{y[t], 1/(y[t] - 1), D[y[t], t], D[y[t], {t, 2}]}], {t,
0, 2}]
And everything goes fine.
However, when I'm trying to obtain the value at which the function stops (I think it is $t = \sqrt{\pi/2}$), MMA doesn't know
Solve[y[t] == 1, t]
{}
When I tried to get certain values, MMA doesn't even return a number!
y[0.5]
y[0.5]
or
Evaluate[y[0.5]]
y[0.5]
Clearly, the plot behaves well around $t = 0.5$, so why does it refuse to return a value?
The only thing that seems to work is the following
y[t] /. t -> 0.5
0.12777
Can someone please explain this behaviour? I am curious.
y[t_] :=....
, i.e. use the underscore in defining the function. $\endgroup$