Question

C++/Computational Physics: Write a program that implements the forward difference routine to calculate a derivative. Use...

C++/Computational Physics: Write a program that implements the forward difference routine to calculate a derivative. Use it to evaulate the derivative of the following function at x=0.8

f(x)=sin(cos(x^2))

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

CODE:

Below is the code to your question

clc

clear all

close all

h=-10;

h=10.^h;

x=0.8;

f=@(x) sin(cos(x.^2));

Dy=(f(x+h)-f(x))/h;

fprintf('The derivative using forward difference at x=0.8 is %.4f\n',Dy)

1clc 2lear all 3 -close all h--10; x=0 . 8 ; 7-f-e (x) sin (cos (x.*2)) 8- Dy= ( f (x+h)-f(x) ) /h ; -rnThe deravative using torward ditterence at x0.8 1 Command Window New to MATLAB? Watch this Video see Examples or read GettingStarted The derivative using forward difference at x-0.8 is -0.6643 兵>>THANK YOU.

Add a comment
Know the answer?
Add Answer to:
C++/Computational Physics: Write a program that implements the forward difference routine to calculate a derivative. Use...
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