Mathematical Modelling FunctionsPart 1
You can do a lot of maths in R. Here we concentrate on the kinds of mathematics that find the most frequent application in scientific work and statistical modelling and we term them as Mathematical Modelling Functions:
 Functions
 Continuous Distributions
 Discrete distributions
 Matrix algebra
 Calculus
 Differential equations
For the kinds of functions you will meet in statistical computing there are only three mathematical rules that you need to learn: these are concerned with powers, exponents and logarithms. In the expression x^(b) the explanatory variable is raised to the power b. In e^(x) the explanatory variable appears as a power – in this special case, of e=271828, of which x is the exponent. The inverse of e^(x) is the logarithm of x, denoted by log(x)
Note – that all our logs are to the base ‘e’ and that, for us, writing log(x) is the same as ln(x). It is also useful to remember a handful of mathematical facts that are useful for working out behaviour at the limits. We would like to know what happens to y when x gets very large (e.g. x→∞) and what happens to y when x goes to 0 (i.e. what the intercept is if there is one).
These are the most important rules:

 Anything to the power zero is 1: x^(0) =1.
 One raised to any power is still 1: 1^(x) =1.
 Infinity plus 1 is infinity: ∞+1=∞.
 One over infinity (the reciprocal of infinity, ∞(−1)) is zero: 1/∞ =0.
 A number bigger than 1 raised to the power infinity is infinity: 1.2^(∞)=∞.A fraction (e.g. 0.99) raised to the power infinity is zero: 0.99^(∞) =0.
 Negative powers are reciprocals: x^(−b) = 1/x^(b).
 Fractional powers are roots: x^(1/3) = 3√x.
 The base of natural logarithms, e, is 2.718 28, so e^(∞)=∞.
 Last, but perhaps most usefully: e^(∞) = 1/∞ = 0
Mathematics Functions
 Arithmetics Function
 Logarithmic Function
 Trigonometric function
 Power Laws
 Polynomial Function
 Gamma function
 Asymptotic function
 Sigmoid(Sshaped) function
 Biexponential Model
 Probability function
Here in this tutorial, I will explain Few functions. Rest will be in next tutorial.
Logarithmic Function: The logarithmic function is given by y=a*[ln(bx)] Here the logarithm is to base e. The exponential function, in which the response y is the antilogarithm of the continuous explanatory variable x, is given by y=a*e^(bx).
Both these functions are smooth functions, and to draw smooth functions in R you need to generate a series of 100 or more regularly spaced x values between min(x) and max(x): x<seq(0,10,0.1)
In R the exponential function expands
1 2 3 4 5 6 
y<exp(x) plot(y~x,type="l",main="Exponential") y<log(x) plot(y~x,type="l",main="Logarithmic") 
the natural log function (ln) is the log. Let a=b=1. To plot the exponential and logarithmic functions with these values together in a row, write
Note: The plot function can be used in an alternative way, specifying the Cartesian coordinates of the line using plot(x,y). These functions are most useful in modelling process of exponential growth and decay.
Trigonometric functions: Here are the cosine (base / hypotenuse), sine (perpendicular / hypotenuse) and tangent (perpendicular/ base) functions of x (measured in radians) over the range 0 to 2. Recall that the full circle is 2 radians, so 1 radian =360/2 =57295 78 degrees.
1 2 3 4 5 6 7 8 
x<seq(0,2*pi,2*pi/100) y1<cos(x) y2<sin(x) y3<tan(x) plot(y1~x,type="l",main="cosine") plot(y2~x,type="l",main="sine") plot(y3~x,type="l",ylim=c(3,3),main="tangent") 
The tangent of x has discontinuities, shooting off to positive infinity at x=/2 and again at x = 3/2. Restricting the range of values plotted on the y axis (here from −3 to +3) therefore gives a better picture of the shape of the tan function. Note that R joins the plus infinity and minus infinity ‘points’ with a straight line at x=/2 and at x=3/2 within the frame of the graph defined by ylim.
Power Laws function: There is an important family of twoparameter mathematical functions of the form y=a[x^(b)] known as power laws. Depending on the value of the power, b, the relationship can take one of five forms. In the trivial case of b = 0 the function is y = a (a horizontal straight line). The four more interesting shapes are as follows:
1 2 3 4 5 6 7 8 9 
x<seq(0,1,0.01) y<x^0.5 plot(x,y,type="l",main="0<b<1") y<x plot(x,y,type="l",main="b=1") y<x^2 plot(x,y,type="l",main="b>1") y<1/x plot(x,y,type="l",main="b<0") 
These functions are useful in a wide range of disciplines. The parameters a and b are easy to estimate from data because the function is linearized by a loglog transformation, log(y)=log(a*x^b)=loga+b*log(x) so that on loglog axes the intercept is log(a) and the slope is b. These are often called allometric relationships because when b =1 the proportion of x that becomes y varies with x.
An important empirical relationship from ecological entomology that has applications in a wide range of statistical analysis is known as Taylor’s power law. It has to do with the relationship between the variance and the mean of a sample.
In elementary statistical models, the variance is assumed to be constant (i.e. the variance does not depend upon the mean). In field data, however, Taylor found that variance increased with the mean according to a power law, such that on loglog axes the data from most systems fell above a line through the origin with slope =1 (the pattern shown by data that are Poisson distributed, where the variance is equal to the mean) and below a line through the origin with a slope of 2.
Taylor’s power law states that, for a particular system:

 log(variance) is a linear function of log(mean);
 the scatter about this straight line is small;
 the slope of the regression of log(variance) against log(mean) is greater than 1 and less than 2;
 the parameter values of the loglog regression are fundamental characteristics of the system.