From maechler at stat.math.ethz.ch  Tue Sep 20 17:27:03 2016
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 20 Sep 2016 17:27:03 +0200
Subject: [Rd] Numerical accuracy of matrix multiplication
In-Reply-To: <FAAEBE2A-0C85-40B1-8305-27452CF7A00C@gmail.com>
References: <CAA4naPDPXh2Q+KUMQhBJs4cecOC7uetbxihz_fxxk92JZNPLKg@mail.gmail.com>
	<FAAEBE2A-0C85-40B1-8305-27452CF7A00C@gmail.com>
Message-ID: <22497.21831.450319.430114@stat.math.ethz.ch>

>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>>     on Fri, 16 Sep 2016 13:33:11 +0200 writes:

    > On 16 Sep 2016, at 12:41 , Alexis Sarda <alexis.sarda at gmail.com> wrote:

    >> Hello,
    >> 
    >> while testing the crossprod() function under Linux, I noticed the following:
    >> 
    >> set.seed(883)
    >> x <- rnorm(100)
    >> x %*% x - sum(x^2) # equal to 1.421085e-14
    >> 
    >> Is this difference normal? It seems to be rather large for double precision.
    >> 

    > It's less than .Machine$double.eps, relative (!) to x  %*% x ~= 100.

indeed!

Still, it gives exactly 0 on my platform(s), where I'm using R's
own version of BLAS / Lapack.

Are you perhaps using an "optimized" BLAS / LAPACK , i.e, one
that is fast but slightly less so accurate ?

Martin Maechler,
ETH Zurich


    > -pd

    >> Regards,
    >> Alexis.
    >> 
    >> [[alternative HTML version deleted]]
    >> 
    >> ______________________________________________
    >> R-devel at r-project.org mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-devel

    > -- 
    > Peter Dalgaard, Professor,
    > Center for Statistics, Copenhagen Business School
    > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
    > Phone: (+45)38153501
    > Office: A 4.23
    > Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

    > ______________________________________________
    > R-devel at r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Numerical accuracy of matrix multiplication
Martin Maechler