Strange (lack of) round-off error using norm

2 visualizzazioni (ultimi 30 giorni)
Mariano
Mariano il 16 Feb 2019
Risposto: Mariano il 17 Feb 2019
Hello,
I have found this behaviour:
>> format hex
>> p=[sqrt(2) sqrt(2)]*1e3;
>> sqrt(sum(p.^2))
ans =
409f400000000001
>> norm(p)
ans =
409f400000000000
I understand the round-off error using sqrt. What I do not understand is how does norm do to avoid it.
Thanks,
Mariano
  2 Commenti
David Goodmanson
David Goodmanson il 17 Feb 2019
Hi Mariano
I ran this on my PC and got
ans = 409f400000000001
ans = 409f400000000001
Not sure what to say .....
Walter Roberson
Walter Roberson il 17 Feb 2019
R2018b on my Mac, I do see the different values.

Accedi per commentare.

Risposte (1)

Mariano
Mariano il 17 Feb 2019
I should have said version and computer:
R2018b on Windows 64bits.

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by