Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
...in one case returning a vector; in the other evaluating only the last entry in vthrow? The expressions have the same form.
Solved! Go to Solution.
Aha. Thanks. That makes sense once you explained it.
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):
Aha. Thanks. That makes sense once you explained it.