Reputation: 11
I'm trying to solve one differential equation and use 2 computed values (at specific points) as boundary conditions for a new differential equation. An example:
sys1 = {p''[x] + p'[x] + p[x] == 0,p'[0] == 0,p'[1] ==0};
sol1 = NDsolve[sys1,p[x],{x,0,1}];
Now I want do define sys2
with boundary conditions taken from the solution sol1
. I mean it should look like this:
sys2 = {3y''[x] + 7y'[x] - 6y[x] == 0,y[0.3] == p[0.3],y'[1] == p'[1]}
And then we can solve sys2
using NDSolve
. I didn't find any clues to how to extract these values from the solution.
Your help would be greatly appreciated.
Upvotes: 0
Views: 1478
Reputation: 1594
You can do:
sol1 = NDSolve[sys1,p,{x,0,1}];
pfun=First[p/.sol1];
pfun[0.3]
pfun'[1]
There is an example in the documentation of InterpolatingFunction for achieving this (http://reference.wolfram.com/language/ref/InterpolatingFunction.html).
Upvotes: 1