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

How to solve a differential equation which consists of variables depending upon another differential equation?

share|improve this question
At least give an example problem which shows you really have a problem at hand and you tried something already ... – PlatoManiac Sep 25 '12 at 16:09
@Julia - Begging doesn't help. There are enough competent people here willing to help you, but something has to come from you. Provide an example of what you want to do and what you already tried. – stevenvh Sep 25 '12 at 16:24
@Julia, welcome to this site! I'd like to suggest you that when you post a question, be prepared to stay online at least for an hour or so, answering comments, commenting on answers and editing your question. That way you'll receive quicker and better answers – Dr. belisarius Sep 25 '12 at 16:41

NDSolve doesn't yield a symbolic solution so you can't directly derive variable values from it. If you have an idea of the solution you could try to fit the output of NDSolve to that model.

If your question is "Can I use the numerical solution from a NDSolve in an DSolve?" the answer is "Yes, sort of".

Let's demonstrate this with an example.

A simple harmonic oscillator can be specified with this DE: y''[t] == -y[t]. With some boundary and initial conditions it can be solved both numerically and symbolically:

g[t_] = y[t] /. First@NDSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y[t], {t, 0, 30}]

Mathematica graphics

h[t_] = y[t] /. First@DSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y[t], t]


A simple driven harmonic oscillator is given by: y''[t] == -k^2 y[t] + d[t] where d[t] is the driving force function. Let's have the driven harmonic oscillator be driven by another harmonic oscillator. Let's pick k^2=2.

In a pure symbolic situation (symbolically solved driven oscillator + symbolically solved driver h[t]) this would lead to the following:

solDD[t_] = y[t] /. First@DSolve[{y''[t] == -2 y[t] + h[t], y[0] == 0, y'[0] == 1}, y[t], t]

Cos[Sqrt[2] t]^2 Sin[t] + Sin[t] Sin[Sqrt[2] t]^2

In a pure numerical situation (numerically solved driven oscillator + numerically solved driver g[t]) we get:

solNN[t_] = 
  y[t] /. First@NDSolve[{y''[t] == -2 y[t] + g[t], y[0] == 0, y'[0] == 1}, y[t], {t, 1, 30}]

Mathematica graphics

These two are easily plotted and appear identical:

 Plot[{solDD[t], solNN[t]}, {t, 0, 30}]

Mathematica graphics

A mixed situation (symbolically solved driven oscillator + numerically solved driver g[t]), which seems to be the target of your question yields:

solDN[t_] = y[t] /. First@DSolve[{y''[t] == -2 y[t] + g[t], y[0] == 0, y'[0] == 1}, y[t], t]

Mathematica graphics

This result can be readily evaluated or plotted, though the latter will be fairly slow because a numerical integral needs to be calculated for every single point in the plot.

The following plot took an estimated 15 minutes, but is the same as the two above.

Mathematica graphics

share|improve this answer
Thanks ..I will keep in mind to frame the question properly – student_curious Sep 26 '12 at 5:00

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.