Is there a more efficient way to write max(A*x,min(y,B*x))?

57 Views Asked by At

Suppose we know that $B > A$. Right now,

$$\max\{A \cdot x,\min(y,B\cdot x)\}$$

requires two multiplication operations to evaluate.

Is there a way to rewrite this using max/min notation such that I only need one multiplication operation (and no other floating point operations such as division) to evaluate?

EDIT: Updated this to place an additional constraint.

1

There are 1 best solutions below

2
On

You could do

$$x \cdot max(A,min(y/x,B))$$

but now of course you have a division operation. It is only 1 multiplication operator though :)