Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a system of ODEs with 10 eqns. I can solve the first 5 independently. How can I use those results to solve for the remaining 5?

An easy example would be

$\dot{x}=f(x), \quad \dot{y}=g(x,y)$

I can solve for x and now I want to use the interpolating function to solve for y.


share|improve this question
Closely related question: Using the result of Solve in subsequent calculations – Jens Jul 22 '12 at 20:52
up vote 9 down vote accepted

This is very straightforward - use the solution "interpolating function" as a regular function. Solve a first-order ordinary differential equation, which gives you sort of decaying oscillations:

sol1 = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}];

Use it inside another equation. The important thing to remember is that the domain of the previous equations should be equal or contain inside the domain of next equations.

sol2 = NDSolve[{z'[x]== -z[x]^2+First[Evaluate[y[x] /. sol1]], z[0] == 0}, z, {x, 0, 30}]

Plot both. It "makes sense". Indeed 1st solution here plays the role of sort of a driving force, so on the graphs below you see synchronization between oscillations.

Plot[{Evaluate[y[x] /. sol1], Evaluate[z[x] /. sol2]}, {x, 0, 30}, PlotRange -> All]

enter image description here

Now you can do more advanced things, like using also derivative of the "Interpolating Function" inside of new equations:

sol3 = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}];
sol4 = NDSolve[{z'[x]== -z[x]+First[y[x]/5 + y'[x] /. sol3], z[0] == 0}, z, {x, 0, 30}];
Plot[{Evaluate[y[x] /. sol3], Evaluate[z[x] /. sol4]}, {x, 0, 30},
      PlotRange -> All, Filling -> 0]

enter image description here

share|improve this answer
Well, that is what I tried and it didn't work. But after a close look upon my eqns, I noticed that I accidentally deleted some of my eqns. But thanks anyway. At least I knew it had to be something different. – Lisa Jul 23 '12 at 7:29
@Lisa I am glad you figured it out. Welcome to the community! You may want to take a look at this:… – Vitaliy Kaurov Jul 23 '12 at 7:45

From the question it seems that you're working with NDSolve (not DSolve) because you're asking about InterpolatingFunction.

As long as you solve all equations for the same domain of the independent variable (let's call it t), it should be possible to use the the results as in this example:

Clear[x, y, t]

xFn = 
 First[x /. NDSolve[{x'[t] == x[t], x[0] == 1}, x, {t, 0, 1}]]

NDSolve[{y'[t] == 2 xFn[t], y[0] == 1}, y, {t, 0, 1}]

Plot[Evaluate[First[y /. %]][t], {t, 0, 1}]

ndsolve result

The main thing is to convert the rule specifying the first solution into a function named xFn.

share|improve this answer

An example:

s = DSolve[Dt[x[t], t] == x[t]^2, x[t], t]
DSolve[Dt[y[t], t] == (x[t] y[t])^2 /. s[[1]], y[t], t]
{{y[t] -> (-t - C[1])/(-1 + t C[2] + C[1] C[2])}}
share|improve this answer
Sorry, I didn't pay attention to the interpolating function part of your question. This answer is for symbolically solved diff eqs. I'll leave it here anyway so it may help others- – Dr. belisarius Jul 22 '12 at 20:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.