Home > Mobile >  Why is norm(x, type='2')!=x%*%x?
Why is norm(x, type='2')!=x%*%x?

Time:09-16

Title says it all.

x = c(1,2,3)
print(norm(x, type='2')-x%*%x)

Prints: -10.25834

Why are they not equal?

CodePudding user response:

Because the 2-norm is the square root of t(x) %*% x:

> print(norm(x, type='2')^2-x%*%x)
     [,1]
[1,]    0
  •  Tags:  
  • r
  • Related