Skip to main content
7-Bedrock
February 8, 2017
Solved

Symbolics with vectorize & scalar product

  • February 8, 2017
  • 2 replies
  • 3877 views

Hello everyone !

It seems to me that symbolic calculation works strangely when applied to scalar product of two vectors, even if I use vectorize operator.

The consequent error message "Divide by 0" is then not so unexpected... Or maybe it's me who's wrong there.

What's the meaning of the bar above T in one of the symbolic results ? (attached worksheet).

Many thanks, Liv.

Best answer by Werner_E

Yes, symbolic evaluation will not use automatic implicit vectorization, whereas numeric evaluation will do.

You have to explicitly vectorize when using symbolic eval (and I would advise to do so with numeric eval as well).

In this case the problem is the exponentiation of the vector, which is not a valid operation on vectors from a mathematical point of view and so muPad refuses to simplify it. In the multiplication the expression is treated like an unknown scalar and thats the reason we get a vector result.

The numerics of Mathcad applies automatic implicit vectorization if an operation is not defined for vectors and does what you probably expected - creating a new vector which then is multiplied by the second vector..

To achieve the same effect using the symbolics, you have to explicitly vectorize that part of the expression.

Example:

2 replies

23-Emerald IV
February 8, 2017

It's because x is undefined. The symbolic solver doesn't mind, simply puts x in the answer.

You use the vectorize operator, so with a vector as input, you should expect a vector as result.

I don't see "the bar above T in one of the symbolic results".

Luc

Liv7-BedrockAuthor
7-Bedrock
February 8, 2017

Obviously, you are right there and me definitely wrong

25-Diamond I
February 8, 2017

It seems to me that symbolic calculation works strangely when applied to scalar product of two vectors, even if I use vectorize operator.

The consequent error message "Divide by 0" is then not so unexpected... Or maybe it's me who's wrong there.

It works, if you vectorize the whole expression (including the division)

What's the meaning of the bar above T in one of the symbolic results ? (attached worksheet).

This means the conjugate complex of T.

It has to do with the mathematical definition of the scalar product:

You can avoid it by using the appropriate matrix multiplication (transpose the first factor to do so)

or tell Mathcad/MuPad that you don't use non-real numbers

But I am not sure which calculation you had in mind and if that partial vectorization was done on purpose:

Liv7-BedrockAuthor
7-Bedrock
February 8, 2017

I think I messed my comments in posted worksheet...

The desired result for Lambda1f is a scalar (a single function of x and T), same as for Lambda2f and Lambda3f. That is a scalar (one function) at both numerator and denominator of Lamda1f.

But you are right, Werner, there is assume/real in Symbolic of Mathcad in order to make use of.

Liv7-BedrockAuthor
7-Bedrock
February 8, 2017

Ok, there's M^1/3 too  ,    which seems to behave differently in numeric and symbolic calculation...

vectors product.jpg