Average Error: 0.0 → 0.0
Time: 26.9s
Precision: 64
$\begin{array}{l} \mathbf{if}\;x \lt 0.5:\\ \;\;\;\;L + \left(H - L\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;H - \left(H - L\right) \cdot \left(1 - x\right)\\ \end{array}$
$L + \left(H - L\right) \cdot x$
\begin{array}{l}
\mathbf{if}\;x \lt 0.5:\\
\;\;\;\;L + \left(H - L\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;H - \left(H - L\right) \cdot \left(1 - x\right)\\

\end{array}
L + \left(H - L\right) \cdot x
double f(double x, double L, double H) {
double r49895414 = x;
double r49895415 = 0.5;
bool r49895416 = r49895414 < r49895415;
double r49895417 = L;
double r49895418 = H;
double r49895419 = r49895418 - r49895417;
double r49895420 = r49895419 * r49895414;
double r49895421 = r49895417 + r49895420;
double r49895422 = 1.0;
double r49895423 = r49895422 - r49895414;
double r49895424 = r49895419 * r49895423;
double r49895425 = r49895418 - r49895424;
double r49895426 = r49895416 ? r49895421 : r49895425;
return r49895426;
}


double f(double x, double L, double H) {
double r49895427 = L;
double r49895428 = H;
double r49895429 = r49895428 - r49895427;
double r49895430 = x;
double r49895431 = r49895429 * r49895430;
double r49895432 = r49895427 + r49895431;
return r49895432;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 0.0

$\begin{array}{l} \mathbf{if}\;x \lt 0.5:\\ \;\;\;\;L + \left(H - L\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;H - \left(H - L\right) \cdot \left(1 - x\right)\\ \end{array}$
2. Simplified0.0

$\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;x \lt 0.5:\\ \;\;\;\;L + \left(H - L\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;L + \left(H - L\right) \cdot x\\ \end{array}}$
3. Final simplification0.0

$\leadsto L + \left(H - L\right) \cdot x$

# Reproduce

herbie shell --seed 1
(FPCore (x L H)
:name "x<0.5 ? L+(H-L)*x : H-(H-L)*(1-x)"
(if (< x 0.5) (+ L (* (- H L) x)) (- H (* (- H L) (- 1 x)))))