How to solve differential equation with variable in differential term?

조회 수: 3 (최근 30일)
Tien Ching Ma
Tien Ching Ma 2023년 2월 28일
답변: DUY Nguyen 2023년 3월 2일
I'm trying to solve differential equations with polar coordinate, the equation looks like the following:
r*dy/dr = A*r*exp(B*(C-x(r))) - y(r)
dx/dr = y(r)./D
I'm using ode45 solver with boundary conditions that y(r=0) = 0, and x(r=R) = E.
Since in ode45 tutorial guide of Matlab, I didn't see any example with "r" included in dy/dr term, I simply divide the first equation with r.
It becomes:
dy/dr = A*exp(B*(C-x(r))) - y(r)/r
And I would have a problem that when r = 0, y(0)/0 = Nan.
I understant that from the mathematical view 0/0 doesn't make sence, but from my physical view, I need y(0) = 0 at the this point. Therefore, I just ignore the last term when r = 0 by using if function:
if r == 0
dy/dr = A*exp(B*(C-x(r)));
else
dy/dr = A*exp(B*(C-x(r))) - y(r)/r;
end
Could someone tell me if there is any other solver/method can solve this r*dy/dr = A*r*exp(B*(C-x(r))) - y(r) equation? Or could the method I'm using so far would lead to some problems?
Thanks a lot!

답변 (1개)

DUY Nguyen
DUY Nguyen 2023년 3월 2일
You could try to define a new variable u = r + eps ( where eps is a small positive number close to zero, should be carefully chosen) and solving the differential equation on the interval [eps, R] instead of [0, R]. This approach will effectively shift the singularity at r = 0 to u = eps, where it can be avoided.

카테고리

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