Implement in MATLAB the Newton-Raphson method to find the rootsof the following functions.
(a) f(x) = x 3 + 3x 2 – 5x + 2
(b) f(x) = x2 – exp(0.5x)
Define these functions and their derivatives using the @ symbol.For example, the function of part (a) should be f=@(x)x^3 + 3*x.^2- 5*x + 2, and its derivative should be f_prime=@(x)3*x.^2 + 6*x -5.
For each function, use three initial values for x (choosebetween -10 and 10), so that you can find more than a single root,if possible. Each time you run the algorithm, keep the values of xfor each iteration, and plot them with respect to the iterationnumber.
Plot each function for x between -10 and 10 (e.g.,x=-10:0.1:10;) to confirm visually that the roots that you foundare where they are supposed to be. You may zoom in as you see fitto get a clearer picture about where the roots are.