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

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?

Best regards,

Sergey

1 ACCEPTED SOLUTION

Accepted Solutions
9-Granite
(To:Sergey)

You need

for it to be a vector !

kudos

Owe

17 REPLIES 17
9-Granite
(To:Sergey)

You need

for it to be a vector !

kudos

Owe

14-Alexandrite
(To:o.svahn)

Of course it is - I should have seen it.

Thanks a lot.

23-Emerald III
(To:Sergey)

OK, you transpose the array x, which 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

14-Alexandrite
(To:LucMeekes)

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

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

14-Alexandrite
(To:LucMeekes)

Hello Luc.

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

Best regards,

Sergey

23-Emerald III
(To:Sergey)

Type, immediately after f(x) the following:

[ j

That will put the j in index position.

Success!
Luc

14-Alexandrite
(To:LucMeekes)

Thank you.

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

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.

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

Stuart

Prime Express 7 worksheet attached.

14-Alexandrite
(To:StuartBruff)

Thank you Stuart.

This explains a lot.

Sergey

23-Emerald II
(To:LucMeekes)

@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

23-Emerald III
(To:StuartBruff)

You're confusing stack with augment?

Not that it matters much:

Luc

14-Alexandrite
(To:LucMeekes)

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

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

23-Emerald II
(To:LucMeekes)

@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?)

23-Emerald II
(To:StuartBruff)

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