Question

In: Computer Science

question should be done on Matlab 4) Find the derivative of sin(2x) at x = 0.8...

question should be done on Matlab

4) Find the derivative of sin(2x) at x = 0.8 rad and find the value of h where the error is minimum as compared to the true value i.e. actual value or accurate value. a) Use for loop b) Use element by element operation

Solutions

Expert Solution

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

a)

clc

clear all

close all

format long

x=0.8;

h=logspace(-1,-20);

emin=100;

hN=1;

f=@(x) sin(2*x);

for i=1:length(h)

Dy=(f(x+h(i))-f(x-h(i)))/(2*h(i));

err=abs(Dy-2*cos(2*x));

if(err<emin)

hN=h(i);

emin=err;

end

end

disp('h at which error is min is');

disp(hN);

b)

clc

clear all

close all

format long

x=0.8;

h=logspace(-1,-20);

emin=100;

hN=1;

f=@(x) sin(2*x);

Dy=(f(x+h)-f(x-h))./(2*h);

err=abs(Dy-2*cos(2*x));

hN=h(err==min(err));

disp('h at which error is min is');

disp(hN);

Kindly revert for any queries

Thanks.


Related Solutions

Find the 83rd derivative of sin(x) at x=4 by finding the first few derivatives and observing...
Find the 83rd derivative of sin(x) at x=4 by finding the first few derivatives and observing the pattern that occurs.
Find the degree 4 Taylor polynomial of f (x) = sin(2x) centered at π/6
Find the degree 4 Taylor polynomial of f (x) = sin(2x) centered at π/6
Use logarithmic differentiation to find the derivative of the function: y= sqrt(x)e^(x^3) (x^4 +1)^9 sin x
Use logarithmic differentiation to find the derivative of the function: y= sqrt(x)e^(x^3) (x^4 +1)^9 sin x
y� � y � 2x sin x
y� � y � 2x sin x
Write a program (fortran 90) that calls a subroutine to approximate the derivative of y=sin(x)+2x^2 using...
Write a program (fortran 90) that calls a subroutine to approximate the derivative of y=sin(x)+2x^2 using a one-sided difference approach fx = (fi-fi-1)/deltaX and a centered difference approach fx = (fi+1-fi-1)/deltaX. The value of the function f and its derivative fx should be evaluated at x=3.75. Your code should print both values tot he screen when it runs.
the question should be done on Matlab. There is a vector defined as H = [-88,...
the question should be done on Matlab. There is a vector defined as H = [-88, 45, 75, 24, 14, 19, -11, 9, -5, -3, 12, 19 ,56, -4, 5, 17, -6, -8, -9, 6, 15] Write a program as a script file that triples the elements that are positive and a divisible by 3 or 5, and, raises to the power of 2 the elements that are negative but greater than -11.
Find the derivative Y=ln(3-2x)
Find the derivative Y=ln(3-2x)
Using Matlab, consider the function f(x) = x^3 – 2x + 4 on the interval [-2,...
Using Matlab, consider the function f(x) = x^3 – 2x + 4 on the interval [-2, 2] with h = 0.25. Write the MATLAB function file to find the first derivatives in the entire interval by all three methods i.e., forward, backward, and centered finite difference approximations. Could you please add the copiable Matlab code and the associated screenshots? Thank you!
first and second derivative of f(x)= (1-x)arctan(2x) also find newtons method formula
first and second derivative of f(x)= (1-x)arctan(2x) also find newtons method formula
Find the absolute maximum and absolute minimum values of f(x) = cos(2x)+2 sin(x) in the interval...
Find the absolute maximum and absolute minimum values of f(x) = cos(2x)+2 sin(x) in the interval [0; pi]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT