1
$\begingroup$

Continuing my previous question from today - I should code a program that finds approximate value of the aforementioned differential equation. The full text of the assignment is:

Water purifier with volume $V = 10000 m^3$ has been contaminated by lead, which is disolved in it with volume of $10 g/m^3$. Fresh water is coming to the purifier at the rate of $2 m^3/s$ and it flows out at the same rate. How long will it take for the volume of lead in the water to drop below $10 \mu g/m^3$?

It can be equated as this differential equation: m' = -\frac{m}{V}v

Where $V = 10000 m^3$ - the Volume of the purifier, $v = 2 m^3/s$ - rate of water inflow/outflow and $m$ is the amount of lead present at the given time. I have no problem solving it explicitly.

After separating the variables I get:

$m(t) = Ke^{\frac{-1}{500}t}$

Where $K = 10000$

My problem is that I don't know what to use for the Euler's approximation. The equation stated here does not contain $t$ for the time elapsed - that's something that shows up only after integrating it and separating the variables and since $t$ is what I'm looking for I'm kinda stuck. Any help would be greatly appreciated.

1 Answers 1

1

Your DE is autonomous; that is, the independent variable doesn't show up. We can simplify your DE to

$m^\prime=Cm$

where $C$ is a constant you obtain from your given $v$ and $V$. Thus, your Euler iteration runs a bit like (where $t$ is the independent variable):

$\begin{align*}t_{k+1}&=t_k+h\\m_{k+1}&=m_k+h(Cm_k)\end{align*}$

where $t_0=0$, $m_0=10000$, and $h$ is a predetermined stepsize.

  • 0
    Thanks for the answer - I have luckily figured that on my own last night, but the problem I have is somewhere else. I am running the algorithm like this - http://pastebin.com/B3GxFMPu And is giving me really weird results.2011-10-31