To write the second-order differential equation y''(x) = 1/sqrt(x) * y(x)^(3/2)
in the standard form suitable for Matlab's ODE solvers, we need to convert it into a system of first-order differential equations:
main.m44 chars3 lines
Here, y
and z
are new functions defined as the first and second derivatives of the original function y
, respectively. Note that the initial condition for this system should include y(1)
, since the given equation is not defined for x=0
.
We can then use Matlab's ode45
solver to numerically integrate the system of differential equations:
main.m265 chars11 lines
This code defines an anonymous function dydx
that takes x
and y=[y(x); z(x)]
as inputs and returns the corresponding derivatives [y'(x); z'(x)]
. It then sets the initial condition y0
as [y(1); y'(1)] = [1; 0]
and solves the system of differential equations numerically using ode45
. Finally, it plots the solution y(x)
as a function of x
.
gistlibby LogSnag