Letting $u=y'$ is the right idea. This gives you the pair of equations
\begin{align*}
u' &= \frac{y}{9} - \pi ye^{x/3}(2u\sin(\pi x) + \pi y\cos(\pi x))\\
y' &= u
\end{align*}
which is a standard initial value problem. Notice that there are no $x$ derivatives, so you can integrate each value of $x$ separately. So fix some value for $x$ and discretize the system using your favorite method -- I am a big fan of Velocity Verlet:
\begin{align*}
y_{n+1} &= y_n + hu_n\\
u_{n+1} &= u_n + h \left(\frac{y_{n+1}}{9}-\pi y_{n+1}e^{x/3}(2u_n\sin(\pi x)+\pi y_{n+1}\cos(\pi x))\right),
\end{align*}
where $h$ is the time step; you could also use e.g. forward or backward Euler (you say you want "Euler's method" but there are at least three!). You know $u_0$ and $v_0$ from the initial conditions, so just iteratively apply the above rules to trace out the trajectory through time.
EDIT: Forward Euler would be
\begin{align*}
u_{n+1} &= u_n + h \left(\frac{y_{n}}{9}-\pi y_{n}e^{x/3}(2u_n\sin(\pi x)+\pi y_{n}\cos(\pi x))\right),\\
y_{n+1} &= y_n + hu_{n+1}
\end{align*}
Notice that I strongly recommend against using Explicit Euler in pretty much any circumstance.
Analytic solution :
$$y(x)=-\int \frac{-ax+b+k}{-x^2+x+m} = \frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{2x-1}{\sqrt{4m+1}} \right) - \frac{a}{2}\ln|-x^2+x+m | +C$$
With condition $y(0)=-y(1)$ :
$y(0)=\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{-1}{\sqrt{4m+1}} \right) - \frac{a}{2}\ln|m | +C$
$C=y(0)-\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{-1}{\sqrt{4m+1}} \right) + \frac{a}{2}\ln|m|$
$$y(x)=y(0)-\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{-1}{\sqrt{4m+1}} \right) + \frac{a}{2}\ln|m|+ +{\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{2x-1}{\sqrt{4m+1}} \right) - \frac{a}{2}\ln|-x^2+x+m |} $$
As a consequence :
$y(1)=y(0)-\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{-1}{\sqrt{4m+1}} \right) + \frac{a}{2}\ln|m| + {\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{1}{\sqrt{4m+1}} \right) - \frac{a}{2}\ln|m|} $
$y(1)=y(0)+2\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{1}{\sqrt{4m+1}} \right)$
The second condition $y(1)=-y(0)$ implies :
$-y(0)=y(0)+2\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{1}{\sqrt{4m+1}} \right)$
$y(0)=-\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{1}{\sqrt{4m+1}} \right)$
$$y(x)=-2\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{-1}{\sqrt{4m+1}} \right) + \frac{a}{2}\ln|m|+ +{\frac{a-2b-2k}{\sqrt{4m+1} }\tanh^{-1}\left( \frac{2x-1}{\sqrt{4m+1}} \right) - \frac{a}{2}\ln|-x^2+x+m |} $$
Best Answer
MATLAB doesn't support second order differential equations outright; it's your job to turn your problem into a system of first order differential equations, as mentioned here.
To wit, first construct the appropriate
function
:and, using
ode45()
as an example,ode45(@rapidash,[0,1],(conditions))
.