Skip to main content
4-Participant
March 7, 2026
Question

how to evaluate multiple inputs without vectorization

  • March 7, 2026
  • 2 replies
  • 234 views

Hi my current workflow involves input a few variables on the first page of mathcad worksheet, then jump to the last page to see the output results after lengthy calculations. I have to tweak the inputs so that the output can meet or at least is close to certain value range. 

This is not efficient, so I am thinking if the worksheet can take in multiple sets (say, about 100) of input, read one set at a time, do the evaluation, then write the output result somewhere/in some file; then it will jump to the next iteration.

I do not want to rewrite the input as vectors, because this will require rewrite all formulas using vectorize operators. 

Thank you .

 

2 replies

25-Diamond I
March 7, 2026

It's a long standing wish of the user community that a worksheet could be turned into a function. This would be exactly what you seem to need.

Unfortunately Mathcad and Prime provide no means to do so.

 

Your subject is "how to evaluate multiple inputs without vectorization". Why 'without vectorization'?

Basically vectorization is exactly what you could use: Provide all inputs as vectors of the same size, rewrite your calculations if necessary to accommodate vectors as inputs instead of scalar variables (this could require to use vectorization in the calculations) and so you would have your output(s) as result vector(s) the same size as the inputs.
There are certainly some pitfalls here and there, but these depend on the specific calculations being performed in your spreadsheet, so no specific tips can be given here.

For more help you would have to attach a small demo worksheet to show what you have in mind. You would have to put the file in zip archive as this forum does not allow direct attachment of Prime or Mathcad files.

 

But .... you actually ar not interested in 100 results returned for 100 input combinations. You ar just interested ind the one combination which comes closest to a specific goal, right?

This might(?) be a job for a solve block, maybe using 'minerr'. 

 

Here a simple example of what i am talking about:

grafik.png

 

You could also add additional constraints or 'weight' a constraint if its important that it is fulfilled (see attached sheet).

All constraints in a solve block are 'soft' constraints, though.

 

4-Participant
March 7, 2026


well, because the intermediate calculations were not written by me, and I found that one of the intermediate variable is already a matrix; I am not sure if vectorization can pass without any error there.

I am thinking of using API, though I have never tried before. Will that work?

 

25-Diamond I
March 7, 2026

The calculations themselves using vectors and matrices is one of the cases which I called 'pitfalls' in my answer above. It possibly could be solved using additional auxiliary functions. How exactly would have to be examined on a individual and specific situation.

Here again a simple example - the product of the two inputs should be multiplied with the lower left element of a provided 2x2 matrix. A function should do this and use both inputs as well as the matrix as its arguments:

grafik.png

I have no experience in using the API but as I understand you would have to build a wrapper in another app (Python or an Excel sheet) which calls the Prime sheet with different arguments. A scripted Prime control could also be used to use the API. When I played around with it, I found it of limited use and difficult to apply - but then this also could be because of my lack of experience...

An using the API you still would have to decide yourself which input set fits best and could not use Primes algorithm to minimize the error.

12-Amethyst
March 7, 2026

I don't work with Prime a lot, but it sounds like one way to get what you want is to insert a collapsible area immediately after your data entry, then cut/paste all the intervening calculations into the collapsible area. Once collapsed, your results should then show immediately below your data entry. The sheet should work just as it does now, except you won't need to navigate back and forth to see inputs and outputs (assuming everything works as I would expect).

 

Lou 

25-Diamond I
March 7, 2026

I fear that the question was not how to avoid scrolling but rather how to make the calculations not just for one set but for a couple of sets of input values in one go to be able to compare them and chose the most appropriate set.