# Covert differential equation into a system of 1st order ODE?

1. Nov 6, 2012

### nufeng

How to covert this differential equation into a system of one order ODE?
(require covert the equation into a system of 1st-order equations and solve by using ode23 in matlab)

x^2*y''-2*x*y'+2*y = 0;
y(1) = 4; y'(1)=0;
solve for y(x)

I tried to convert it
get

X' = AX
in which
X = [y, z]'
A = [0, 1; 2/x^2, 2/x];

But x exists in A, which cannot solve by dsolve in Matlab.

2. Nov 7, 2012

### Simon Bridge

You have left out steps in your reasoning.
You are mixing math and matlab notation: is the "prime" for derivative or transpose?

Try: $$X=\left [ \matrix{y\\z}\right ]$$ $$X^\prime=AX$$

What did you make $z$ equal to?

3. Nov 7, 2012

### nufeng

Thank you!
I know how to do it.

4. Nov 7, 2012

### Simon Bridge

Great to hear!
For the benefit of those poor souls who google to this page off a similar problem, and find my reply too obtuse perhaps you will post the answer?

5. Nov 7, 2012

### nufeng

solve by MAPLE
first, solve 2nd order differential equation
ode2 := x^2*(diff(f(x), x, x))-2*x*(diff(f(x), x))+2*f(x) = 0
ics2 := (D(f))(1) = 9, f(1) = 4
dsolve([ode2, ics2])

convert to a system of 1st ode
sys1ode := diff(y(t), t) = z(t), diff(z(t), t) = -2*y(t)/t^2+2*z(t)/t
ics := y(1) = 4, (D(y))(1) = 9
dsolve([sys1ode, ics])
solution: {y(t) = t*(5*t-1), z(t) = 10*t-1}

My original problem is I want to solve this problem by using ode23 or ode45 in MATLAB,
code:

% subfunction to define the equation
function f = funcENGM801(t,x);
A =[0,1;-2/(t+1)^2,2/(t+1)]; % here I change t to t+1
f = A*x ;

% main function
format longEng
tspan = [0: 0.01: 1];
x0 = [4,9];
[t,x] = ode45('funcENGM801', tspan, x0);

6. Nov 7, 2012

Thank you :)