Evaluation using Interval Arithmetic
The problem was to evaluate the expression
f(x) = (((1.013x**2 - 5.262)x - 0.1732)x + 0.8389)x - 1.912
using four decimal digit interval arithmetic with
x = [2.278,2.280].
The sequence of operations is:
x^2 contained in [ 5.189,5.199]
1.013x^2 contained in [ 5.256,5.267]
1.013x^2 - 5.262 contained in [-0.006,0.005]
* x contained in [-0.01368,0.01140] (4 SIGNIFICANT figs.)
-0.01732 contained in [-0.03100,-0.005920]
*x contained in [-0.07068,-0.01348]
+0.8389 contained in [ 0.7682, 0.8255]
*x contained in [ 1.749, 1.881]
-1.912 contained in [-0.1630,-0.03100]
This function is rather ill-conditioned. If the program
! The following program uses machine rounding, rather than
! four digit rounding
program problem_3_b_with_interval
use interval_arithmetic
implicit none
type(interval) :: x, value
call simini
x = interval(2.278d0,2.280d0)
value = x**2
write(*,'(1x,a15,2(1x,d14.6))') "^2:", value
value = 1.013d0*value
write(*,'(1x,a15,2(1x,d14.6))') "*1.013:", value
value = value-5.262d0
write(*,'(1x,a15,2(1x,d14.6))') "-5.262:", value
value = value*x
write(*,'(1x,a15,2(1x,d14.6))') "*x:", value
value = value-0.01732d0
write(*,'(1x,a15,2(1x,d14.6))') "-0.01732:", value
value = value*x
write(*,'(1x,a15,2(1x,d14.6))') "*x:", value
value = value+ 0.8389d0
write(*,'(1x,a15,2(1x,d14.6))') "+0.8389:", value
value = value*x
write(*,'(1x,a15,2(1x,d14.6))') "*x:", value
value = value -1.912d0
write(*,'(1x,a15,2(1x,d14.6))') "-1.912:", value
end program problem_3_b_with_interval
is run, the following output is produced:
^2: 0.518928D+01 0.519840D+01
*1.013: 0.525674D+01 0.526598D+01
-5.262: -0.525531D-02 0.397920D-02
*x: -0.119821D-01 0.907258D-02
-0.01732: -0.293021D-01 -0.824742D-02
*x: -0.668088D-01 -0.187876D-01
+0.8389: 0.772091D+00 0.820112D+00
*x: 0.175882D+01 0.186986D+01
-1.912: -0.153176D+00 -0.421438D-01
If, instead of x = [2.278,2.280], x=[2.279,2.279]
is used in the program, and a d24.16 format is used, the
following output is produced:
^2: 0.5193840999999999D+01 0.5193841000000000D+01
*1.013: 0.5261360932999998D+01 0.5261360933000000D+01
-5.262: -0.6390670000016030D-03 -0.6390669999998266D-03
*x: -0.1456433693003653D-02 -0.1456433692999605D-02
-0.01732: -0.1877643369300365D-01 -0.1877643369299960D-01
*x: -0.4279149238635533D-01 -0.4279149238634609D-01
+0.8389: 0.7961085076136446D+00 0.7961085076136539D+00
*x: 0.1814331288851496D+01 0.1814331288851517D+01
-1.912: -0.9766871114850395D-01 -0.9766871114848263D-01
One concludes that the values are sensitive to x.