This is what you might be looking for.
```python
import time
def computation(f):
f /= 7
f += 1
f *= 7
f -= 7
return f
f = 1e16
while True:
f = computation(f)
print(f)
time.sleep(0.1)
```
Why this happens:
In floating-point arithmetic:
$f/7$ and $f*7$ precision loss means these may not perfectly cancel each other.
Performing $f /= 7$, means that the floating-point representation can store results slightly off from expected. This is more noticeable in very large or small numbers.
This is amplified in iterative computations. It won’t immediately result in a divergence to infinity, but the error can grow significantly over many iterations.
Explanation:
- Floating-point division: Dividing by 7 results in a decimal approximation and so might introduce small inaccuracies, especially for very large numbers like $10^{16}$.
- Reaccumulation of errors: Each iteration accumulates small inaccuracies. These will eventually cause noticeable deviations.
- Precision loss with large numbers: starting with large values like $f = 10^{16}$, the floating-point representation cannot store the exact result of each division/multiplication, and so drifting occurs.
A good resource for exploring floating-point issues in detail is the online:
Also, check the IEEE 754 Standard for Floating-Point Arithmetic