If we compute the stopping condition using error = relative_error(f, x), then relative_error calls f(x) internally, but in my solver loop (inside solve_fixed_point() ) I do:
X_next = f(x); // first call to f
error = relative_error(f, x); // second call to f?
num_calls++; // so should num_calls be incremented by two each iteration?
Are we expected to:
-
Use relative_error directly to determine the stopping condition (so count two calls to f per iteration?
or
Compute the relative difference manually inside solve_fixed_point (using the already computed x_next) to ensure only one call to f per iteration (so we only use relative_error at the end in solverexample?)