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

1-Newbie

## Symbolically identifying solutions to max/min function

I feel like this may be a simple question to answer, but I'm having a hard time finding a solution on my own, so hopefully someone can help me with this.

I've been exploring symbolic/explicit calculation for a short while now, but keep running into a wall when I want to display the solution to a max or min function as the actual variable and not the numeric solution. What I keep getting is:

a:=1

b:=2

c:=3

min(a,b,c) -> min(a,b,c),

min(a,b,c) -> min(1,2,3), or

min(a,b,c) -> 1

What I would like to be able to see is:

min(a,b,c) -> a

If someone could point me in the right direction as to what keywords to use to achieve this, I'd really appreciate it.

7 REPLIES 7
24-Ruby IV
(To:ptc-4438750)

Don't think that "explicit" or any other keyword will do what you want as soon as we have concrete values for a,b,c.

Not exactly what you demanded but the best I could come up is

1-Newbie
(To:Werner_E)

So there's no way to symbolically evaluate a max/min function once you have concrete values?

For my current project I'm looking to evaluate different safety ratios, so a,b,c and are actually (Vd1/Vr1), (Vd2/Vr2), (Vd3/Vr3), which will need numerical values in order to compare them.

1-Newbie
(To:ptc-4438750)

In case anyone else is looking for this as well, this is a method that works, but looks ugly as sin and will only get worse with the more variables you're comparing.

It's a series of "if" statements that compare the number/variable to the solution of the max/min function. It works fine if no units are involved (in the case of comparing Vd/Vr as "lbf" cancel out), but otherwise if comparing numbers with units, you have to remove them in order to avoid an error ("value must be scalar"). Here's a sample of both cases:

24-Ruby IV
(To:ptc-4438750)

Clever workaround.

Still not as easy and natural as it should be, but could using vectors be an option?

15-Moonstone
(To:Werner_E)

Here's yet another (cumbersome) way of indicating which variable is the minimum .

Alan

1-Newbie
(To:Werner_E)

Nice.

Your version is a lot more compact, and is easily modifiable for more/less values. Only restriction seems to be variables that rely on numerical subscript, but I think you can get around that by including some "substitute" lines after "explicit,minidx" if you had to use letters instead (i.e. substitute, V[sub]cb = V[sub]1)

24-Ruby IV
(To:ptc-4438750)

Not sure how the substitute would interact with the (rather sensible) explicit, but maybe worth a try.

Announcements
Check out the latest