Average Error: 3.3 → 1.1
Time: 2.6m
Precision: 64
Internal Precision: 384
\[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -6.798242451867544 \cdot 10^{-115}:\\
\;\;\;\;\left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27.0\right) \cdot b\\
\mathbf{if}\;y \le 4.7969606968471655 \cdot 10^{-108}:\\
\;\;\;\;\left(27.0 \cdot \left(b \cdot a\right) + 2.0 \cdot x\right) - 9.0 \cdot \left(\left(z \cdot y\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2.0 - \left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27.0\right) \cdot b\\
\end{array}\]
Target
| Original | 3.3 |
|---|
| Target | 2.4 |
|---|
| Herbie | 1.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \lt 7.590524218811189 \cdot 10^{-161}:\\
\;\;\;\;\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + a \cdot \left(27.0 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\\
\end{array}\]
Derivation
- Split input into 2 regimes
if y < -6.798242451867544e-115 or 4.7969606968471655e-108 < y
Initial program 5.0
\[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
- Using strategy
rm Applied associate-*l*1.4
\[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
if -6.798242451867544e-115 < y < 4.7969606968471655e-108
Initial program 0.6
\[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
Taylor expanded around inf 0.5
\[\leadsto \color{blue}{\left(27.0 \cdot \left(b \cdot a\right) + 2.0 \cdot x\right) - 9.0 \cdot \left(z \cdot \left(y \cdot t\right)\right)}\]
- Using strategy
rm Applied associate-*r*0.6
\[\leadsto \left(27.0 \cdot \left(b \cdot a\right) + 2.0 \cdot x\right) - 9.0 \cdot \color{blue}{\left(\left(z \cdot y\right) \cdot t\right)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A"
:herbie-target
(if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))
(+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))