Average Error: 3.2 → 0.3
Time: 34.5s
Precision: 64
Internal precision: 128
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -2.6282574721209407 \cdot 10^{+98}:\\
\;\;\;\;x \cdot 1.0 + z \cdot \left(x \cdot \left(y - 1.0\right)\right)\\
\mathbf{if}\;z \le 1.1178113736376001 \cdot 10^{+57}:\\
\;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.0 + \left(z \cdot x\right) \cdot \left(y - 1.0\right)\\
\end{array}\]
Target
| Original | 3.2 |
| Comparison | 0.2 |
| Herbie | 0.3 |
\[ \begin{array}{l}
\mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\end{array} \]
Derivation
- Split input into 3 regimes.
-
if z < -2.6282574721209407e+98
Initial program 11.7
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
Applied taylor 0.1
\[\leadsto \left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)\]
Taylor expanded around inf 0.1
\[\leadsto \color{blue}{\left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{x \cdot 1.0 + \left(z \cdot x\right) \cdot \left(y - 1.0\right)}\]
- Using strategy
rm
Applied associate-*l* 0.1
\[\leadsto x \cdot 1.0 + \color{blue}{z \cdot \left(x \cdot \left(y - 1.0\right)\right)}\]
if -2.6282574721209407e+98 < z < 1.1178113736376001e+57
Initial program 0.4
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
if 1.1178113736376001e+57 < z
Initial program 9.8
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
Applied taylor 0.1
\[\leadsto \left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)\]
Taylor expanded around inf 0.1
\[\leadsto \color{blue}{\left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{x \cdot 1.0 + \left(z \cdot x\right) \cdot \left(y - 1.0\right)}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1263240699 3960646907 392216334 637456588 434149341 1861915064)'
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))