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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Why are these expressions evaluating differently?

JohnRudnicki
15-Moonstone

Why are these expressions evaluating differently?

...in one case returning a vector; in the other evaluating only the last entry in vthrow? The expressions  have the same form.

ACCEPTED SOLUTION

Accepted Solutions

Aha. Thanks. That makes sense once you explained it.

View solution in original post

2 REPLIES 2

No, they don't have the same form!

 

The secret is "automatic vectorization" which Mathcad applies, if an expression/operation would otherwise make no sense when applied to a vector.

 

v^2 is an operation not defined for vectors. So instead of throwing an error message Mathcad applies automatic vectorization. That means it takes every element of the vector v, calculates the expression for this value and collects all those results in a new result vector. Thats the reason you see a vector as result in your first function as neither 1/v^2 nor sin are operations/function defined for vectors.

In you second example the expression in the parenthesis would yield a vector cause of auto vectorization. The expression v/g also yields a vector. And now those two vectors are multiplied. And multiplication IS an operation defined for vectors and so Mathcad return the dot product, a single scalar.

If you want to have that expression evaluated vectorized you would have to explicitly demand it (and I would advise to explicitly apply manual vectorization every time you want it to be done and do not rely on the automatic):

Bild.png

Aha. Thanks. That makes sense once you explained it.

Announcements

Top Tags