http://www.mathworks.com/matlabcentral/newsreader/view_thread/326283
MATLAB Central Newsreader  Solving Second Order Homogeneous Diff Eq
Feed for thread: Solving Second Order Homogeneous Diff Eq
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 31 Jan 2013 20:38:08 +0000
Solving Second Order Homogeneous Diff Eq
http://www.mathworks.com/matlabcentral/newsreader/view_thread/326283#896783
Cody
Hello everyone, I'm trying to solve the standard 2nd order differential equation with constant coefficients listed below under the specified boundary conditions:<br>
<br>
dP(x)^2/dx^2 = C * P(x) where C=(2*E*m)/h^2<br>
<br>
under the boundary conditions P(L/2)=0 and P(L/2)=0 for some constant L>0.<br>
<br>
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.<br>
<br>
Matlab correctly calculates the general solution 'P(x)':<br>
<br>
syms C E m h P(x) real<br>
C=(E*2*m)/h^2;<br>
assume(C>0 & E>0 & m>0 & h>0)<br>
P(x)=dsolve( diff(P,2)==C*P )<br>
<br>
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.<br>
<br>
syms C E m h L P(x) real<br>
C=(E*2*m)/h^2;<br>
assume(C>0 & E>0 & m>0 & h>0 & L>0)<br>
P(x)=dsolve( diff(P,2)==C*P, P(L/2)==0, P(L/2)==0 )<br>
<br>
Thank you,<br>
MntGoat

Thu, 31 Jan 2013 23:05:10 +0000
Re: Solving Second Order Homogeneous Diff Eq
http://www.mathworks.com/matlabcentral/newsreader/view_thread/326283#896794
Jonathan Nebauer
"Cody" wrote in message <keekng$cpo$1@newscl01ah.mathworks.com>...<br>
> Hello everyone, I'm trying to solve the standard 2nd order differential equation with constant coefficients listed below under the specified boundary conditions:<br>
> <br>
> dP(x)^2/dx^2 = C * P(x) where C=(2*E*m)/h^2<br>
> <br>
> under the boundary conditions P(L/2)=0 and P(L/2)=0 for some constant L>0.<br>
> <br>
> 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.<br>
> <br>
> Matlab correctly calculates the general solution 'P(x)':<br>
> <br>
> syms C E m h P(x) real<br>
> C=(E*2*m)/h^2;<br>
> assume(C>0 & E>0 & m>0 & h>0)<br>
> P(x)=dsolve( diff(P,2)==C*P )<br>
> <br>
> 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.<br>
> <br>
> syms C E m h L P(x) real<br>
> C=(E*2*m)/h^2;<br>
> assume(C>0 & E>0 & m>0 & h>0 & L>0)<br>
> P(x)=dsolve( diff(P,2)==C*P, P(L/2)==0, P(L/2)==0 )<br>
> <br>
> Thank you,<br>
> MntGoat<br>
<br>
Your equation is secondorder nonlinear, and represents diffusion in most systems. As the continuous eigenspace of this equation is known to be stable, without an inital condition that is nonzero, or a differential set of BC's, I'm not sure that you could expect anything other than 0. Think the timemarching 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.<br>
<br>
Putting a perturbation into the system shows this:<br>
<br>
>> N(x)=dsolve( diff(P,2)==C*P, P(L/2)==0.001, P(L/2)==0.000 )<br>
<br>
N(x) =<br>
<br>
(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)))<br>
<br>
Alternativly, solving your unclamped case for zero at the ends is not possible, and with a perturbation, the result is still zero. <br>
<br>
>> solve(log(C1/C2)/C^(1/2)==log(C2/C1)/C^(1/2)+eps)<br>
<br>
ans =<br>
<br>
20282409603651670423947251286016*(log(C1/C2)  log(C2/C1))^2<br>
<br>
When the BC's go to 0, matlab is solving a quoteit of 1/Inf, producing zero. <br>
<br>
Cheers

Fri, 01 Feb 2013 07:22:04 +0000
Re: Solving Second Order Homogeneous Diff Eq
http://www.mathworks.com/matlabcentral/newsreader/view_thread/326283#896809
Torsten
"Cody" wrote in message <keekng$cpo$1@newscl01ah.mathworks.com>...<br>
> Hello everyone, I'm trying to solve the standard 2nd order differential equation with constant coefficients listed below under the specified boundary conditions:<br>
> <br>
> dP(x)^2/dx^2 = C * P(x) where C=(2*E*m)/h^2<br>
> <br>
> under the boundary conditions P(L/2)=0 and P(L/2)=0 for some constant L>0.<br>
> <br>
> 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.<br>
> <br>
> Matlab correctly calculates the general solution 'P(x)':<br>
> <br>
> syms C E m h P(x) real<br>
> C=(E*2*m)/h^2;<br>
> assume(C>0 & E>0 & m>0 & h>0)<br>
> P(x)=dsolve( diff(P,2)==C*P )<br>
> <br>
> 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.<br>
> <br>
> syms C E m h L P(x) real<br>
> C=(E*2*m)/h^2;<br>
> assume(C>0 & E>0 & m>0 & h>0 & L>0)<br>
> P(x)=dsolve( diff(P,2)==C*P, P(L/2)==0, P(L/2)==0 )<br>
> <br>
> Thank you,<br>
> MntGoat<br>
<br>
P(x)=0 actually _is_ the solution of your ODE under the prescribed boundary conditions.<br>
Insert it in your differential equations and you will see that it satisfies both the differential equation and the boundary conditions.<br>
<br>
Best wishes<br>
Torsten.