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!