cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

6-Contributor

## Symbolics with vectorize & scalar product

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.

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:Liv)

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:

10 REPLIES 10
23-Emerald II
(To:Liv)

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

6-Contributor
(To:LucMeekes)

Obviously, you are right there and me definitely wrong

24-Ruby V
(To:Liv)
 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)

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

6-Contributor
(To:Werner_E)

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.

6-Contributor
(To:Liv)

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

24-Ruby V
(To:Liv)

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:

23-Emerald II
(To:Werner_E)

The error messages are in all 4 cases: "No symbolic result was found.", which is a viable statement considering the mathematical incorrectness. But it's sad that the vectorization does not seem to get transferred to the symbolic domain.

Mathcad11/Maple also refuses other exponents (I tried '2').

Luc

24-Ruby V
(To:LucMeekes)

I guessed that Maple would react differently and I agree that its sad that vectorization does not work as it should with symbolic eval.

Think that has nothing to do with Maple but its a matter of Mathcads interface to the symbolics which obviously was improved somewhere on the way to MC15.

24-Ruby V
(To:Werner_E)

Just see that I inserted a wrong picture when I was talking about he matrix product.

It should have been this one

6-Contributor
(To:Werner_E)

Problem solved.

Thank you both, Luc and Werner, for considering it.

Announcements