Average Error: 32.7 → 17.6
Time: 25.4s
Precision: 64
${\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \left(h - \ell\right) + \ell$
$\begin{array}{l} \mathbf{if}\;\ell \le -8.871732447447531999119543546783605262891 \cdot 10^{-88}:\\ \;\;\;\;h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\left(\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}\right) \cdot \frac{\sqrt[3]{r - \ell}}{h - \ell}\right)}^{p} \cdot \ell\right)\\ \mathbf{elif}\;\ell \le 3.158856803397546206799279296528649745594 \cdot 10^{-224}:\\ \;\;\;\;\left({\left(\frac{\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}\right)}^{p} \cdot {\left(\frac{\sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell}}\right)}^{p}\right) \cdot \left(h - \ell\right) + \ell\\ \mathbf{else}:\\ \;\;\;\;h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\frac{\frac{r - \ell}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}}{\sqrt[3]{h - \ell}}\right)}^{p} \cdot \ell\right)\\ \end{array}$
{\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \left(h - \ell\right) + \ell
\begin{array}{l}
\mathbf{if}\;\ell \le -8.871732447447531999119543546783605262891 \cdot 10^{-88}:\\
\;\;\;\;h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\left(\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}\right) \cdot \frac{\sqrt[3]{r - \ell}}{h - \ell}\right)}^{p} \cdot \ell\right)\\

\mathbf{elif}\;\ell \le 3.158856803397546206799279296528649745594 \cdot 10^{-224}:\\
\;\;\;\;\left({\left(\frac{\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}\right)}^{p} \cdot {\left(\frac{\sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell}}\right)}^{p}\right) \cdot \left(h - \ell\right) + \ell\\

\mathbf{else}:\\
\;\;\;\;h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\frac{\frac{r - \ell}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}}{\sqrt[3]{h - \ell}}\right)}^{p} \cdot \ell\right)\\

\end{array}
double f(double r, double l, double h, double p) {
double r277989 = r;
double r277990 = l;
double r277991 = r277989 - r277990;
double r277992 = h;
double r277993 = r277992 - r277990;
double r277994 = r277991 / r277993;
double r277995 = p;
double r277996 = pow(r277994, r277995);
double r277997 = r277996 * r277993;
double r277998 = r277997 + r277990;
return r277998;
}


double f(double r, double l, double h, double p) {
double r277999 = l;
double r278000 = -8.871732447447532e-88;
bool r278001 = r277999 <= r278000;
double r278002 = h;
double r278003 = r;
double r278004 = r278003 - r277999;
double r278005 = r278002 - r277999;
double r278006 = r278004 / r278005;
double r278007 = p;
double r278008 = pow(r278006, r278007);
double r278009 = r278002 * r278008;
double r278010 = cbrt(r278004);
double r278011 = r278010 * r278010;
double r278012 = r278010 / r278005;
double r278013 = r278011 * r278012;
double r278014 = pow(r278013, r278007);
double r278015 = r278014 * r277999;
double r278016 = r277999 - r278015;
double r278017 = r278009 + r278016;
double r278018 = 3.158856803397546e-224;
bool r278019 = r277999 <= r278018;
double r278020 = cbrt(r278005);
double r278021 = r278020 * r278020;
double r278022 = r278011 / r278021;
double r278023 = pow(r278022, r278007);
double r278024 = r278010 / r278020;
double r278025 = pow(r278024, r278007);
double r278026 = r278023 * r278025;
double r278027 = r278026 * r278005;
double r278028 = r278027 + r277999;
double r278029 = r278004 / r278021;
double r278030 = r278029 / r278020;
double r278031 = pow(r278030, r278007);
double r278032 = r278031 * r277999;
double r278033 = r277999 - r278032;
double r278034 = r278009 + r278033;
double r278035 = r278019 ? r278028 : r278034;
double r278036 = r278001 ? r278017 : r278035;
return r278036;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if l < -8.871732447447532e-88

1. Initial program 41.1

${\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \left(h - \ell\right) + \ell$
2. Using strategy rm
3. Applied sub-neg41.1

$\leadsto {\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \color{blue}{\left(h + \left(-\ell\right)\right)} + \ell$
4. Applied distribute-rgt-in41.1

$\leadsto \color{blue}{\left(h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(-\ell\right) \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p}\right)} + \ell$
5. Applied associate-+l+23.8

$\leadsto \color{blue}{h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\left(-\ell\right) \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \ell\right)}$
6. Simplified23.8

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \color{blue}{\left(\ell - {\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \ell\right)}$
7. Using strategy rm
8. Applied *-un-lft-identity23.8

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\frac{r - \ell}{\color{blue}{1 \cdot \left(h - \ell\right)}}\right)}^{p} \cdot \ell\right)$

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\frac{\color{blue}{\left(\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}\right) \cdot \sqrt[3]{r - \ell}}}{1 \cdot \left(h - \ell\right)}\right)}^{p} \cdot \ell\right)$
10. Applied times-frac22.1

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\color{blue}{\left(\frac{\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}}{1} \cdot \frac{\sqrt[3]{r - \ell}}{h - \ell}\right)}}^{p} \cdot \ell\right)$
11. Simplified22.1

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\color{blue}{\left(\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}\right)} \cdot \frac{\sqrt[3]{r - \ell}}{h - \ell}\right)}^{p} \cdot \ell\right)$

