1 answer

4. The first derivative of a function f(x) at a point x = xo can be approximated with the four-po...

Question:

Solve using MATLAB and provide code please

4. The first derivative of a function f(x) at a point x = xo can be approximated with the four-point central difference formu

4. The first derivative of a function f(x) at a point x = xo can be approximated with the four-point central difference formula: dx 12h where h is a small number relative to xo. Write a user-defined function function that calculates the derivative of a math function fx) by using the four-point central difference formula. For the user-defined function name, use dfax-FoPrder(Fun, x0), where Fun is a name for the function that is passed into FoPtder, and x0 is the point where the derivative is calculated. Use h =-in the four-point central difference formula. 100 3 2x 4a (10 points) Compute the derivative of the function f(x) at x0-0.6 using the FoPtder function. Test it in the command window (use format long) 4.b (10 points) Repeat 4.a but with anonymous function. 4.c (5 points) Find the equation for the derivative of f(x) and the value at 0.6. Compare the result with the value in part (a) Ad (10 points) Compute the derivative of the function g(x) =-atx0-2.5 using the FoPtder function. Test it in the command window (use format long) 4.e (5 points) Find the equation for the derivative of g(x) and the value at 2.5. Compare the result with the value in part (d)

Answers

%%% Matlab function

function dfdx = FoPtdr(Fun,x0)
h=x0/100;
dfdx=(Fun(x0-2*h)-8*Fun(x0-h)+8*Fun(x0+h)-Fun(x0+2*h))/(12*h);
end

%%%% Test

clc;
close all;
clear all;
format long;
[email protected](x) x^3*exp(2*x);
x0=0.6;

(a)

>> FoPtdr(Fun,x0)

ans =

5.020016698059604

>>

(b)

>> [email protected](x) x^3;
>> x0=2;
>> FoPtdr(Fun,x0)

ans =

12.000000000000027

(c)

%%%

syms x;
f=x^3*exp(2*x);
df=subs(diff(f),x0);
fprintf('Actual value = %f Error =%1.10f \n',df,abs(x1-df));

OUTPUT:

Actual value = 5.020017 Error =0.0000000891   
>>

(d) and (e)

clc;
close all;
clear all;
format long;
[email protected](x) 3^x/x^2;
x0=2.5;
x1=FoPtdr(Fun,x0);
fprintf('Using function FoPtdr dydx=%f \n',x1);
syms x;
f=3^x/x^2;
df=subs(diff(f),x0);
fprintf('Actual value = %f Error =%1.10f \n',df,abs(x1-df));

OUTPUT:

Using function FoPtdr dydx=0.744785
Actual value = 0.744785 Error =0.0000000174   
>>

.

Similar Solved Questions

