# Tutorial Video

# Form of Functions

MATLAB functions have the form:

`[output]=function(input)`

Where we use `[ ]`

to enclose the output variables, `function`

is the function name and the function input variables are enclosed with `( )`

Multiple output variables are separated using `,`

likewise for multiple input variables:

`[output1,output2]=function(input1,iInput2)`

For a single output we do not need to use `[ ]`

`output=function(input)`

# sqrt Function

Let us use the example of the inbuilt function sqrt which calculates the square root of the input variable:

`output=function(input)`

First we are going to type the function name with an open bracket and no outputs:

`output=sqrt(`

If MATLAB recognises the function name. a drop down box will show, which highlights the form of the functions inputs (in this case just 1 input):

We can select More Help to get more information:

Okay now let’s input a simple input and close the bracket

`output=sqrt(4)`

This type of function can be used with an Array and works on an element by element basis.

`M=[4,9;16,25]`

`Output=sqrt(M)`

# nthroot Function

Let us use the example of the inbuilt function nth which calculates the nth root of the first input variable with respect to the second input variable:

`Output=function(Input1,Input2)`

First we are going to type the function name with an open bracket and no outputs:

`output=nthroot(`

We can see this time that there are two inputs. Once again if we select More Help we can get more information:

Here we find a description of what the function does and what each of the inputs are:

Setting the second input of three gives the cubed route of the first input value 27:

`Output=`

**n**throot(27,**3**)

Let’s now make both inputs matrices:

`M=[4,27;256,3125]`

`N=[2,3;4,5]`

`Output=nthroot(M,N)`

# exp Function

For a process with 100 % return during a single growth period the rateofgrowth will equal to:

In other words after 1 growth period with 100 % growth you get your starting investment value of 1 plus an additional value of 1 return.

After two growth periods:

If instead you get an investment of 100 % growth over two growth periods, in the first of the two growth periods you will have your initial investment of 1, plus an additional value of 0.5 return. This means you start the second growth period with 1.5 and then after the second growth period you gain an additional value of 0.75 return. Thus you end up with your starting investment of 1 plus an additional value of 1.25.

After three growth periods:

If instead you get an investment of 100 % growth over three growth periods, in the first of the three growth periods you will have your initial investment of 1, plus an addition value of 0.3333 return. In the second growth period you thus start with 1.3333 and get 0.4444 return and this means in the third growth period, you start with 1.7777 and get 0.5925 in return. Thus you end up with your starting investment of 1 plus an additional value of 1.3702 (1.3704 if the calculation is carried out to more significant figures).

And after growth periods:

For continuous growth

As you can see from above the numbers begin to converge at high and they converge to a constant known as . is thus defined as the maximum rate of a continuous process.

`output=function(Input)`

We can look at MATLABs help about the Exponential by typing the following in and selecting More Help:

`output=exp(`

`output=exp(1)`

`output=2.7183`

`M=[1,2;3,4]`

`N=exp(M)`

# log Function

The natural logarithm can be used to calculate the amount of product one has after units of time at continuous growth. We can also calculate the logarithm using the function. In this case we will actually use another function as an input argument and because these two functions cancel each other out we should just return with the input argument:

`Output=function(Input)`

`Output=log(exp(2))`

`Output=log(N)`

This of course is equal to `M`

as the two functions cancel each other out: