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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Summation of the function

Sergey
14-Alexandrite

Summation of the function

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 

1 ACCEPTED SOLUTION

Accepted Solutions
o.svahn
9-Granite
(To:Sergey)

You need  

osvahn_0-1633520213771.png

for it to be a vector !

kudos

Owe

View solution in original post

17 REPLIES 17
o.svahn
9-Granite
(To:Sergey)

You need  

osvahn_0-1633520213771.png

for it to be a vector !

kudos

Owe

Sergey
14-Alexandrite
(To:o.svahn)

Of course it is - I should have seen it.

Thanks a lot.

LucMeekes
23-Emerald III
(To:Sergey)

OK, you transpose the array x, which gives

LucMeekes_0-1633530300169.png

Then your summation gives:

LucMeekes_1-1633530327207.png

That is because j is not part of the argument of the summation. If you change the limits for j:

LucMeekes_2-1633530387800.png

or:

LucMeekes_3-1633530434036.png

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:

LucMeekes_4-1633530574198.png

Which is (most probably) what you were after.

Prime is pretty forgiving. Without requiring a transpose, this also works:

LucMeekes_0-1633529446024.png

Success!
Luc

Sergey
14-Alexandrite
(To:LucMeekes)

Thanks Luc.
But for the correctness sake it may be better to stick with the transpose operator 🙂

 

Sergey

 

 

Sergey
14-Alexandrite
(To:LucMeekes)

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

Sergey
14-Alexandrite
(To:LucMeekes)

Hello Luc.

 

How do you index the function with "j" inside the summation? 

 

Best regards,

Sergey

LucMeekes
23-Emerald III
(To:Sergey)

Type, immediately after f(x) the following:

[ j

That will put the j in index position.

 

Success!
Luc

Sergey
14-Alexandrite
(To:LucMeekes)

Thank you.

 

 

Sergey
14-Alexandrite
(To:LucMeekes)

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

 

StuartBruff
23-Emerald II
(To: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.

 

2021 10 10 A.png

 

What were you expecting f(x) to produce as a value?

 

2021 10 10 B.png

 

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

Sergey
14-Alexandrite
(To:StuartBruff)

Thank you Stuart.

This explains a lot.

 

Sergey

StuartBruff
23-Emerald II
(To:LucMeekes)


@LucMeekes wrote:

Prime is pretty forgiving. Without requiring a transpose, this also works:

 

 

LucMeekes_0-1633529446024.png


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 ...

 

2021 10 07 A.png

 

Is Saruman reserving them for some amusing fate?

 

(I wonder when we'll get the prefix operator back?)

 

Stuart

LucMeekes
23-Emerald III
(To:StuartBruff)

You're confusing stack with augment?

LucMeekes_0-1633626422558.png

Not that it matters much:

LucMeekes_1-1633626521297.png

Luc

Sergey
14-Alexandrite
(To:LucMeekes)

So "stuck" is basically another way of representing a vector?

 

 

StuartBruff
23-Emerald II
(To:Sergey)


@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

StuartBruff
23-Emerald II
(To:LucMeekes)


@LucMeekes wrote:

You're confusing stack with augment?

LucMeekes_0-1633626422558.png

Not that it matters much:

LucMeekes_1-1633626521297.png

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

Top Tags