# Smooth approximation of a five phase linear function

I am looking for a smooth (continuous differentiable) approximation of the following five-phased linear function: $$P(U, R, P_r) = \begin{cases} R(U_{\max} - U) + R(U_{up} - U_{\max}) + P_r; & U \geq U_{\max}\\ R(U_{up} - U) + P_r; & U_{up} < U < U_{\max}\\ P_r; & U_{low} \leq U \leq U_{up}\\ R(U_{low} - U) + P_r; & U_{\min} < U < U_{low}\\ R(U_{\min} - U) + R(U_{low} - U_{\min}) + P_r; & U \leq U_{\min}\\ \end{cases},$$ Here $$U_{\max} \geq U_{up} \geq U_{low} \geq U_{\min}$$ are the breakpoints and bounds of the variable $$U$$. $$P_r$$ and $$R$$ are a given setpoint value and slope of the line respectively. Also, $$P$$ has bounds as $$P_{\min} \leq P \leq P_{\max}$$.

I am trying to define these constraints as nested max functions and then apply the smooth approximation. Such that: $$F(x) = \max\{0,x\}, \quad for \quad x \in \mathbb{R}$$

By picking any positive number $$\epsilon > 0$$:

$$F^\epsilon(x) = \epsilon \ln \left(1+ \exp(x/\epsilon)\right), \quad for \quad x \in \mathbb{R}$$

with bound verification:

$$F^\epsilon(x) - \epsilon \ln2 \leq F(x) \leq F^\epsilon(x)$$

• If I further simplify the function as: $$P(U, R, P_r) = \begin{cases} R(U_{up} - U) + P_r; & U_{up} < U \leq U_{max}\\ P_r; & U_{low} \leq U \leq U_{up}\\ R(U_{low} - U) + P_r; & U_{min} \leq U < U_{low}\\ \end{cases},$$ Feb 2 at 0:35