Skip to main content
25-Diamond I
January 15, 2013
Question

MC doing wrong squaring a vector?

  • January 15, 2013
  • 1 reply
  • 5240 views

I'm not sure, but if X is a vector, shouldn't X^2 give the same result as X*X?

I think Mathcad is doing wrong here, as squaring should be interpreted as scalar product.

The vector with each element squared I would only expect as a result when I use vectorize.

Or am i missing the point?

vectorsqu.png

BTW, the effect is the same in MC15 and Prime2.

1 reply

1-Visitor
January 15, 2013

If you vectorize X*X you match x^2

Isn't a dot product suppose to provide a scalar?

Norm

Werner_E25-Diamond IAuthor
25-Diamond I
January 15, 2013

Isn't a dot product suppose to provide a scalar?

Yes, thats exactly what I was talking about. I'd expect to be X^2 a scalar, too.

In my opinion itt should only be the vectorization which applies the operation singly to each element.

X^(-1) should return an error, if X is not a square matrix, etc.

19-Tanzanite
January 16, 2013

When X is a column vector, then X*X should return an error if Mathcad were complying with the normal rules of vector multiplication. However, all versions of Mathcad I'm aware of (going back to 3) have deliberately chosen to treat X*X as though it were the transpose of X (ie a row vector) multiplied by X, and have chosen to implement X^2 as an element by element operation. These are not strictly errors, but choices (poor choices possibly, but deliberate!).

If you let X be a non-square matrix (rather than a single-column vector) you get the expected error message for both X*X and X^2.

Alan