How to convert to exact arithmetic?

130 Views Asked by At

I'm working through a numerical analysis exercise where I use Newton's method over five iterations. Below is my code.

x = [-5:.01:5];
x0 = 1;
f = 1+0.99*x-x;
fprime = -0.01;

% calculation: take five iterations
for i = 1:5
    h= x0 - f/fprime;          
    xnew = h;                          
end

fprintf("The root after 5 iterations: %25.e", xnew);

I have no issue with how this code works, but I am required to express the number of iterations to reach a root in exact arithmetic. My textbook doesn't contain information about exact arithmetic and Google wasn't too specific.

I know the root is found after one iteration. How do I express $1$ in exact arithmetic?

1

There are 1 best solutions below

1
On BEST ANSWER

That is exactly the answer. In exact arithmetic (for instance using a rational number data type over unlimited integers), Newton solves linear systems in one step.

(One could also directly use the linear solver that is used anyway to compute the Newton step.)