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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

2-Guest

Program to perform summation on an array

I wrote and attached a basic worksheet to demonstrate what I am trying to achieve. I can get the solution by defining each part one-by-one like you will see on the attached sheet, but that is going to be too tedious on my main worksheet. A program or other built in function would be ideal.

Thanks in advance for the help.

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:AS_10137793)

Here are a few suggestions for functions to do the job.

On contrary to Stuart recursive function, none of them will deal with a scalar as argument and the last two fail if the argument vector has just one element. Would need to throw in an "if" to deal with that situation if necessary.

5 REPLIES 5
23-Emerald II
(To:AS_10137793)

My trial period for Mathcad Prime 8 has just run out, so I can't demonstrate a programmed version, but here's a version that should run in most versions of Mathcad (this was written in Mathcad Express 7).   It uses range variables.

Stuart

23-Emerald II
(To:StuartBruff)

And here's one possible (recursive) functional solution ...

This function will return a vector even if its argument is a scalar.

Stuart

23-Emerald III
(To:AS_10137793)

Here's one approach. Should work for any length vector >0  and with any value of ORIGIN.

Success!
Luc

24-Ruby V
(To:AS_10137793)

Here are a few suggestions for functions to do the job.

On contrary to Stuart recursive function, none of them will deal with a scalar as argument and the last two fail if the argument vector has just one element. Would need to throw in an "if" to deal with that situation if necessary.

2-Guest
(To:Werner_E)

Thank you everyone for the help! I tried lots of different things on my end and I did not know to use the "last(v)" in there as part of the sum. That's new to me, so thank you for that as well. A couple of these solutions will work for me, and I will be able to use some of this new info on other things I will have to code later.

Andrew

Announcements
Top Tags