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

## Newton's Law of Cooling

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,  $$\frac{\text{d}Q}{\text{d}t}=\alpha A (T_{s}-T)$$.

Where  $$Q$$ is the heat,  $$A$$ is the surface area of the body through which the heat is transferred, $$T$$ is the temperature of the body, $$T_{s}$$ is the temperature of the surrounding environment,  $$\alpha$$ 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, $$Q=CT$$ where $$C$$ is the heat capacity of the body, we can write it as,

$$\frac{\text{d}T}{\text{d}t}=\frac{\alpha A }{C}(T_{s}-T)=k(T_{s}-T)$$.

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.

$$T(t)=T_{s}+(T_{0}-T_{s})e^{-kt}$$,

where $$T_{0}$$ is the initial temperature of the body, $$T(t)$$ is the temperature of the body at time $$t$$ and $$T_{s}$$ is temperature of the surrounding, $$k$$ 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  $$350$$°F.  The temperature of the kitchen is  $$75$$°F, and after  $$5$$  minutes the temperature of the pizza is  $$340$$°F. Jack would like to wait until the temperature of the pizza reaches $$300$$°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 $$75$$°F, so $$T_{s}=75$$.

The temperature of the pizza when it comes out of the oven is  $$350$$°F , which is the initial temperature (i.e., initial value), so  $$T_{0}=350$$.

$$\frac{\text{d}T}{\text{d}t}=k(T-35)$$

with $$T(0)=350$$.

Solving a separable differential equations.

Step 1: Setting the right-hand side equal to zero gives  $$T=75$$  as a constant solution. Since the pizza starts at  $$350$$°F,  this is not the solution we are seeking.

Step 2: Rewrite the differential equation by multiplying both sides by $$dt$$ and dividing both sides by $$T-75$$:

$$\frac{\text{d}T}{\text T-75}=k \space dt$$

Step 3: Integrating both sides:

$$\int \frac{\text{d}T}{\text T-75}=\int k \space dt$$

$$ln|T-75|=kt+C$$

Step 4: Solve for $$T$$ by first exponentially both sides:

$$e^{ln|T-75|}=e^{kt+C}$$

$$|T-75|= C_{1} \space e^{kt}$$,         where $$C_{1} = e^{C}$$

$$T-75= \pm C_{1} e^{kt}$$

$$T-75=Ce^{kt}$$,        where $$C = \pm C_{1}$$ or $$C = 0$$.

$$T(t)=75+Ce^{kt}$$

Therefore, the solution to the IVP is

$$T(t)=75+275 e^{kt}$$

To determine the value of  $$k$$ , we need to use the fact that after  $$5$$  minutes the temperature of the pizza is  $$340$$°F. Therefore  $$T(5)=340$$.  Substituting this information into the IVP, we have

$$T(t)=75+275 e^{kt}$$

$$T(5)=340 = 75 + 275 e^{5k}$$

$$265=275 e^{5k}$$

$$e^{5k} = \frac {53}{55}$$

$$ln$$ $$e^{5k}= ln(\frac {53} {55})$$

$$5k = ln (\frac {53}{55})$$

$$k= \frac {1}{5} ln(\frac {53}{55}) \approx -0.007408$$

So now we have $$T(t) = 75 + 275 e^{-0.007048 t}$$. When is the temperature $$300$$ °F? Solving for $$t$$, we find

$$T(t)=75 + 275 e^{-0.007048 t}$$

$$300 = 75 + 275 e^{-0.007048 t}$$

$$225 = 275 e^{-0.007048 t}$$

$$e^{-0.007048 t}= \frac {9} {11}$$

$$ln e^{-0.007048 t} = ln (\frac {9} {11})$$

$$\text -0.007048 t = ln(\frac {9} {11})$$

$$t = – \frac {1}{0.007048} ln {9}{11} \approx 28.5$$.

Therefore, Jack need to wait for $$28.5$$ 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.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: ## Population Growth of Bacteria

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  $$t$$ will represent time. The units of time can be hours, days, weeks, months, or even years. The variable  $$P$$  will represent population. Since the population varies over time, it is understood to be a function of time. Therefore we use the notation  $$P(t)$$  for the population as a function of time. If  $$P(t)$$  is a differentiable function, then the first derivative $$\frac{\text{d}P}{\text{d}t}$$  represents the instantaneous rate of change of the population as a function of time.

Let $$P$$ represent population at any time $$t$$

$$\frac{\text{d}P}{\text{d}t}$$ is the rate of change of Population.

$$\frac{\text{d}P}{\text{d}t} \propto P$$

$$\frac{\text{d}P}{\text{d}t} = kP$$

$$dP= kP$$ $$dt$$

Therefore, $$\frac{{d}P}{P} = k d{t}$$

Modifying the equation as, $$\ln P = kt + c$$

$$P = e^{kt + c}$$

$$P = e^{kt} + e^{c}$$

$$P = c e^{kt}$$

Therefore, $$P(t) = P_{0} e^{kt}$$

Problem: A bacteria culture starting with $$200$$ bacteria grows at a rate proportional to its size. After $$3$$ hours there will be $$900$$ bacteria. Express the population function after $$t$$ hours as a function of $$t$$? What will be the population after $$6$$ hours? When will the population reach $$5000$$?

Solution:

$$P(t) = P_{0} e^{kt}$$

At $$t=0$$, $$P(0) = P_{0} e^{k*0}$$

$$200 = P_{0} (1)$$

Therefore, $$P_{0} = 200$$

$$k = \frac { \ln \frac {P(t)} {P_{0}}} {t}$$

At $$t=3$$, $$P(t)=900$$

$$k = \frac { \ln \frac {900} {200}} {3}$$

Therefore, $$k= 0.501359$$

Therefore, the population function after $$t$$ hours as a function of $$t$$ is $$P(t)= 200 e^{0.501359*t}$$

At $$t=6$$, substituting the value in final equation we get, $$P(t)$$ as $$4050$$.

The population after $$6$$ hours will be $$4050$$.

For $$P(t)=5000$$, substituting the value we get $$t = 6.42$$

The population will reach $$5000$$ in $$6.42$$ 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) 