Tutorial#

We will solve the following problem using a computer to do some of the more tedious calculations.

Problem

A container has volume \(V\) of liquid which is poured in at a rate proportional to \(e^{-t}\) (where \(t\) is some measurement of time). Initially the container is empty and after \(t=3\) time units the rate at which the liquid is poured is 15.

  1. Show that \(V(t)=\frac{-15e^{3}}{1-e^{3}}(1 - e^{-t})\)

  2. Obtain the limit \(\lim_{t\to \infty}V(t)\)

We first need to create the differential equation described in the text:

\[\frac{V(t)}{dt}=ke^{-t}\]

We create this differential equation in python:

import sympy as sym

t = sym.Symbol("t")
k = sym.Symbol("k")
V = sym.Function("V")

differential_equation = sym.Eq(lhs=sym.diff(V(t), t), rhs=k * sym.exp(-t))
differential_equation
\[\displaystyle \frac{d}{d t} V{\left(t \right)} = k e^{- t}\]

In order to solve the differential equation we can write:

sym.dsolve(differential_equation, V(t))
\[\displaystyle V{\left(t \right)} = C_{1} - k e^{- t}\]

Note that the question gives us an initial condition: “initially the container is empty” which corresponds to \(V(0)=0\).

We can pass this to the call to solve the differential equation:

condition = {V(0): 0}
particular_solution = sym.dsolve(differential_equation, V(t), ics=condition)
sym.simplify(particular_solution)
\[\displaystyle V{\left(t \right)} = k - k e^{- t}\]

We also know that \(V(3)=15\) which corresponds to the following equation:

equation = sym.Eq(particular_solution.rhs.subs({t: 3}), 15)
equation
\[\displaystyle - \frac{k}{e^{3}} + k = 15\]

We can solve this equation to find a value for \(k\):

sym.simplify(sym.solveset(equation, k))
\[\displaystyle \left\{- \frac{15 e^{3}}{1 - e^{3}}\right\}\]

which is the required value.

We can use the complete expression for \(V(t)\) to take the limit:

limit = sym.limit((-15 * sym.exp(3) / (1- sym.exp(3))) *  (1 - sym.exp(-t)), t, sym.oo)
limit
\[\displaystyle - \frac{15 e^{3}}{1 - e^{3}}\]

This is approximately:

float(limit)
15.78593544736884

Important

In this tutorial we have

  • Created a differential equation

  • Obtained the general solution of a differential equation

  • Obtained the particular solution of a differential equation.