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

nufeng
Messages
6
Reaction score
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.
 
Physics news on Phys.org
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?
 
Simon Bridge said:
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.
 
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?
 
Simon Bridge said:
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);
 
Thank you :)
 
Thread 'Direction Fields and Isoclines'
I sketched the isoclines for $$ m=-1,0,1,2 $$. Since both $$ \frac{dy}{dx} $$ and $$ D_{y} \frac{dy}{dx} $$ are continuous on the square region R defined by $$ -4\leq x \leq 4, -4 \leq y \leq 4 $$ the existence and uniqueness theorem guarantees that if we pick a point in the interior that lies on an isocline there will be a unique differentiable function (solution) passing through that point. I understand that a solution exists but I unsure how to actually sketch it. For example, consider a...
Back
Top