Question
Due to what error (round-off or truncation) does the result for N 40 no longer improve when increasing N? MY FUNCTION function [y,tre] = myLnx(x,N)
Due to what error (round-off or truncation) does the result for N 40 no longer improve when increasing N?
MY FUNCTION
function [y,tre] = myLnx(x,N) %Input: %x: argument of ln(x) %N: number of terms to use %Output: %y: value of ln(x) %tre: true relative error
%initialize running sum or lower bound of sum y = 0;
for n = 0:N y = y+(2.*(x-1).^(2*n+1))./((2*n+1).*(x+1).^(2*n+1)); end
%calculate true relative error tre = (Log(x)-y)./Log(x);
end
%save the above function and run the following code
x = 4.5; % given in the problem
for N= [10 20 30 40 50] [y,tre] = myLnx(x,N); fprintf('N=%i: estimate for Ln(x) = %+16.15e, true relative error = %+16.15e ',... N,y,tre); end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started