How to solve the ODE $$ y’’(t)=y(t)+t, $$ with initial conditions $y(0)=0$ and $y’(0)=0$.
I’ve found $y=-t$ and $y=e^t-t$, but both aren’t valid solutions because of the two initial conditions.
How to solve the ODE $$ y’’(t)=y(t)+t, $$ with initial conditions $y(0)=0$ and $y’(0)=0$.
I’ve found $y=-t$ and $y=e^t-t$, but both aren’t valid solutions because of the two initial conditions.
First solve the homogeneous part $y''-y=0$., put $y=e^{mt}$, you get $m=\pm 1$, so $y=A e^t + B e^{-t}$. Next let $y=p t +q$ in $y''-y=t \implies 0-p t -q =t \implies p=-1, q=0$. Thius the complrtre solution is $$y= A e^{t} +B e^{-t}-t.$$
Using Duhamel’s principle.
Firstly, we consider u solves the problem
$$\left\{\begin{array}{rl} u’’-u =0&t>s;\\u=0,u’=s&t=s. \end{array}\right.$$ Then we get $$u(t;s)=\frac{s}{2}e^{t-s}-\frac{s}{2}e^{-(t-s)}.$$ Hence by duhamel’s principle we know \begin{align} y(t)&=\int_0^t u(t;s)\,ds\\ &=\int_0^t \frac{s}{2}e^{t-s}-\frac{s}{2}e^{-(t-s)}\,ds\\ &=\frac{1}{2}e^t-\frac{1}{2}e^{-t}-t. \end{align} That is the solution to your problem.
Using power series expansion and a simple linear least-squares:
Set up polynomial basis (truncated power series), add some small regularization, for example Tihkhonov regularization, ($\epsilon = \lambda$):
$$\bf M = D^2 - I$$
$$\min_{\bf v}\left\{\|{\bf Mv-d}\|_2^2 + \epsilon \|{\bf v}\|_2^2\right\}$$
Initial conditions directly translate to $${\bf v}_1 = {\bf v}_2=0$$ which we can enforce with adding cost function: $$ + \|{\bf Cv}\|_2^2$$
$\bf C$ diagonal matrix two upper left elements 1 and rest 0.
We can solve in some software for example Matlab:
$$\begin{bmatrix} 0.166666666666666 &0.166666666666667\\ 0.008333333333333& 0.008333333333333\\ 0.000198412698411& 0.000198412698413\\ 0.000002755731878& 0.000002755731922\\ 0.000000025050038& 0.000000025052108\end{bmatrix}$$
left is solved non-zero coefficients.
Right is Taylor expansion of solution around $t=0$ according to wolfram alpha:
$$y(t) = \frac{1}{2}\left(e^{t}-e^{-t}\right) - t$$