problem1) Create a MATLAB function called problem3 that finds the root of an equation numerically using the following recursive formula:
x_{n+1}= x_{n}– f(x_{n})/g(x_{n}) , for n =1,2,3,……
where g(x_{n}) = (f(x_{n} +f(x_{n} ))-f(x_{n}_{ } ))/f(x_{n}_{ }) . This iterative procedure should stop when the absolute difference between x_{n} andx_{n+1}is less than a given tolerance epsilon. The function must accept as inputs , a scalar function ‘f’, an initial number ‘x’ and a positive number ‘epsilon’ to terminate the procedure. Hence use this numerical technique to find the root of the equation e^{x }–x^{2} =0
problem2) Let S_{t} be the price of one share of a particular company at time t. If the price S_{t+1} at time t+1 can wither take the value of uS_{t}with probability p_{1} (where u>1), remain the same with probability p_{2} or go down to dS_{t}with probability 1-p_{1}-p_{2 }(where 0t}_{t}=0^{20}for given u, d, p1,p2 and plot S_{t} against t. Hence, by counting the number of paths, find out the probability that S_{6} = S_{0}^{u}2d^{3 }. Do this by using the command rand.
problem3) Suppose you are at a casino playing roulette and that you are betting on black to turn up. You start by betting 1 euro. If you win bet another 1 euro in the next game. If you lose you double your previous bet. You will stop playing when you have either won at least 10 euros or lost more than 100 euros. Create a script file called problem6 to simulate this system. Then play the game 5000 times and record your performance. Use the command rand.
problem4) A Legendre polynomial of degree n is given by the following expression:
P_{n}(x) = (1/2^{n}n!)*(d^{n}/dx^{n})*(x^{2}-1)^{n}
where(d^{n}/dx^{n})f is the nth derivative of function f.
(a) Generate the first four polynomials and use the command subplot to plot the resulting graphs. Use the different colours and symbols for the plots
(b) create a Matlab function called legendrepolynomial which for given inputs n and m find outs the integral
∫P_{n}(x)P_{m}(x) dx
using the trapezoid rule with a suitability chosen number of gridpoints. Comment on the output obtained.
Note: Limits of integral from -1 to 1
problem5) A Eulerian number P_{n,k}is the number of permutations p_{1}p_{2}….p_{n} of the numbers 1,2,….,n in which there are k places with p_{j}j+1. For ex P_{3,1}= 4 because there are four permutations having one ascent which hare 132,213,231,312. This number can be generated using the following recurrence relation
P_{n,0} = 1 for all n>=0
P_{n,k}= 0 for all k>=n
P_{n,k}= (k+1)P_{n-1},k+ (n-k)P_{n-1},_{k-1} for all k=1,2,…..,n-1
(a) create a function called euleriannumber which generates a Eulerian number for a given n and k
(b) create a script file called euleriannidentity which calls the function euleriannumber and then verifies the identity
∑in = ∑P_{n,k}(m+k+1 , n+1)
for given m,n and k, where (m+k+1 , n+1) = (m+k+1)!/((n+1)!*(m+k-n)!)
note: limits of i^{n}= from i=1 to m
limits of P_{n,k}(m+k+1 , n+1) = from k=0 to n-1