Asking about an output
이전 댓글 표시
%% 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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!