Numerical Patterns
Convergence Steps
Halve an Error
Many numerical methods repeatedly reduce an error estimate. A small bounded loop can show the shape without doing heavy computation.
Program
Play the program to choose how many halving steps are applied.
convergence_steps.f90
program convergence_steps_demo
implicit none
integer :: step_count
integer :: i
real :: error
step_count =
error = 1.0
do i = 1, step_count
error = error / 2.0
end do
print '(F0.3)', error
end program convergence_steps_demo
program convergence_steps_demo
implicit none
integer :: step_count
integer :: i
real :: error
step_count =
error = 1.0
do i = 1, step_count
error = error / 2.0
end do
print '(F0.3)', error
end program convergence_steps_demo
program convergence_steps_demo
implicit none
integer :: step_count
integer :: i
real :: error
step_count =
error = 1.0
do i = 1, step_count
error = error / 2.0
end do
print '(F0.3)', error
end program convergence_steps_demo
bounded loop
`do i = 1, step_count` keeps the iteration count explicit.
error update
Each loop halves the current error estimate.
convergence
Repeated reduction shows the approach toward zero without relying on timing.