How to solve this second order nonlinear differential equation?

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.

 Akzeptierte Antwort

Torsten
Torsten am 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 Kommentare

Thank you very much for your detailed answer!!! I will try it myself.
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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 Kommentare

Jane
Jane am 16 Apr. 2015
Bearbeitet: Jane am 16 Apr. 2015
Thank you very much for your answer. Actually 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.
And yes, we can assume A = 1.
The condition in the two boundaries is shown with derivative, therefore the equation contained three conditions: the initial value at the first boundary point, the derivatives of the two boundary points.
I found it difficult for me to deal with the power y^3 and y^5 in the calculation. I hope to find an algorithm to work out the numerical results. So sorry that I did not express it clearly.
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.
Jane
Jane am 16 Apr. 2015
Bearbeitet: Jane am 16 Apr. 2015
Torsten, thank you for your answer!
You are right for two boundary conditions, should I use the exact value one or the derivative one?
For a normal problem, this differential equation satisfied the derivative conditions in two boundaries.
Because most cases I have seen are given in two exact values for the boundaries, especially this one: [y'(end)+E*y(end) = 0], now I am not sure how to deal with the derivative conditions in bvp4c, could you offer some hints for the numerical calculation?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 16 Apr. 2015

Kommentiert:

am 17 Apr. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by