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 am trying to use Mathematica to solve a relatively simple ODE involving parameter(s). I would like to use a set of conditions to solve for the particular solution of the ODE. I understand how to make Mathematica find values for the constants that arise during the process of solving the ODE, but what about solving for constants/coefficients already present in the original ODE? Here is a simple example involving Newton's Law of Cooling... enter image description here

Here is the code I tried:

      T'[t] == -k*(T[t] - Ta),
      T[0] == 70,
      T[1/2] == 110,
      T[1] == 145
     {T[t], t, k},

I feel like I need a two step process... first solve the ODE with the parameters, and then solve for the parameters afterwards. I'm just not sure where to start.

Thank you in advance!

share|improve this question
Please, provide the code you are working on - otherwise it will be closed as a non-constructive-puhleaze-gimmi-da-code question. – Sektor Jan 15 '14 at 16:51
up vote 1 down vote accepted
sol = T[t] /. First@DSolve[{T'[t] == -k*(T[t] - Ta)}, T[t], t]

Mathematica graphics

sol = sol /. C[1] -> c

Mathematica graphics

eq1 = 70 == sol /. t -> 0;
eq2 = 110 == sol /. t -> 1/2;
eq3 = 145 == sol /. t -> 1;
Solve[{eq1, eq2, eq3}, {k, c, Ta}]

Mathematica graphics

share|improve this answer
Apparently Mathematica solves better if equations containing E^x are expressed in Log form. – Chris Degnen Jan 15 '14 at 23:46
DSolve[D[T[t], t] == -k*(T[t] - Ta), T[t], t]

{{T[t] -> Ta + E^(-k t) C[1]}}

At t = 0, (substituting t = 0 above), T[0] = Ta + C[1],

therefore C[1] = T[0] - Ta.

Substituting C[1] gives:

T[t] -> Ta + (T[0] - Ta) E^(-k t)

Given T[0] = 70

and rearranging the equation to the form: k == -(1/t) Log[(T[t] - Ta)/(T[0] - Ta)]:

Solve[{k == -2 Log[(110 - Ta)/(70 - Ta)],
  k == -Log[(145 - Ta)/(70 - Ta)]}, {k, Ta}]

{{k -> Log[64/49], Ta -> 390}}

Therefore k = 0.267063, Ta = 390 and c = T[0]-Ta = -320

share|improve this answer

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.