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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

4-Participant

## Absolute Value

I am having an issue with finding the max value of positive and negative values.  I want it to always pick the highest integer but to have it's sign remain the same.

For instance,

x=10, y=15, z=-20 are my numbers calculated that

t:=550*[max(x,y,z)] -p is depended on.

if I do r:= max(x,y,z) it will state that r=15 when I need it to pick the worse case for an equation it will be integrated in later on.

if I do r:= max(IxI,IyI,IzI) it will state r=20 but not -20 cause of the absolute value.

Is there a different approach I can do where I wouldn't have to use solve for t for each single case and pick the max absolute value of all three?

ACCEPTED SOLUTION

Accepted Solutions
23-Emerald III
(To:jenny29)

Define your own function maxabs:

Success!
Luc

6 REPLIES 6
21-Topaz I
(To:jenny29)

max(|x|,|y|,|z|)=max(x,y,z)

This is fallible but works most of the time

if test is true you have a positive number
if test is false you have a negative number

23-Emerald III
(To:jenny29)

Define your own function maxabs:

Success!
Luc

9-Granite
(To:LucMeekes)

Hi Luc. I guess that your solution is correct, just a margin note: If x = max(A) then -x = min(-A).

Best regards.

Alvaro.

25-Diamond I
(To:LucMeekes)

Here are my 2 cents

4-Participant
(To:LucMeekes)

When I do that, it tells me that "these values must all be of one type."

I am not sure what that means.

4-Participant
(To:jenny29)

Actually I was able to make it work with your method, Luc. thank you.  My issue was that I was mixing {2,1} variables with {1,1} when what I needed to do first is find the maxabs of the {2,1} and then combine them all in one matrix to find the total maxabs of (B).  It's a bit longer the steps but it gives the correct solution.

Announcements

Top Tags