1/9 * 45
results in zero rather than 5 since 1/9 (with integer arithmetic) produces
a zero.
Even assuming real arithmetic, the decimal expansion of 1/9 is limited to the number of places allotted for real numbers. Thus it is possible that 1.0/9.0 * 9.0 will NOT equal 1.0.
On some machines, 1.0/9.0 may equal 0.1111111, which when multiplied by 9.0 results in .99999999 rather than 1.0000.
This has implications about repeated additions or multiplications. A good rule is to arrange computations such that operations are performed, as much as possible, on numbers of the relatively same magnitudes. Thus small numbers should be added to small numbers and large numbers to large numbers.
As an example, one can get different answers if one adds the harmonic series
1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + ... + 1/30,000starting with the one or starting with the end term.
Sometimes formulas for functions (e.g., sin x, cos x, ex) are based on the Taylor or Maclaurin Series expansions (cf. Stewart, Calculus). For example,
Now, one way to reduce the number of operations is to make use of Horner's Rule in which powers of a variable are changed into nested multiplications. For example,
ax3 + bx2 + cx + d
can be rewritten as
((ax + b)x + c)x +d
The first expression contains 2 powers, 3 multiplications and 3 additions.
The second expression contains 0 powers, 3 multiplications and 3 additions,
a reduction of 2 power operations.
It is possible to rewrite a short version of ex as given above,
This page is maintained by Dennis C. Smolarski, S.J.
dsmolarski@math.scu.edu
© Copyright 2000 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 11 February 2000.