Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Solving Second Order Homogeneous Diff Eq

Subject: Solving Second Order Homogeneous Diff Eq

From: Cody

Date: 31 Jan, 2013 20:38:08

Message: 1 of 3

Hello everyone, I'm trying to solve the standard 2nd order differential equation with constant coefficients listed below under the specified boundary conditions:

-dP(x)^2/dx^2 = C * P(x) where C=(2*E*m)/h^2

under the boundary conditions P(-L/2)=0 and P(L/2)=0 for some constant L>0.

Matlab is able to solve the equation with the expected general solution, however, when I apply the boundary conditions, the 'dsolve' command fails. I know a solution exists under these boundary conditions because I can successfully solve the equation by hand, and the solution is listed in a textbook.

Matlab correctly calculates the general solution 'P(x)':

syms C E m h P(x) real
C=(E*2*m)/h^2;
assume(C>0 & E>0 & m>0 & h>0)
P(x)=dsolve( -diff(P,2)==C*P )

However, when I attempt to apply the boundary conditions Matlab calculates P(x)=0. I would appreciate any advice on how to correctly setup Matlab to solve this type of differential equation.

syms C E m h L P(x) real
C=(E*2*m)/h^2;
assume(C>0 & E>0 & m>0 & h>0 & L>0)
P(x)=dsolve( -diff(P,2)==C*P, P(-L/2)==0, P(L/2)==0 )

Thank you,
-MntGoat

Subject: Solving Second Order Homogeneous Diff Eq

From: Jonathan Nebauer

Date: 31 Jan, 2013 23:05:10

Message: 2 of 3

"Cody" wrote in message <keekng$cpo$1@newscl01ah.mathworks.com>...
> Hello everyone, I'm trying to solve the standard 2nd order differential equation with constant coefficients listed below under the specified boundary conditions:
>
> -dP(x)^2/dx^2 = C * P(x) where C=(2*E*m)/h^2
>
> under the boundary conditions P(-L/2)=0 and P(L/2)=0 for some constant L>0.
>
> Matlab is able to solve the equation with the expected general solution, however, when I apply the boundary conditions, the 'dsolve' command fails. I know a solution exists under these boundary conditions because I can successfully solve the equation by hand, and the solution is listed in a textbook.
>
> Matlab correctly calculates the general solution 'P(x)':
>
> syms C E m h P(x) real
> C=(E*2*m)/h^2;
> assume(C>0 & E>0 & m>0 & h>0)
> P(x)=dsolve( -diff(P,2)==C*P )
>
> However, when I attempt to apply the boundary conditions Matlab calculates P(x)=0. I would appreciate any advice on how to correctly setup Matlab to solve this type of differential equation.
>
> syms C E m h L P(x) real
> C=(E*2*m)/h^2;
> assume(C>0 & E>0 & m>0 & h>0 & L>0)
> P(x)=dsolve( -diff(P,2)==C*P, P(-L/2)==0, P(L/2)==0 )
>
> Thank you,
> -MntGoat

Your equation is second-order non-linear, and represents diffusion in most systems. As the continuous eigenspace of this equation is known to be stable, without an inital condition that is non-zero, or a differential set of BC's, I'm not sure that you could expect anything other than 0. Think the time-marching heat equation - an initial hot spot fades to a uniform value over the domain (assuming no energy loss). If you clamp the BC's to be 0 on the hot domain, the whole system will, in time, diffuse to zero -- which is exactly what you have done here.

Putting a perturbation into the system shows this:

>> N(x)=dsolve( -diff(P,2)==C*P, P(-L/2)==0.001, P(L/2)==0.000 )
 
N(x) =
 
(exp((2^(1/2)*L*(-E*m)^(1/2))/(2*h))*exp(-(2^(1/2)*x*(-E*m)^(1/2))/h))/(1000*(exp((2^(1/2)*L*(-E*m)^(1/2))/h) - exp(-(2^(1/2)*L*(-E*m)^(1/2))/h))) - (exp(-(2^(1/2)*L*(-E*m)^(1/2))/(2*h))*exp((2^(1/2)*x*(-E*m)^(1/2))/h))/(1000*(exp((2^(1/2)*L*(-E*m)^(1/2))/h) - exp(-(2^(1/2)*L*(-E*m)^(1/2))/h)))
 
Alternativly, solving your un-clamped case for zero at the ends is not possible, and with a perturbation, the result is still zero.

>> solve(log(-C1/C2)/C^(1/2)==log(-C2/C1)/C^(1/2)+eps)
 
ans =
 
20282409603651670423947251286016*(log(-C1/C2) - log(-C2/C1))^2

When the BC's go to 0, matlab is solving a quoteit of 1/Inf, producing zero.

Cheers

Subject: Solving Second Order Homogeneous Diff Eq

From: Torsten

Date: 1 Feb, 2013 07:22:04

Message: 3 of 3

"Cody" wrote in message <keekng$cpo$1@newscl01ah.mathworks.com>...
> Hello everyone, I'm trying to solve the standard 2nd order differential equation with constant coefficients listed below under the specified boundary conditions:
>
> -dP(x)^2/dx^2 = C * P(x) where C=(2*E*m)/h^2
>
> under the boundary conditions P(-L/2)=0 and P(L/2)=0 for some constant L>0.
>
> Matlab is able to solve the equation with the expected general solution, however, when I apply the boundary conditions, the 'dsolve' command fails. I know a solution exists under these boundary conditions because I can successfully solve the equation by hand, and the solution is listed in a textbook.
>
> Matlab correctly calculates the general solution 'P(x)':
>
> syms C E m h P(x) real
> C=(E*2*m)/h^2;
> assume(C>0 & E>0 & m>0 & h>0)
> P(x)=dsolve( -diff(P,2)==C*P )
>
> However, when I attempt to apply the boundary conditions Matlab calculates P(x)=0. I would appreciate any advice on how to correctly setup Matlab to solve this type of differential equation.
>
> syms C E m h L P(x) real
> C=(E*2*m)/h^2;
> assume(C>0 & E>0 & m>0 & h>0 & L>0)
> P(x)=dsolve( -diff(P,2)==C*P, P(-L/2)==0, P(L/2)==0 )
>
> Thank you,
> -MntGoat

P(x)=0 actually _is_ the solution of your ODE under the prescribed boundary conditions.
Insert it in your differential equations and you will see that it satisfies both the differential equation and the boundary conditions.

Best wishes
Torsten.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us