# Derivative of a function in a particular point

2 views (last 30 days)
george veropoulos on 16 Jul 2021
Commented: george veropoulos on 19 Jul 2021
Hi
I have an external function y= function fa(x)
y=sin(x./pi)
end
i want in the main program to find the derivative of fa in numerical point
thank you
George

george veropoulos on 16 Jul 2021
format long
x = 2 ;
h = sqrt(eps) ;
f1=(sin(x + h)./(x+h) - sin(x)./x) / h % -0.400000
% -0.435397773981094
f2=cos(x)./x-sin(x)./x^2
% -0.435397774979992
##### 2 CommentsShowHide 1 older comment
george veropoulos on 16 Jul 2021
yes sqrt(eps(x) )

Jan on 16 Jul 2021
Use one of the quotients of differences to get a numerical approximation of the derivative:
x = 1.2345;
h = sqrt(eps);
dy_right = (fa(x + h) - fa(x)) / (h)
dy_left = (fa(x) - fa(x - h)) / (h)
dy_both = (fa(x + h) - fa(x - h)) / (2 * h)
function y = fa(x)
y = sin(x./pi)
end
george veropoulos on 19 Jul 2021
thank you all! very helpfull dicussion
George

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!