Question

5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central and Tayl

0 0
Add a comment Improve this question Transcribed image text
Answer #1

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU ALL THE BEST

AS FOR GIVEN DATA...

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:

a. f(x) = xe^x +3x^2 +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)

EXPLANATION ::-

a) Matlab Code

f= @(x) x*exp(x)+3*x^2+x-1;
h = [0.1 0.01 0.001];
% for h=0.1
firstorder_forward1 = (f(3+h(1))-f(3))/h(1)
firstorder_backward1 = (f(3)-f(3-h(1)))/h(1)
firstorder_central1 = (f(3+h(1))-f(3-h(1)))/(2*h(1))
secondorder_central1 = (f(3+h(1))-2*f(3)+f(3-h(1)))/h(1)^2
% for h=0.01
firstorder_forward2 = (f(3+h(2))-f(3))/h(2)
firstorder_backward2 = (f(3)-f(3-h(2)))/h(2)
firstorder_central2 = (f(3+h(2))-f(3-h(2)))/(2*h(2))
secondorder_central2 = (f(3+h(2))-2*f(3)+f(3-h(2)))/h(2)^2
% for h=0.001
firstorder_forward3 = (f(3+h(3))-f(3))/h(3)
firstorder_backward3 = (f(3)-f(3-h(3)))/h(3)
firstorder_central3 = (f(3+h(3))-f(3-h(3)))/(2*h(3))
secondorder_central3 = (f(3+h(3))-2*f(3)+f(3-h(3)))/h(3)^2

b) Matlab Code

x = [0.8 0.9 1.0 1.1 1.2];
f = [0.992 0.999 1.0 1.001 1.008];
firstorder_forward = (f(4)-f(3))/0.1
firstorder_backward = (f(3)-f(2))/0.1
firstorder_central = (f(4)-f(2))/0.2
secondorder_central = (f(4)-2*f(3)+f(2))/0.1^2
secondorder_higher = (-f(1)+16*f(2)-30*f(3)+16*f(4)-f(5))/(12*0.1^2)

I HOPE YOU UNDERSSTAND..

PLS ..RATE THUMBSUP IT HELPS ME ALOT

THANKS GOODLUCK

THANK YOU....!..

Add a comment
Know the answer?
Add Answer to:
5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT