Asking about an output
Afficher commentaires plus anciens
%% Differentiation of tan^{-1}x at 1
clear all;
clc;
f=@(x) atan(x);
a=1;
h=10.^[-2:-1:-4];
eVal=1/(1+a^2);
%% Forward difference formula
errf=zeros(length(h),1);
for i=1:length(h)
fDiff(i)=(f(a+h(i))-f(a))/h(i);
errf(i)=abs(eVal-fDiff(i));
end
disp(errf);
%% Central difference formula
errc=zeros(length(h),1);
for i=1:length(h)
fCen(i)=(f(a+h(i))-f(a-h(i)))/(2*h(i));
errc(i)=abs(eVal-fCen(i));
end
disp(errc);
%% Backward Difference formula
errb=zeros(length(h),1);
for i=1:length(h)
fBack(i)=(f(a)-f(a-h(i)))/h(i);
errb(i)=abs(eVal-fBack(i));
end
disp(errb);
The output is:
0.002491666914583
0.000249916666750
0.000024999166126
1.0e-05 *
0.833308332937044
0.008333328516130
0.000083316731292
0.002508333081242
0.000250083333320
0.000025000832460
My question is why the term 1.0e-05 * appearing?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!