You are on page 1of 2

Table of Contents

Problem-1 .......................................................................................................................... 1
Problem-2 .......................................................................................................................... 1
Problem-3 .......................................................................................................................... 2

Problem-1
clc
x = [2 2+0.1];
y = exp(x)+2*sin(x);
dx = diff(x);
dy = diff(y);
format long
dy./dx

ans =

6.849376932833818

Problem-2
f=@(x) exp(x)+2.*sin(x);
x=linspace(0,pi,100);
dx=diff(x);
y=f(x);
dy=diff(y);
d2y=diff(dy);
d2ydx2=d2y./(dx(1:98).^2);
plot(x(1:98),d2ydx2,'*r')
title('Second Derivative of f(x) = exp(x) + 2 sin x');

1
Problem-3
derive(@(x) x*cos(x)-3*x, 0.2, 1.3, 4)

Derivative table
______________________________________________
i h Di,1 Di,2 Di,3 ...
______________________________________________
1 0.2000 -3.9821
2 0.1000 -3.9844 -3.9851
3 0.0500 -3.9849 -3.9851 -3.9851
4 0.0250 -3.9851 -3.9851 -3.9851 -3.9851

Published with MATLAB® R2015a

You might also like