Let us look at some applications. Ordinary differential equations applications in real life are used to calculate the movement or flow of electricity, motion of an object to and fro like a pendulum, to explain thermodynamics concepts. Also, in medical terms, they are used to check the growth of diseases in graphical representation. We will discuss two real-life application of ODE here.

1. Newton’s law of Cooling

2. Population Growth of Bacteria

In the late seventeenth century, Sir Issac Newton studied and researched about the cooling of bodies. Experiments showed that the cooling rate approximately proportional to the difference of temperatures between the heated body and the environment. It can be written in the form of differential equation, .

Where is the heat, is the surface area of the body through which the heat is transferred, is the temperature of the body, is the temperature of the surrounding environment, is the heat transfer coefficient depending on the geometry of the body, state of the surface, heat transfer mode, and other factors.

As we know, where is the heat capacity of the body, we can write it as,

.

__Statement:__ According to Newton’s law of cooling, the rate of loss of heat from a body is directly proportional to the difference in the temperature of the body and its surroundings.

,

where is the initial temperature of the body, is the temperature of the body at time and is temperature of the surrounding, is the positive constant that depends on the area and nature of the surface of the body under consideration.

__Problem:__ A pizza is removed from the oven after baking thoroughly, and the temperature of the oven is °F. The temperature of the kitchen is °F, and after minutes the temperature of the pizza is °F. Jack would like to wait until the temperature of the pizza reaches °F before cutting and serving it. How much longer will Jack have to wait from the time he removed the pizza from the oven?

__Solution:__

The ambient temperature (room temperature) is °F, so .

The temperature of the pizza when it comes out of the oven is °F , which is the initial temperature (i.e., initial value), so .

with .

Solving a separable differential equations.

__Step 1:__ Setting the right-hand side equal to zero gives as a constant solution. Since the pizza starts at °F, this is not the solution we are seeking.

__Step 2:__ Rewrite the differential equation by multiplying both sides by and dividing both sides by :

__Step 3:__ Integrating both sides:

__Step 4:__ Solve for by first exponentially both sides:

, where

, where or .

Therefore, the solution to the IVP is

To determine the value of , we need to use the fact that after minutes the temperature of the pizza is °F. Therefore . Substituting this information into the IVP, we have

So now we have . When is the temperature °F? Solving for , we find

.

Therefore, Jack need to wait for minutes (after the pizza is removed from the oven).

__Code:__

` ````
```// Newton's Law of Cooling Problem
// Waiting for a PIZZA to Cool
// T' = k(T-75) as ambient temperature for this case is 75 F
// dT/dt = k(T-75)
%use s2
val f: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(T: Double, k: Double): Double {
return k*(T - 75) // k(T-75)
}
}
println("Differential Equation for Newton's law of Cooling for this case : dT/dt = k(T-75)")
// Solving the Differential
// dT/(T-75) = k*dt
// integral(dT/(T-75)) = integral(k*dt)
// ln|T - 75| = kt + C
// exp(ln|T - 75|) = exp(kt + C)
// T - 75 = C * exp(kt)
// T as a function of t: T(t) = 75 + C*exp(kt)
println("Final equation T as a function of t: T(t) = 75 + C*exp(kt) ")
// constant C = [T(t) - 75]/exp(kt)
val T_at_0 = 350.0 // intial temperature of PIZZA T(0)=350
val C: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(T_at_0: Double, t: Double): Double {
return (T_at_0 - 75)/Math.exp(t)
}
}
val c = C.evaluate(T_at_0,0.0) // At t=0, T(0)=350
println("The equation based on constant value C becomes: T(t) = 75 + %f*exp(kt)".format(c))
// k = ( ln|[T(t) - 75]/C| )/t
val ln: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(T_at_t: Double, c: Double): Double {
return (T_at_t - 75)/c
}
}
val T_at_5 = 340.0 // T(5) = 340
val k1 = ln.evaluate(T_at_5, c)
val k2: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(k1: Double, t: Double): Double {
return Math.log(k1)/t
}
}
val k = k2.evaluate(k1,5.0) // At t=5, T(5)=340
println("The equation based on constant value k becomes: T(t) = 75 + %f*exp(%f*t)".format(c,k))
// To find t when T(t) = 300
val T_at_t = 300.0
// t = ( ln|[T(t) - 75]/C| )/k
val t1 = ln.evaluate(T_at_t, c)
val t2: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(t1: Double, k: Double): Double {
return Math.log(t1)/k
}
}
val t = t2.evaluate(t1,k)
println("%nThe approximate time required to wait before consuming the PIZZA : %f".format(t))
// plot Cooling Curve
val p = JGnuplot(false)
p.setTitle("COOLING CURVE for PIZZA")
p.setTitleFontSize(23)
p.addPlot("75 + %f*exp(%f * x)".format(c,k))
p.getYAxis().setBoundaries(290.0, 375.0)
p.getXAxis().setBoundaries(0.0, 35.0)
p.getYAxis().setLabel("Temperature (F)")
p.getXAxis().setLabel("Time (min.)")
p.plot()

