How to solve this second order nonlinear differential equation?
2 views (last 30 days)
Show older comments
Here is the differential equation:
A*y''=B*y+C*y^3+D*y^5;
Boundary condition: y(0) = constant(known); y'(0) = 0;
y'(end)+E*y(end) = 0.
I wanted to solve it in the numerical way with Matlab, and have tried the finite difference method to discretize the above differential equation and get:
(-3*y(0)+4*y(1)-y(2))/2/h = 0;
A*(y(i+1)-2*y(i)+y(i-1))/h^2 = B*y(i)+C*y(i)^3+D*y(i)^5;
(-3*y(I-2)-4*y(I-1)+3*y(I))/2/h+E*y(I) = 0.
I tried the quasi-Newton method to solve the equation set, but the given initial value (y(0) = constant(known)) could not be used. And the values changed with different pre-set initial values.
Is there another method to solve this problem?
P.S. : A,B,C,D and E have their own exact values and it related to a practical problem, but the values of these coefficients are in different order of magnitudes so I didn't put them on the questions. Also the boundary value y(0) is an exact number and for the same reason I replaced it with constant to make it simple.
Accepted Answer
Torsten
on 16 Apr 2015
function mat4bvp
xstart=0.0;
xend=...;
A=...;
B=...;
C=...;
D=...;
E=...;
solinit = bvpinit(linspace(xstart,xend,10),[0 0]);
sol = bvp4c(@(x,y)mat4ode(x,y,A,B,C,D),@(ya,yb)mat4bc(ya,yb,E),solinit);
% ------------------------------------------------------------
function dydx = mat4ode(x,y,A,B,C,D)
dydx = [ y(2)
(B*y(1)+C*y(1)^3+D*y(1)^5)/A ];
% ------------------------------------------------------------
function res = mat4bc(ya,yb,E)
res = [ ya(1)
yb(2)+E*yb(1)];
Best wishes
Torsten.
2 Comments
Torsten
on 17 Apr 2015
At the moment, the boundary condition at x=0 is y(0)=0.
Better use the following code:
function mat4bvp
xstart=0.0;
xend=...;
A=...;
B=...;
C=...;
D=...;
E=...;
constant=...;
solinit = bvpinit(linspace(xstart,xend,10),[0 0]);
sol = bvp4c(@(x,y)mat4ode(x,y,A,B,C,D),@(ya,yb)mat4bc(ya,yb,E,constant),solinit);
% ------------------------------------------------------------
function dydx = mat4ode(x,y,A,B,C,D)
dydx = [ y(2)
(B*y(1)+C*y(1)^3+D*y(1)^5)/A ];
% ------------------------------------------------------------
function res = mat4bc(ya,yb,E,constant)
res = [ ya(1)-constant
yb(2)+E*yb(1)];
Best wishes
Torsten.
More Answers (1)
John D'Errico
on 16 Apr 2015
No matter what, you can NEVER choose a unique set of coefficients for all four values, A,B,C,D, since if any set of numbers {A,B,C,D} satisfies that equation, then {k*A,k*B,k*C,k*D} also satisfies the equation as well.
So without any loss, you can assume A = 1.
y'' = B*y + C*y^3 + D*y^5
Next, you have completely insufficient information in that single boundary value to choose the three coefficients {B,C,D}. ONE piece of information is not enough.
Sorry, but you are wasting your time trying to solve this.
3 Comments
Torsten
on 16 Apr 2015
You can only prescribe two boundary conditions, not three, for your differential equation.
That being said, you can use bvp4c to solve.
Best wishes
Torsten.
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!