Write a Matlab script to calculate the second order derivati
Write a Matlab script to calculate the second order derivative for the following: function: f(x) = 2^x/x for 1 lessthanorequalto x lessthanorequalto 26 a) Find f\'(x) using second order scheme with h = (b-a)/12.5 for first calculation b) Find f\'(x) using second order scheme with h = (b-a)/25 for second calculation c) Find f\'(x) using Richardson 6^th order accuracy scheme for final results d) Find the relative error for the thee solutions at point x = 24 from part b) For plotting and for the relative error calculation in the three cases use the following analytical solution: f\'(x) = 2^x(In 2)^2/x - 2 times 2^x(In 2)/x^2 + 2 times 2^x/x^3
Solution
syms x
f=2^x / x
diff (f)
ans=(x*2^ x ln2 - 2^x) /x^2
diff
syms h
x = 2 : h : 26
ans=
syms h
x =1 : h : 26
ans =
diff f = f(x+h) -f(x-h) /2*h -h^2 /3!*diff(f,x,3) +h^4/5!diff(f,x,5)+....
ans =
diff f =2^x (ln2)^2/x - 2*2^x (ln2)/x^2 + 2*2^x/x^3
ans=
