Tutorial
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.
Show that \(V(t)=\frac{-15e^{3}}{1-e^{3}}(1 - e^{-t})\)
Obtain the limit \(\lim_{t\to \infty}V(t)\)
We first need to create the differential equation described in the text:
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
In order to solve the differential equation we can write:
sym.dsolve(differential_equation, V(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)
We also know that \(V(3)=15\) which corresponds to the following equation:
equation = sym.Eq(particular_solution.rhs.subs({t: 3}), 15)
equation
We can solve this equation to find a value for \(k\):
sym.simplify(sym.solveset(equation, k))
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
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.