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

  • Thread starter nufeng
  • Start date
6
0
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.
 

Simon Bridge

Science Advisor
Homework Helper
17,823
1,637
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?
 
6
0
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?
Thank you!
I know how to do it.
 

Simon Bridge

Science Advisor
Homework Helper
17,823
1,637
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?
 
6
0
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?
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])
answer is f(x) = 5*x^2-x

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);
 

Simon Bridge

Science Advisor
Homework Helper
17,823
1,637
Thank you :)
 

Related Threads for: Covert differential equation into a system of 1st order ODE?

Replies
6
Views
3K
Replies
3
Views
690
Replies
1
Views
653
Replies
2
Views
1K
Replies
4
Views
2K
Replies
14
Views
15K

Hot Threads

Top