# Using Differential Equations in Modelling
## What should you know before you start

* You will of done similar work to this in core 4, however questions will be at a higher level. The core 4 content is covered here but having done core 4 before hand will be handy
* You need to know all the calculus from core 2, core 3, and core 4
* You will of need to of covered work on newtons laws and general motion in mechanics 1

## Introduction to Differential Equations

How does the quantity of drug in the body vary with time? How long does it take a cup of coffee take to cool? After how many days will the moon take the same shape again? These question all have on thing in common. They have a quantity that is continuously changing. We see change in most things in life. Some changes are permanent; like the temperature of coffee. Some have repeating patterns, like the cycle of the moon.
You have already studied a lot of mathematics to describe these changes, but never really put that into real life applications. You will know from previously studies calculus that the rate of change of a quantity is called a derivative. If an equation contains a derivative, it is a differential equation.
The simplest form of a differential equation is to show the rate of change of one variable with respect to another like:
* 1.${\frac {dy}{dx}}=x+y$,
* 2.${\frac {dP}{dt}}=0.02P$
These are 2 very basic examples of differential equations. You will learn how to solve them in later sections.
A solution to a differential equation gives a relationship between the variables, which doesn't involve a derivative. The solutions to the differential equations above are given by:
* 1.$y=-x-1+Ce^{x}$
* 2.$P=Ae^{0.02t}$
(where C and A are constants of integration)
Differential equations begin to get more complicated where higher derivatives are involved (${\frac {d^{2}y}{dx^{2}}}$), or if they included more variables.

## Modelling

In order to solve any problem successfully, you need to develop a mathematical model that describes the situation adequately. In this module you will learn how to solve problems which can be solved using differential equations.
With some problems you can go straight into the mathematics. This is usually the case where you have already have some models that you can apply to the situation. These usually include; but are not limited to newtons laws of motion, and many kinematics problems (stuff in mechanics 1, basically.)Because of this your solution to a problem will depend on assumptions and simplifications you made; like ignoring air resistance, or assuming constant mass, etc. This can sometimes give significant errors in your solution. Collecting data can help see if your model is off or not.
Some problems will need their own model developed, however. This means you will need to do some experiments to find a correlation between the results you get. This will help with understanding the problem better, and help you formulate a mathematical model.

### Example

You have been asked to find out how much of an antidepressant is left in the body after a given time of taking the pill. How would you do this? Well the process of removing a drug from the body varies with the drug. The kidney plays the most important rule, doing something called renal clearance.The rate of this can be measured by taking urine samples.
Lets make some assumptions about the problem:
* Once the pill has been taking, it is instantly absorbed into the body
* The drug is removed from the bloodstream via renal clearance.
* The rate of renal clearance is proportional to the quantity of the drug in the body
We can now formulate a model. Let 't' be time in hours, and 'q' be the amount of drug in the body (in mg). this means that:
${\frac {dq}{dt}}\propto q$
we replace the proportional sign:
${\frac {dq}{dt}}=-kq$ where k is a positive constant of proportionality, and the negitive sign is there because the amount of drug is decreasing.
We will show later that the solution to the differential equation is:
$q=Ae^{-kt}$, Where A is a constant of integration. Although we have not shown this solution is true, we can check that is is a solution by differentiating it.
${\frac {dq}{dt}}=A(-ke^{-kt})=-kAe^{-kt}$
$q=Ae^{-kt}$
${\frac {dq}{dt}}=-kq$, so therefore we have shown that it is a solution
Now we need to find values for A and k,for this we will need some experimental results:
* In the morning a man takes 40 mg of the antidepressant
* Every hour, approximately 5% of it is gone
We now let t=0, and q=40
$40=Ae^{0}=A$
in this case our constant of integration, A, is 40. So therefore:
$q=40e^{-kt}$
Now lets find k. We know that every hour the amount of drug decreases by 5% every hour, so when t=1, q=(0.75)*40=38
$38=40e^{-k}$
Dividing each side by 40, and taking logs of each side gives that:
$k=-ln({\frac {38}{40}})=0.0513$
This gives that:
$q=40e^{-0.0513k}$

## key points

* A differential equation is an equation involving a derivative
* The order of a differential equation is the order of the highest derivative
* Differential equations are used to model situations which involve rates of change
* The solution to a differential equation gives a relationship between the variables themselves, not the derivatives
* The general solution of a first order differential equation satisfies the differential equations and has a constant of integration in its solution
* The particular solution of a differential equation is one in which additional information has been used to calculate the constant of integration
* The general solution may be represented by a family of curves and the particular solution is one of that family
* To verify that a function is a particular solution you must check that it satisfy's the differential equation and initial conditions