Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hello!
I am trying to sum up all the values of the given function f(x) by using the summation operator.
Variable "x" has assigned values in vector form. How do I proceed here?
Please, take a look at the attached file (Mathcad Prime 6).
Best regards,
Sergey
Solved! Go to Solution.
You need
for it to be a vector !
kudos
Owe
Of course it is - I should have seen it.
Thanks a lot.
OK, you transpose the array x, which gives
Then your summation gives:
That is because j is not part of the argument of the summation. If you change the limits for j:
or:
Now if you sum these array values, you get 83, which is the sum of the values of the function results for each of the array elements in x.
To get that straight away, you can index the function inside the summation:
Which is (most probably) what you were after.
Prime is pretty forgiving. Without requiring a transpose, this also works:
Success!
Luc
Thanks Luc.
But for the correctness sake it may be better to stick with the transpose operator 🙂
Sergey
Hello.
The last but one equation is one I was looking after. I prefer to have "j" in my summation to reflect algebraic correctness.
Thanks a lot!!
Sergey
Hello Luc.
How do you index the function with "j" inside the summation?
Best regards,
Sergey
Type, immediately after f(x) the following:
[ j
That will put the j in index position.
Success!
Luc
Thank you.
Luc,
I came across one more challenge: when there is a function of two arguments such as f(x,y) Mathcad computes incorrect value of the summation. If the function is given with the argument "y" outside brackets, then Mathcad indicates an error in computations. The same issue is when we have a function of one variable which is inside and outside of the brackets.
What do I do wrong here?
Sergey
@Sergey wrote:
Luc,
I came across one more challenge: when there is a function of two arguments such as f(x,y) Mathcad computes incorrect value of the summation. If the function is given with the argument "y" outside brackets, then Mathcad indicates an error in computations. The same issue is when we have a function of one variable which is inside and outside of the brackets.
What do I do wrong here?
Sergey
Don't forget that Mathcad is an array language, Sergey. Consequently, if there are vectors or matrices involved, Mathcad will interpret operations as array operations if it can.
What were you expecting f(x) to produce as a value?
Stuart
Prime Express 7 worksheet attached.
Vectorize operator help: https://support.ptc.com/help/mathcad/r7.0/en/index.html#page/PTC_Mathcad_Help%2Fvectorize_operator.html
Thank you Stuart.
This explains a lot.
Sergey
@LucMeekes wrote:
Prime is pretty forgiving. Without requiring a transpose, this also works:
Forgiving, Luc? Inconsistent more like.
If it were forgiving, I wouldn't have to prettify myself in front of the mirror and put on my best, whiny orc accent ...
Is Saruman reserving them for some amusing fate?
(I wonder when we'll get the prefix operator back?)
Stuart
You're confusing stack with augment?
Not that it matters much:
Luc
So "stuck" is basically another way of representing a vector?
@Sergey wrote:
So "stuck" is basically another way of representing a vector?
"stack" is closer to being an array constructor than a representation of a vector.
stack forms an array by joining its arguments together vertically. These arguments can be of scalars, strings, vectors or more general arrays. The major restriction is that the arguments must have the same number of columns (scalars and strings get effectively promoted to single-element arrays).
augment is like stack, except that it joins arrays horizontally - implying that the arguments must have the same number of rows.
Stuart
@LucMeekes wrote:
You're confusing stack with augment?
Not that it matters much:
Luc
A combination of typos and shuffling things into the wrong places, I'm afraid, Luc.
I'm suffering from a particularly virulent case of the dreaded lurgi at the moment, and confusion is but one of the symptoms. I was hallucinating at about 0500 hrs this morning that I was replying to a message from @ValeryOchkov that seemed to infer an object-oriented version of Mathcad (something, I'd proposed back in the Mathsoft days). Given that I'm still experiencing that dream-like, floating state that sometimes accompanies bugs on the rampage, I wouldn't be surprised to find this reply is equally unreal ...
Stuart
(You'd think I would have had better things to hallucinate about than obscure Mathcad feature requests, wouldn't you? ... where are the dancing girls, aliens or interstellar, stealth fighters?)
@StuartBruff wrote:
...that seemed to infer an object-oriented version of Mathcad (something, I'd proposed back in the Mathsoft days).
At least I wasn't hallucinating about that bit.
https://community.ptc.com/t5/PTC-Mathcad/Making-use-of-namespaces/m-p/377006#M147950
I'm semi-sure there was a more detailed version of the proposal, but that may not have survived the transition from Collaboratory to Community.
Stuart