1 answer
Stockholders' equity of Ernst Company consists of 87,000 shares of $5 par value, 11% cumulative prefe...
Stockholders' equity of Ernst Company consists of 87,000 shares of $5 par value, 11% cumulative prefe of $1 par value common stock. Both classes of stock have been outstanding since the company's ince dividends in the prior year, but it now declares and pays a $160,000 cash dividend at the c...
1 answer
Determine if the set is orthogonal in the interval{sen 2nx}, n = 1,2,3... [0, 7/2).
determine if the set is orthogonal in the interval{sen 2nx}, n = 1,2,3... [0, 7/2)....
1 answer
Campbell Corporation uses the retail method to value its inventory. The following information is available for the year 2021:
Campbell Corporation uses the retail method to value its inventory. The following information is available for the year 2021: CostRetailMerchandise inventory, January 1, 2021$390,000$320,000Purchases587,000980,000Freight-in28,000Net markups40,000Net markdowns6,000Net sales1,000,000Required:Dete...
1 answer
Please select answer from options given in [] and are bold, there are 3 parts Cancer...
please select answer from options given in [] and are bold, there are 3 parts Cancer can be described as    ["a genetic", "an infectious"]         disease which results from ["mutations in multiple different genes", "a single gene m...
1 answer
1. For the molecule below a) Circle and label all functional groups. b) Name all intermolecular...
1. For the molecule below a) Circle and label all functional groups. b) Name all intermolecular forces present in the molecule: Amane Aromates hetone lendon dspervon Dipale -Dipole Amine Aromatr 2. For the molecule below a) Box in all atoms that can hydrogen bond with water but not with acetone (CH3...
1 answer
In the root-cause analysis of wrong-site surgery, what is the probability of finding that the patient...
In the root-cause analysis of wrong-site surgery, what is the probability of finding that the patient was responsible? If in the past you have reviewed 100 wrong-site surgeries and found that 5 percent of them were because of patient misinformation, what is the implication of this finding for the ro...
1 answer
QUESTION THREE a. Construct a Push Down Automata that accepts L= {On In|n20; [10 Marks) b....
QUESTION THREE a. Construct a Push Down Automata that accepts L= {On In|n20; [10 Marks) b. A finite-state machine can also be used to model a simple automated teller machine (ATM). Construct an FSM for an ATM that accepts deposits and withdrawals [10 Marks)...
1 answer
STANDARD VIEW PETTER VERSION MCK RCES Question 6 Selected transactions for Sophie's Dog Care are as...
STANDARD VIEW PETTER VERSION MCK RCES Question 6 Selected transactions for Sophie's Dog Care are as follows during the month of March: Mar. 1 Pald the monthly rent of $1,000 3 Performed dog grooming services for $170 on account. 5 Performed dog grooming services for cash of $215. 8 Purchased equ...
1 answer
3. During a very quick stop, a car decelerates at 6.2 m/s2. Assume the forward motion...
3. During a very quick stop, a car decelerates at 6.2 m/s2. Assume the forward motion of the car corresponds to a positive direction for the rotation of the tires (and that they do not slip on the pavement). a. What is the angular acceleration of its tires in rad/s2, assuming they have a radius of 0...
1 answer
The profitability index (PI) is a capital budgeting tool that is defined as the present value...
The profitability index (PI) is a capital budgeting tool that is defined as the present value of a project's cash inflows divided by the absolute value of its initial cash outflow. Consider this case: Happy Dog Soap Company is considering investing $2,500,000 in a project that is expected to gen...
1 answer
What is a western blot HIV test?
What is a western blot HIV test?...
2 answers
How are enzymes destroyed, and what type of proteins speed up a chemical reaction?
how are enzymes destroyed, and what type of proteins speed up a chemical reaction?...
1 answer
Please answer correctly and i'll rate a like asap. 1.) A 72-kg woman holds a 9-kg...
Please answer correctly and i'll rate a like asap. 1.) A 72-kg woman holds a 9-kg package as she stands within an elevator which briefly accelerates upward at a rate of 0.27g. Determine the force R which the elevator floor exerts on her feet and the lifting force L which she exerts on the packa...
1 answer
1. Order: Amikin 0.15 Gm, IM, three times a day. Available: MOC 00 15-3015-20 Amikin AMACIN...
1. Order: Amikin 0.15 Gm, IM, three times a day. Available: MOC 00 15-3015-20 Amikin AMACIN SULFATE MUJECTION Fortal. Uw EQUIVALENT TO 100 no EZIVOLYYTYI 10M 3015200RL-06 an 5 with M,50 View 0.13sodium bisulfite added aan alondant, utlernd win 0.5 sodium citrate, dusted to pH U.S. 3.71.280 14.024,34...
1 answer
Sample Question 3. Instruments located at O are part of the ground traffic control system for...
Sample Question 3. Instruments located at O are part of the ground traffic control system for a major airport. At a certain instant during the takeoff roll of the aircraft P, the sensors indicate the angle θ=40° and the total velocity V= 140 ft/sec. Determine the value of ?̇ and ?M...
1 answer
QUESTION 36 Where does the Calvin cycle take place in algae and plants O A. Stroma...
QUESTION 36 Where does the Calvin cycle take place in algae and plants O A. Stroma of the chloroplast B. None of these answers are correct OC. Cytoplasm surrounding the chloroplast OD. On the thylakoid membrane E. Interior of the thylakold (thylakoid space) F. Outer membrane of the chloroplast...
3 answers
The HCF of the smallest composite number and the smallest prime number is 1
The HCF of the smallest composite number and the smallest prime number is 1.is this statement is true or false.give reason.please...
1 answer
6. -1 points OSColPhysAP2016 6.2.WA.022.Tutorial. My Notes Ask Your Teacher 0 A jet fighter flying at...
6. -1 points OSColPhysAP2016 6.2.WA.022.Tutorial. My Notes Ask Your Teacher 0 A jet fighter flying at 300 m/s (just below the speed of sound) makes a turn of radius 1.90 km. (a) What is its centripetal acceleration in gs? (b) Suppose the pilot makes an emergency turn to avoid an approaching missile,...
1 answer
Book Depot Inc. sells on terms of 3/10, net 60. What is the implicit cost of...
Book Depot Inc. sells on terms of 3/10, net 60. What is the implicit cost of trade credit under these terms? Use a 365-day year....