# Mathematics for Chemistry/Some Useful Aspects of Calculus
## Limits

Many textbooks go through the proper theory of differentiation and integration by using limits. As chemists it is possible to live without knowing this so we might well not have it as an examinable topic. However here is how we differentiate sin from 1st principles.
${\frac {{\rm {d}}y}{{\rm {d}}x}}=\left({\frac {{\delta }y}{{\delta }x}}\right)_{{\rm {limit}}~~~~\delta x\rightarrow 0}$
$={\frac {\sin(x+\delta x)-\sin x}{\delta x}}$
$={\frac {\sin x\cos \delta x+\sin \delta x\cos x-\sin x}{\delta x}}$
$={\frac {\sin x}{\delta x}}-{\frac {\sin x}{\delta x}}+{\frac {\sin \delta x}{\delta x}}\cos x$
As $\sin \delta x=\delta x$ for small $x$ this expression is $\cos x$.
Similarly for $\cos \theta$
${\frac {{\rm {d}}y}{{\rm {d}}\theta }}={\frac {\cos(\theta +\delta \theta )-\cos \theta }{\delta \theta }}$
$={\frac {\cos \theta \cos \delta \theta -sin\theta \sin \delta \theta -\cos \theta }{\delta \theta }}$
$={\frac {\cos \theta }{\delta \theta }}-{\frac {\sin \theta ~~\delta \theta }{\delta \theta }}-{\frac {\cos \theta }{\delta \theta }}$
This is equal to $-\sin \theta$.

## Numerical differentiation

You may be aware that you can fit a quadratic to 3 points, a cubic to 4 points, a quartic to 5 etc. If you differentiate a function numerically by having two values of the function $\delta x$ apart you get an approximation to ${\frac {{\rm {d}}y}{{\rm {d}}x}}$ by constructing a triangle and the gradient is the tangent. There is a forward triangle and a backward triangle depending on the sign of $\delta x$. These are the forward and backward differentiation approximations.
If however you have a central value with a $\delta$ either side you get the central difference formula which is equivalent to fitting a quadratic, and so is second order in the small value of $\delta x$ giving high accuracy compared with drawing a tangent. It is possible to derive this formula by fitting a quadratic and differentiating it to give:
${\frac {{\rm {d}}y}{{\rm {d}}x}}={\frac {f^{+}+f^{-}-2f^{0}}{\delta ^{2}}}$
This is calculated data for the shielding in ppm of the proton in HCl when the bondlength is stretched or compressed by 0.01 of an Angstrom (not the approved unit pm). The total shielding is the sum of two parts, the paramagnetic and the diamagnetic. Notice we have retained a lot of significant figures in this data, always necessary when doing numerical differentiation.
Exercise - use numerical differentiation to calculated $d\sigma /dr$and $d^{2}\sigma /dr^{2}$using a step of 0.01 and also with 0.02. Use 0.01 to calculate $d\sigma (para)/dr$ and $d\sigma (dia)/dr$

## Numerical integration

Wikipedia has explanations of the Trapezium rule and Simpson's Rule. Later you will use computer programs which have more sophisticated versions of these rules called Gaussian quadratures inside them. You will only need to know about these if you do a numerical project later in the course. Chebyshev quadratures are another version of this procedure which are specially optimised for integrating noisy data coming from an experimental source. The mathematical derivation averages rather than amplifies the noise in a clever way.