## if -8.871732447447532e-88 < l < 3.158856803397546e-224

1. Initial program 10.6

${\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \left(h - \ell\right) + \ell$
2. Using strategy rm

$\leadsto {\left(\frac{r - \ell}{\color{blue}{\left(\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}\right) \cdot \sqrt[3]{h - \ell}}}\right)}^{p} \cdot \left(h - \ell\right) + \ell$

$\leadsto {\left(\frac{\color{blue}{\left(\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}\right) \cdot \sqrt[3]{r - \ell}}}{\left(\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}\right) \cdot \sqrt[3]{h - \ell}}\right)}^{p} \cdot \left(h - \ell\right) + \ell$
5. Applied times-frac10.6

$\leadsto {\color{blue}{\left(\frac{\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}} \cdot \frac{\sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell}}\right)}}^{p} \cdot \left(h - \ell\right) + \ell$
6. Applied unpow-prod-down6.1

$\leadsto \color{blue}{\left({\left(\frac{\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}\right)}^{p} \cdot {\left(\frac{\sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell}}\right)}^{p}\right)} \cdot \left(h - \ell\right) + \ell$

## if 3.158856803397546e-224 < l

1. Initial program 36.6

${\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \left(h - \ell\right) + \ell$
2. Using strategy rm
3. Applied sub-neg36.6

$\leadsto {\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \color{blue}{\left(h + \left(-\ell\right)\right)} + \ell$
4. Applied distribute-rgt-in36.6

$\leadsto \color{blue}{\left(h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(-\ell\right) \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p}\right)} + \ell$
5. Applied associate-+l+20.9

$\leadsto \color{blue}{h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\left(-\ell\right) \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \ell\right)}$
6. Simplified20.9

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \color{blue}{\left(\ell - {\left(\frac{r - \ell}{h - \ell}\right)}^{p} \cdot \ell\right)}$
7. Using strategy rm

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\frac{r - \ell}{\color{blue}{\left(\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}\right) \cdot \sqrt[3]{h - \ell}}}\right)}^{p} \cdot \ell\right)$
9. Applied associate-/r*19.5

$\leadsto h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\color{blue}{\left(\frac{\frac{r - \ell}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}}{\sqrt[3]{h - \ell}}\right)}}^{p} \cdot \ell\right)$
3. Recombined 3 regimes into one program.
4. Final simplification17.6

$\leadsto \begin{array}{l} \mathbf{if}\;\ell \le -8.871732447447531999119543546783605262891 \cdot 10^{-88}:\\ \;\;\;\;h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\left(\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}\right) \cdot \frac{\sqrt[3]{r - \ell}}{h - \ell}\right)}^{p} \cdot \ell\right)\\ \mathbf{elif}\;\ell \le 3.158856803397546206799279296528649745594 \cdot 10^{-224}:\\ \;\;\;\;\left({\left(\frac{\sqrt[3]{r - \ell} \cdot \sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}\right)}^{p} \cdot {\left(\frac{\sqrt[3]{r - \ell}}{\sqrt[3]{h - \ell}}\right)}^{p}\right) \cdot \left(h - \ell\right) + \ell\\ \mathbf{else}:\\ \;\;\;\;h \cdot {\left(\frac{r - \ell}{h - \ell}\right)}^{p} + \left(\ell - {\left(\frac{\frac{r - \ell}{\sqrt[3]{h - \ell} \cdot \sqrt[3]{h - \ell}}}{\sqrt[3]{h - \ell}}\right)}^{p} \cdot \ell\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (r l h p)
:name "(pow(((r - l) / (h - l)), p) * (h - l)) + l"
:precision binary64
(+ (* (pow (/ (- r l) (- h l)) p) (- h l)) l))