Message Boards Message Boards

0
|
3387 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

NDSolve a second order ODE with second derivative as boundary?

Posted 5 years ago

Hello, Can somebody help me understand why the following code for solving a second order ODE works fine:

s = NDSolve[{x y[x] + x^2 y''[x] == 0, y[1] == 0, y'[10] == 1}, 
  y, {x, 1, 10}]

while this one that replaces the boundary condition y'[10] with y''[10]

s = NDSolve[{x y[x] + x^2 y''[x] == 0, y[1] == 0, y''[10] == 1}, y, {x, 1, 10}]

does not?

File attached.

Thank you in advance

Attachments:
POSTED BY: Lorenzo Garlappi
2 Replies

Got it. Thank you. I was able to solve it in MATLAB via finite differences with a second order boundary condition and did not know Mathematica NDSolve does not take it as a boundary condition.

POSTED BY: Lorenzo Garlappi

Lorenzo,

You can never set the highest derivative as a boundary condition in an ODE. The highest derivative is always set by your equations. You can, however, solve for the correct boundary condition to get your answer:

The boundary condition that will give you y''[10]==1 can be found:

bc = Solve[x y[x] + x^2 y''[x] == 0 /. x -> 10 /. y''[10] -> 1, 
    y[10]][[1, 1]] /. Rule -> Equal

To get

y[10]==-10

Now you can solve your ODE:

s = NDSolve[{x y[x] + x^2 y''[x] == 0, y[1] == 0, bc}, y, {x, 1, 10}]

Regards,

Neil

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract