Need help while defining ode function for bvp4c/bvp5c/ode45 solve
이전 댓글 표시
I wanted to define system of ode functions for my higher order problems. I have differential equations are :
x=cosy
z=siny
y'=sqrt((lambda*f*p*siny/x)+(siny^2/x^2)-(2/lambda^2)+(2*cosy/lambda)-(3*a*p^2*lambda^2/2))
y"=(-y'*x'/lambda*x)-(cosy/x)-(f*p'/4)-(f*x'*p/4*x)+(y'*cosy/x)+(siny/lambda)+(lambda*f*p*cosy/4*x)+(siny*cosy/x^2)+(mu_1*(sin(y) - mu_2*cos(y)) / (2 * x^2)
where, y,x,p are functions of s. and f,lambda and a are constants.
while defining ode function for my bvp solve, I write the code as
function dydx = odefun2(t, y, params)
lambda = params.lambda;
a = params.a;
f = params.f;
mu_1=params.mu_1;
mu_2=params.mu_2;
y1 = y(1); % y
y2 = y(2); % x
y3 = y(3); % z
y4 = y(4); % p
y5 = y(5); % p_dot
y6 = cos(y1); %x_dot
y7 = sin(y1); %z_dot
ydot = sqrt((lambda * f * y4 * sin(y1) / y2) + (sin(y1)^2 / y2^2) - (2 / lambda^2) + (2 * cos(y1) / lambda) - (3 * a * (y4^2) * lambda^2)/2);
yddot = -((ydot * cos(y1) / (lambda * y2))) - (cos(y1) / y2) - (0.5 * y5 / 4) - (0.5 *cos(y1) * y4 / (4 * y2)) + (ydot * cos(y1) / y2) + (sin(y1) / lambda) + (0.5 * lambda * y4 * cos(y1) / (4 * y2)) + (sin(y1) * cos(y1) / y2^2) + (mu_1*(sin(y1) - mu_2*cos(y1)) / (2 * y2));
dydx = [y5; y6; y7; ydot; yddot];
end
But I have no equation for p'. And I am not sure that how can I relate x and z with x' and z' respectively. Also I don't have any differential equation for p'. how I should relate p and p'?
need some suggestions.
댓글 수: 11
You cannot work with two different differential equations for one and the same solution variable (in your case y).
Or is it an implicit equation for p that
d/dt (y'(t)) = y''(t)
or written out
d/dt (sqrt((lambda*f*p*siny/x)+(siny^2/x^2)-(2/lambda^2)+(2*cosy/lambda)-(3*a*p^2*lambda^2/2))) =
(-y'*x'/lambda*x)-(cosy/x)-(f*p'/4)-(f*x'*p/4*x)+(y'*cosy/x)+(siny/lambda)+(lambda*f*p*cosy/4*x)+(siny*cosy/x^2)+(mu_1*(sin(y) - mu_2*cos(y)) / (2 * x^2)
?
Md Sojib
2024년 6월 6일
No. I say that you can't solve a system of differential equations that contains contradictory equations.
Say you have a system
y'' = 1
y' = 3*t
Then differentiating the last equation gives
y'' = d/dt (3*t) = 3
contradicting the first equation
y'' = 1
Or did you arrive at the equation for y'' by just differentiating y' with respect to t ? Then the equation for y'' is superfluous.
Md Sojib
2024년 6월 6일
Torsten
2024년 6월 6일
You didn't answer my questions.
Torsten
2024년 6월 6일
The equations for x and z make no problem because they don't need to be solved. Once you have y, you also have x and z. And expressions for x or z in the equation for y can be substituted by cos(y) and sin(y).
So you need to solve for y and p. What are the equations and what are the boundary/initial conditions ?
Md Sojib
2024년 6월 6일
I tried to explain that you cannot use both equations for y because they contradict each other.
And you didn't supply an equation for p. Or - a question you did not yet answer - should p be deduced from the equation
d/dt (y'(t)) = y''(t)
or - written out -
d/dt ( sqrt((lambda*f*p*siny/x)+(siny^2/x^2)-(2/lambda^2)+(2*cosy/lambda)-(3*a*p^2*lambda^2/2)) ) =
(-y'*x'/lambda*x)-(cosy/x)-(f*p'/4)-(f*x'*p/4*x)+(y'*cosy/x)+(siny/lambda)+(lambda*f*p*cosy/4*x)+(siny*cosy/x^2)+(mu_1*(sin(y) - mu_2*cos(y)) / (2 * x^2)
?
Torsten
2024년 6월 6일
Then you will have to dive into the derivation of the equations again. If you don't know the equation for a function within your problem formulation, how do you want to solve it ?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!