Computing the absolute error
이전 댓글 표시
How do I compute the absolute error n = |xn − xr| for n = 0, 1, . . . , 50, where we take the output xr from MATLAB’s fzero function with initial guess xinit = 1 to be the “true” root, given this.
xn = bisectionMethod(f, a, b, numiter)
f1= @(x) cos(x)-x;
f2= @(x) exp(-x^2)-x;
f3= @(x) (x^3)-(1/2);
x1= bisectionMethod(f1, 0, 1, 50);
x2= bisectionMethod(f2, 0, 1, 50);
x3= bisectionMethod(f3, 0, 1, 50);
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Generating and Calling Reentrant Code에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!