1. ## min(max(C,D),A)... again

Although I posted a very similar problem before, I must resubmit.

I have this function where A,C,D are real numbers and C< A:

min(max(C,D),A)

I need to decompose algebrically this into NOT-NESTED min/max
functions with NO absolute values.

Something like: max(???) + max(???) or any combination of min/max.

2. ## mid(A,C,D)

Perhaps I can better formulate my problem.

I have three real numbers A, C, D with C < A.

How can I write an algebraic function that gives the median number,
i.e. mid(A,C,D)?

The min(max(C,D),A) works but I must get rid of the nested function.
And also, I cannot use absolute values.

Note that, being C < A, there are only three cases to consider:

1) D < C < A (mid = C)
2) C < D < A (mid = D)
3) C < A < D (mid = A)

Therefore, the mid numer is one of these two: max(D,C) or min(A,D).

But don't see how to progress and come out with the right one.

PLS HELP!

A+C+D-min(A,C,D)-min(A,C,D).

4. ## Resolved

Actually, given the posted constraints, I resolved it:

mid(A,C,D) = min( max(C, D), A) = max(C, D) + min(A, D) – D

That's what I really needed!

5. Originally Posted by ebaines