Question

2. The function fi(xo,h) = sin(xo+h)-sin(xo) can be transformed into another form., f2(xo,h), using the trigonometric formula

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


Ond 2 CoA - 2. Herce nothtno 2. 2- 2. 2 (wort)2 Cane So thotMatlab code for finding derivative clear all close all function for which derivative have to find f-e (x) sin (x) fprintffunc

%%Matlab code for finding derivative
clear all
close all

%function for which derivative have to find
f=@(x) sin(x);
fprintf('function for which derivative have to find f(x)=')
disp(f)
%derivative of f
ff=@(x,h) (sin(x+h)-sin(x))/h;
%x0 value
x0=1.2;
%all h values
hh=logspace(0,-20,21);
fprintf('\n\t h \tval \t ext_val \t error\n\n')
for i=1:length(hh)
    h=hh(i);
    val=ff(x0,h);
    val_ext=cos(x0);
    error=abs(val-val_ext);
    fprintf('\t%2.2e \t%f \t%f \t%e \n',h,val,val_ext,error)
end

%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%%
   

Add a comment
Know the answer?
Add Answer to:
2. The function fi(xo,h) = sin(xo+h)-sin(xo) can be transformed into another form., f2(xo,h), using the trigonometri...
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
  • 2. The function fi(xo.h)= sin(xo +h)- sin(xo) can be transformed into another form. f2(xo,h), using the trigonom...

    2. The function fi(xo.h)= sin(xo +h)- sin(xo) can be transformed into another form. f2(xo,h), using the trigonometric formula + sin()-sin() =2cos sin 2 Thus, fi and f have the same values, in exact arithmetic, for any given argument values xo and h. (b) Suggest a formula that avoids cancellation errors for computing the approximation (f(xo +h)- f(xo))/h to the derivative of f(x) = sin(x ) at x xo. Write a MATLAB pro- gram that implements your formula and computes an...

  • Classes and Methods: A class for estimating the derivative of a function f) at the form: takes wh...

    In Python 3.6 Classes and Methods: A class for estimating the derivative of a function f) at the form: takes where h is a small change in x. The goal of this exercise is to use the formula above to differentinte a mat hematical function f(x) implemented as a Python function f(x) Implement class Diff with two special methods. The--init--() method takes in function object and also an optional argument h. The default value of h is le-4. Implement also...

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