Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Finding which combination of values gives the high...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

08-13-2019
06:04 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-13-2019
06:04 PM

Finding which combination of values gives the highest/lowest result

I've been scouring the forums for a while now and I'm starting to come to the conclusion that either my question is so simple that nobody else needs to ask how to do it or that it just can't be done. Put simply, I'm trying to find out how I can get MathCAD (using Prime 4.0) to return the highest or lowest result of a function given a list of possible input variables.

For example, if I have a simple function:

f(x,y) = x + y^2

and a list of possible values for x and y:

x = [3, -6, 2] y = [2, 3, -3]

How can I get MathCAD to output the largest (11) or smallest (-2) result?

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

08-13-2019
07:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-13-2019
07:12 PM

Here are a few ways to do it

But I would prefer to write a utility function to do the job

Sometimes it may be a problem to have the function create the full matrix, so a different, a little bit more lengthy approach would do the same job:

Worksheet in format P4 attached

EDIT: I just remembered that there was a similar, but more coomplicated/demanding question here in this thread

There you can find a minmax function which will work with function with more than just two arguments. Not sure which version the file attached there is, but I guess the thread is old enough so the file should open with P4.

5 REPLIES 5

08-13-2019
07:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-13-2019
07:12 PM

Here are a few ways to do it

But I would prefer to write a utility function to do the job

Sometimes it may be a problem to have the function create the full matrix, so a different, a little bit more lengthy approach would do the same job:

Worksheet in format P4 attached

EDIT: I just remembered that there was a similar, but more coomplicated/demanding question here in this thread

There you can find a minmax function which will work with function with more than just two arguments. Not sure which version the file attached there is, but I guess the thread is old enough so the file should open with P4.

08-14-2019
01:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-14-2019
01:09 PM

That is probably the most thorough and well-documented answer I've ever received! Thank you so much!

05-10-2021
12:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-10-2021
12:57 PM

In the 2nd line in your 1st screenshot, why is there a "T" superscript on the bracketed numbers for x and y

05-10-2021
02:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-10-2021
02:00 PM

That 'superscript T' is the transpose operator.

It turns a row vector into a column vector:

a column vector into a row vector:

and exchanges rows and columns in a matrix:

Success!

Luc

05-10-2021
05:40 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-10-2021
05:40 PM

@AL_9913769 wrote:

Luc already explained the meaning of the transpose operator.

The question about the "why" I used it is simply answered: To save vertical space. It makes the worksheet looking a bit cleaner when a column vector is defined as a transposed row vector 😉

The same goes for the evaluation/display of a vector. Often its preferable to display it transposed in a row rather then the vector display taking up multiple lines in the text.