#use MATLAB script
1) Calculate the following for the function f(x) = e-4x- 2x3
a. Calculate the derivative of the function by hand. Write a MATLAB function that calculates the derivative 05. of this function and calculate the derivative at x = 0.5.
b. Develop an M- to evaluate the cetered finite-difference approximation (use equation below), at x = 0.5. Assume that h = 0.1.
c. Repeat part (b) for the second-order forward and backward differences. Again Assume that h = 0.1.
d. Using the results obtained in parts b and c, calculate the percentage error between the actual value and the results of (b) and (c).
clc
clear all
close all
f=@(x) exp(-4*x)-2*x^3;
g=matlabFunction(diff(sym(f)));
disp('Exact value of derivative at x=0.5 is');
ex=g(0.5);
disp(ex);
disp('Value for part b');
h=0.1;
x=0.5;
Df1=(-f(x+2*h)+8*f(x+h)-8*f(x-h)+f(x-2*h))/(12*h)
disp('Value for part c, forward difference');
Df2=(-f(x+2*h)+4*f(x+h)-3*f(x))/(2*h)
disp('Value for part c, backward difference');
Df3=(3*f(x)-4*f(x-h)+f(x-2*h))/(2*h)
disp('Percent error in central difference is');
abs(ex-Df1)/abs(ex)*100
disp('Percent error in forward difference is');
abs(ex-Df3)/abs(ex)*100
disp('Percent error in backard difference is');
abs(ex-Df2)/abs(ex)*100
please i need the requiered MATLAB script to solve this. All calculations need to be done in matlab please Design Layout References Mailings Review View Share 1) (15 points) Calculate the following for the function f(x) = e-a-x a. Use calculus to determine the correct value of the derivative. b. Develop an M-file function to evaluate the centered finite-difference approximations, starting with x = 0.5 Thus, for the first evaluation, the x values for the centered difference approximation will be...
please show the matlab coding Exercise 4. Calculate the derivative of j(r) = besselj (1,x) at x = 1 using forward, backward and centered finite differences with a step h = 0.1. Exercise 4. Calculate the derivative of j(r) = besselj (1,x) at x = 1 using forward, backward and centered finite differences with a step h = 0.1.
#7. [Extra Credit] is calculus wrong?! Consider f(x) = ex (a) Calculate the derivative of fx) atx 0 using O(h) finite difference (forward and backward) and O(h2) centered finite difference. Vary h in the following manner: 1, 101,102... 1015. (Write a MATLAB script for this purpose and call it pset5_prob7) (b) Modify your script to plot (log-log) the the true percent error in all three cases as a function of h in one plot. (c) In calculus we learned that...
Please help me answer this question using matlab Consider the function f(x) x3 2x4 on the interval [-2, 2] with h 0.25. Use the forward, backward, and centered finite difference approximations for the first and second derivatives so as to graphically illustrate which approximation is most accurate. Graph all three first-derivative finite difference approximations along with the theoretical, and do the same for the second derivative as well
MatlabMECE 2350 Numerical Methods Lab 8.1. Differentiate the following function: f(x) = ex -2x +1 and solve its first derivative atx = 8 2. Numerically evaluate the approximated first derivative from the above function at x = 8 and h = 0.15 by the following: (a) Forward finite difference method (b) Backward finite difference method (c) Centered finite difference method 3. Calculate the error of each method by comparing the numerical derivative with the result from problem 1.
3. Find the first derivative of a functionf(x)-ex (a) Use calculus to determine the correct value of the derivative at x = 2. If h = 0.25, (b) Evaluate the second-order centered finite-difference approximation (e) Evaluate the second-order forward difference approximation. (d) Evaluate the second-order backward difference approximation. (e) Create a MATLAB function program, which gives output up to second order centered finite difference approximation of second derivative "(xo). The input arguments aref n (order of approximation, 1 or 2),...
5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central and Taylor numerical schemes. Test your code using the following functions: f(x)-xe*+3x2 +2x -1 and find f (3) and f' (3) for with h 0.1, 0.01 and 0.001 b. Approximate y'(1) and y"(1) using the following table f(x) 0.992 0.8 0.9 0.999 1.0 1.001 1.008 Input: (copy and paste the MATLAB or Scilab script in the following box) 5. Create a...
please show me a Matlab script that will compute the total errors of the approximation due to the given function, also include the panel plot as well, thank you. 1) This problem studies the errors due to the approximation of the first derivative of a given function f(x) using the forward and centered difference methods. For this problem, we consider f(x)=sin(x). a) First, we will investigate the effect of the step size h on the first derivative approximation. Set h=10',...
MatLab Help!! Write a function called Difference to calculate the central difference, forward diflerence, and backward diference approximation to an function within a given range of xmin:xinc:xmax The input argument of the function Difference is the handle to an anonymous function, a row array xmin:xinc:xmax The differences should be returned as a row array, calculated at xmin xinc xmax Restriction. The function should not use loops Ex func - (x) x.3 xmin-3 xinc-e.25; xmax-4; [backDifference, centralDifference, forwardDifference] Derivative(func, xmin, xmax,...
solve with matlab Given the function: f(x) x2 + 4x + et and the point f(1) = 7.7183 use Taylor series to compute the second order approximation to find the value off (1.5). Input your answer up to 4 decimal places.