Strange (lack of) round-off error using norm

1 次查看(过去 30 天)
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 个评论
David Goodmanson
David Goodmanson 2019-2-17
Hi Mariano
I ran this on my PC and got
ans = 409f400000000001
ans = 409f400000000001
Not sure what to say .....
Walter Roberson
Walter Roberson 2019-2-17
R2018b on my Mac, I do see the different values.

请先登录,再进行评论。

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by