# Solving an ODE with parameters and conditions

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... Here is the code I tried:

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


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.

• 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

sol = T[t] /. First@DSolve[{T'[t] == -k*(T[t] - Ta)}, T[t], t] sol = sol /. C -> c eq1 = 70 == sol /. t -> 0;
eq2 = 110 == sol /. t -> 1/2;
eq3 = 145 == sol /. t -> 1;
Solve[{eq1, eq2, eq3}, {k, c, Ta}] • 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}}

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

therefore C = T - Ta.

Substituting C gives:

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


Given T = 70

and rearranging the equation to the form: k == -(1/t) Log[(T[t] - Ta)/(T - 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-Ta = -320