what I should do-----second order variable coefficients ODE??

조회 수: 5 (최근 30일)
petter
petter 2012년 7월 14일
Hi, matlab person,I have some problems about second order variable coefficients ODE.
Thank you very much for any suggestion or help.
equation: x^2 y''+x y'-sin(y)cos(y)+4*k/pi*x sin(y)^2-x^2 sin(y)cos(y)=0
boundary condition: y(0)=0;y'(0)=-0.126
The following is my code, but there are several problem:
first defining function *********************************************
function yprime = skyrmion(x,y)
k=0.95;
yprime = [y(2); -1/x*y(2)+1/x^2*sin(y(1))*cos(y(1))-4*k/pi* (1/x)*sin(y(1))^2+sin(y(1))*cos(y(1))];
*********************************************************
Then transfer function
*****************************************************
xspan=[0.01,10];
y0=[-0.126;pi];
[x,y]=ode45('skyrmion',xspan,y0);
plot(x(:),y(:,2))
****************************************************
problem one:
Because The ODE was divided by x^2, so the x span can't use x==0. whether the code can be modified to not divide x^2.
problem two:
the results get by using my code are not consist with some papers.
so I want to know my code is right or wrong.
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 7월 14일
편집: Walter Roberson 2012년 7월 14일
To confirm: x is independent and there is y(x) ? In particular, it is not x(t) and y(t) ?
And y'' is diff(diff(y(x),x),x) ?
petter
petter 2012년 7월 15일
Yes,y is y(x) and y''is diff(diff(y(x),x),x) .
can you give some advise for solving this ODE.
Thank you again.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2012년 7월 14일
편집: Star Strider 2012년 7월 14일
Your initial equation:
x^2 y''+x y'-sin(y)cos(y)+x sin(y)^2-x^2 sin(y)cos(y)=0
does not contain the ‘-4*k*pi’ term that appears in your second one:
yprime = [y(2); -1/x*y(2)+1/x^2*sin(y(1))*cos(y(1)) -4*k/pi * (1/x)*sin(y(1))^2+sin(y(1))*cos(y(1))];
So should
-4*k*pi
be
-4*k*pi/x^2
instead?
I found no other problems with your conversion of the first equation to your ‘yprime’ matrix expression. You could simplify it a bit by combining the ‘sin(y)*cos(y)’ terms to ‘(1+1/x^2)*sin(y)*cos(y)’ but I doubt that would make much of a performance difference.
I believe ‘ode45’ will avoid the singularity at x=0 on its own, and search for solutions elsewhere. If you want to be certain about this, contact TMW Tech Support and ask them.
  댓글 수: 4
petter
petter 2012년 7월 16일
In other paper, they solved this ODE by Runge-Kutta method. the different of asymptotic behavior near x=0 is not the largest, My results are different from their results in the region of large x
In deed, their results show y appears to converge to 0 with x -> infinity. My results show trigonometric performance for large x. I feel I should consider the consideration y(infinite)=0 But I don't know how I should add the boundary condition y(infinite)=0 to ODE45.
Thank you for your help.
Star Strider
Star Strider 2012년 7월 16일
편집: Star Strider 2012년 7월 16일
My pleasure! The ‘ode45’ function is also a Runge-Kutta solver, according to the documentation. You and the authors you quote are both correct as I understand it. The behavior of the integrated differential equation is similar to that of ‘exp(-x)*cos(x)’ so while it approaches zero asymptotically for large x, it also remains periodic.
I doubt it is possible to add the boundary condition of y(x->infinity) -> 0 to ‘ode45’, although the function seems to do this itself. You might be able to do this with ‘bvp4c’. I have used ‘bvp4c’ once, so I do not feel qualified to comment on how you would apply it to your differential equation. I will experiment with it later.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 7월 14일
Please check my transcription of your equations:
dsolve( [x^2*((D@@2)(y))(x)+x*(D(y))(x)-sin(y(x))*cos(y(x))+x*sin(y(x))^2-x^2*sin(y(x))*cos(y(x)), (D(y))(0) = 0, ((D@@2)(y))(0) = -.126])
When I use that, Maple believes there is no solution. Indeed it thinks that even when I do not provide the boundary conditions.
  댓글 수: 1
petter
petter 2012년 7월 15일
Thank you for your reply. I have no idea about maple.Indeed,I believe my ODE has not analytical solutions. So I want to use ODE45 to get numerical solutions.
now except the problem of the singularity at x=0,other question is if I want to carry out other boundary condition such as y(infinite)=0
can you give me some advice for solving this problem?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by