__Output:__

Differential equations can be used to represent the size of a population as it varies over time. This model includes other factors that affect the growth of the population. Here, we understand the differential equation and it’s application to the study of population dynamics in the context of biology.

To model population growth using a differential equation, we will need to introduce some variables and relevant terms. The variable will represent time. The units of time can be hours, days, weeks, months, or even years. The variable will represent population. Since the population varies over time, it is understood to be a function of time. Therefore we use the notation for the population as a function of time. If is a differentiable function, then the first derivative represents the instantaneous rate of change of the population as a function of time.

Let represent population at any time

is the rate of change of Population.

Therefore,

Modifying the equation as,

Therefore,

__Problem:__ A bacteria culture starting with bacteria grows at a rate proportional to its size. After hours there will be bacteria. Express the population function after hours as a function of ? What will be the population after hours? When will the population reach ?

__Solution:__

At ,

Therefore,

At ,

Therefore,

Therefore, the population function after hours as a function of is

At , substituting the value in final equation we get, as .

The population after hours will be .

For , substituting the value we get

The population will reach in hours.

**Code:**

` ````
```// Population Growth Problem
// Population Growth of Bacteria
// dP/dt = kP
%use s2
val f: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(P: Double, k: Double): Double {
return k*P
}
}
println("Differential Equation for Population Growth : dP/dt = kP ")
// Solving the Differential
// dP/P = k*dt
// integral(dP/P = integral(k*dt)
// ln|P| = kt + C
// exp(ln|P|) = exp(kt + C)
// P = C * exp(kt)
// P as a function of t: P(t) = C*exp(kt)
// Let C = P0....initial Population
println("Final equation P as a function of t: P(t) = P0*exp(kt) ")
// constant P0 = P(t)/exp(kt)
val P_at_0 = 200.0 // Bacteria culture starting with or intial population of Bacteria P(0)=200
val P0: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(P_at_0: Double, t: Double): Double {
return P_at_0/Math.exp(t)
}
}
val p = P0.evaluate(P_at_0,0.0) // At t=0, P(0)=200
println("The equation based on constant value P0 becomes: P(t) = %f*exp(kt)".format(p))
// k = ( ln| P(t)/P0 | )/t
val ln: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(P_at_t: Double, p0: Double): Double {
return (P_at_t)/p0
}
}
val P_at_3 = 900.0 // After 3 hrs P(3) = 900
val k1 = ln.evaluate(P_at_3, p)
val k2: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(k1: Double, t: Double): Double {
return Math.log(k1)/t
}
}
val k = k2.evaluate(k1,3.0) // At t=3, P(3)=900
println("The equation based on constant value k becomes: P(t) = %f*exp(%f*t)".format(p,k))
// To find P(t) when t = 6
val t = 6.0
// P(t) = P0*exp(kt)
val expo: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(k: Double, t: Double): Double {
return Math.exp(k*t)
}
}
val p1 = expo.evaluate(k,t)
val Population: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(P0: Double, expo: Double): Double {
return P0*expo
}
}
val P_at_6 = Population.evaluate(p,p1)
println("%nThe Population after %f hours will be %f".format(t,P_at_6))
// To find t when P(t) = 5000
val P_at_t = 5000.0
// t = ( ln|P(t)/P0| )/k
val t1 = ln.evaluate(P_at_t, p)
val t2: BivariateRealFunction = object : AbstractBivariateRealFunction() {
override fun evaluate(t1: Double, k: Double): Double {
return Math.log(t1)/k
}
}
val t_new = t2.evaluate(t1,k)
println("%nThe Population will reach %f in %f hours".format(P_at_t,t_new))
// plot Population Curve
val pop= JGnuplot(false)
pop.setTitle("POPULATION CURVE for Bacteria")
pop.setTitleFontSize(23)
pop.addPlot("%f*exp(%f * x)".format(p,k))
pop.getYAxis().setBoundaries(100.0, 5000.0)
pop.getXAxis().setBoundaries(0.0, 8.0)
pop.getYAxis().setLabel("Population")
pop.getXAxis().setLabel("Time (hrs.)")
pop.plot()

**Solution:**