Computing 4-digit float point arithmetic

2.4k Views Asked by At

Compute $f(π)$ using 4-digit float point arithmetic if $f(x) = \sqrt{x^2 - 8 - \sqrt{x} }$

Is my $x = 3.141$? and is $f(x) = 0.306$?

1

There are 1 best solutions below

0
On

If you use your 4-digit float point arithmetic for every step you get (assuming correct rounding to nearest): $$x = 3.142$$ $$\sqrt{3.142} = 1.773$$ $$3.142^2 = 9.872$$ $$9.872-8 = 1.872$$ $$1.872-1.773 = 0.099$$ $$f(x) =\sqrt{0.099} = 0.3146$$ Note the lost of a digit through cancellation in the penultimate step.