Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi guys
I have issue with matrix multiplications.
Please see the file and (hope) help me with it.
Best regards
Andrzej
Solved! Go to Solution.
@AC_9854174 wrote:
Hi guys
I have issue with matrix multiplications.
Please see the file and (hope) help me with it.
Hi Andrzej,
I'm not near a Mathcad PC at the moment, but it looks like you have fallen into the long-standing Mathcad "it looks like a vector but it isn't" visual trap.
The key thing to note is that a range variable (s in your case) is *not* a vector (which I'm sure you already know). However, the result of evaluating a range vector can look very much like a vector.
What you need to do in the above instance is convert s to a vector. This you can do by the simple expedient of typing "=" after defining s. Mathcad will then convert the range (1,2..4) to a vector and assign it to s. I don't like this trick, for a variety of reasons, but it is fairly common practice. Hopefully, you should the see the result you want.
----
As for why you don't see the intended result, the next key thing to note is that Mathcad treats a range variable (s) as an implicit loop operator. Mathcad evaluates s for each value of its range. If you simply evaluate s, then Mathcad displays the evaluation as if it were a vector, but, as stated earlier, it's not - it's a list of the results of each individual evaluation stacked up on each other to look like a vector.
In your first vectorized expression, Mathcad will calculate b*a(1) and display the result at the top, then b*a(2), and so on. Mathcad further confuses the range vs vector display by collapsing each of the individual results to make the output look like a nested vector.
Your final example works because each of the two data items actually are vectors.
Hope that isn't too confusing.
This display confusion has been a matter of discussion since the time of Pythagoras (at least, I'm sure I've seen a cuneiform tablet complaining about the issue)..
Stuart
@AC_9854174 wrote:
Hi guys
I have issue with matrix multiplications.
Please see the file and (hope) help me with it.
Hi Andrzej,
I'm not near a Mathcad PC at the moment, but it looks like you have fallen into the long-standing Mathcad "it looks like a vector but it isn't" visual trap.
The key thing to note is that a range variable (s in your case) is *not* a vector (which I'm sure you already know). However, the result of evaluating a range vector can look very much like a vector.
What you need to do in the above instance is convert s to a vector. This you can do by the simple expedient of typing "=" after defining s. Mathcad will then convert the range (1,2..4) to a vector and assign it to s. I don't like this trick, for a variety of reasons, but it is fairly common practice. Hopefully, you should the see the result you want.
----
As for why you don't see the intended result, the next key thing to note is that Mathcad treats a range variable (s) as an implicit loop operator. Mathcad evaluates s for each value of its range. If you simply evaluate s, then Mathcad displays the evaluation as if it were a vector, but, as stated earlier, it's not - it's a list of the results of each individual evaluation stacked up on each other to look like a vector.
In your first vectorized expression, Mathcad will calculate b*a(1) and display the result at the top, then b*a(2), and so on. Mathcad further confuses the range vs vector display by collapsing each of the individual results to make the output look like a nested vector.
Your final example works because each of the two data items actually are vectors.
Hope that isn't too confusing.
This display confusion has been a matter of discussion since the time of Pythagoras (at least, I'm sure I've seen a cuneiform tablet complaining about the issue)..
Stuart
Hi Stuart
Its so simple solution that I will never come up with it 😉
Thanks a lot
Andrzej
@AC_9854174 wrote:
Hi Stuart
Its so simple solution that I will never come up with it 😉
Thanks a lot
Hi Andrzej,
Not only you. It's not intuitive and can cause problems if you expect it to apply to matrices or nested vectors.
Here are a couple of examples where the "displayed" value differs from the actually calculated value.
That's why I usually prefer to explicitly define vectors and not use 'tricks' that don't generalise.
Stuart