Skip to main content
1-Visitor
January 5, 2012
Solved

Creating a function with n-arguments?

  • January 5, 2012
  • 4 replies
  • 6628 views

Hi,

I am working with Mathcad and want to create a function to calculate the parallel resistance of n resistors. Therefore I would need a function that would accept n arguments.

Currently I have separate functions defined for 2 elements, 3 elements, and 4 elements:

Is there any way to define a function that would evaluate this expression for n elements?

Thanks

Best answer by RichardJ

Sorry, but it is not possible to create user defined functions that take a variable number of arguments (even though there are built-in functions that take a variable number of arguments). It's one of a long list of long-standing requests. The best (perhaps even only!) thing you can do is what Vladmir shows. That can be simplified a little too:

Parallel.png

4 replies

24-Ruby III
January 5, 2012

Hello!

Please attach your Mathcad worksheet.

1-Visitor
January 5, 2012

I'd rather not upload the entire worksheet, so I've posted an image of the relevant formulas.

1-Visitor
January 5, 2012

Functions for 2, 3, and 4 elements:

untitled.PNG

24-Ruby III
January 5, 2012
RichardJ19-TanzaniteAnswer
19-Tanzanite
January 5, 2012

Sorry, but it is not possible to create user defined functions that take a variable number of arguments (even though there are built-in functions that take a variable number of arguments). It's one of a long list of long-standing requests. The best (perhaps even only!) thing you can do is what Vladmir shows. That can be simplified a little too:

Parallel.png

24-Ruby IV
January 5, 2012

May be so:

ohm.png

19-Tanzanite
January 5, 2012

Yes, including ORIGIN is a very good idea! Necessary, in fact, because I always use ORIGIN=0, and my version of the function would in fact not work correctly in any of my own worksheets

24-Ruby IV
January 7, 2012

We can have in some built-in function of Mathcad 15 (find, min, max, stack etc) n-arguments.

One example max(1, 2, 3, 4, 5, 6...) = ...

The max n is 50 (n = 1-50)

Do you know how much max arguments can we have in same functions in Mathcad Prime? I know more than 50 or 256.

Do you have a full list of this functions with var n of arguments?