# Floating point multiplication in python

Thomas 'PointedEars' Lahn PointedEars at web.de
Tue Sep 6 18:07:42 CEST 2011

```Thomas Rachel wrote:

> Now if you multiply two values with an error, the error also propagates
> into the result - PLUs the result can have its own error source - in the
> same order of magnitude.
>
> (a+e) * (a+e) = a*a + 2*a*e + e*e. So your new error term is 2*a*e + e*e
> or (2*a + e) * e.

but have only scanned here – so it might be flawed as well –,
notwithstanding, it is not clear to me at all what you are trying to prove
there.

Computers (well, perhaps outside of mathematical software) do NOT compute an
equation as humans would do, so the binomial theorem does NOT apply.  In an
algorithm of the real implementation,

(a + e) * (a + e)

would be computed as follows:

b := a + e
c := b * b
or
c := b + … + b

[add the value of `b' to the value of `b' (b−1) times, since binary logic
does not support multiplication]

IOW, the error does propagate into the result indeed, but not as you
described.  Indeed, thanks to rounding on assignment and multiplication
(i. e., setting register values or IEEE-754 floating-point mantissa and
exponent), the error will be different, probably greater than you compute
here.

--
PointedEars

Bitte keine Kopien per E-Mail. / Please do not Cc: me.

```