Average Error: 5.0 → 1.8
Time: 5.0m
Precision: 64
Internal Precision: 384
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \le -5.38122143438205 \cdot 10^{-09}:\\
\;\;\;\;\left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(\left(t \cdot \left(\left(18.0 \cdot x\right) \cdot y\right)\right) \cdot z - 27.0 \cdot \left(k \cdot j\right)\right)\\
\mathbf{if}\;z \le 1.620828576697051 \cdot 10^{-140}:\\
\;\;\;\;\left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(\left(\sqrt[3]{t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right)} \cdot \sqrt[3]{t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right)}\right) \cdot \sqrt[3]{t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right)} - 27.0 \cdot \left(k \cdot j\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(18.0 \cdot \left(z \cdot \left(y \cdot \left(t \cdot x\right)\right)\right) - 27.0 \cdot \left(k \cdot j\right)\right)\\
\end{array}\]
Target
| Original | 5.0 |
|---|
| Target | 1.4 |
|---|
| Herbie | 1.8 |
|---|
\[\begin{array}{l}
\mathbf{if}\;t \lt -1.6210815397541398 \cdot 10^{-69}:\\
\;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\
\mathbf{if}\;t \lt 165.68027943805222:\\
\;\;\;\;\left(\left(18.0 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) + \left(c \cdot b - 27.0 \cdot \left(k \cdot j\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\
\end{array}\]
Derivation
- Split input into 3 regimes
if z < -5.38122143438205e-09
Initial program 6.0
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
Applied simplify11.3
\[\leadsto \color{blue}{\left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right) - 27.0 \cdot \left(k \cdot j\right)\right)}\]
- Using strategy
rm Applied associate-*r*5.9
\[\leadsto \left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(t \cdot \color{blue}{\left(\left(\left(18.0 \cdot x\right) \cdot y\right) \cdot z\right)} - 27.0 \cdot \left(k \cdot j\right)\right)\]
- Using strategy
rm Applied associate-*r*1.8
\[\leadsto \left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(\color{blue}{\left(t \cdot \left(\left(18.0 \cdot x\right) \cdot y\right)\right) \cdot z} - 27.0 \cdot \left(k \cdot j\right)\right)\]
if -5.38122143438205e-09 < z < 1.620828576697051e-140
Initial program 4.1
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
Applied simplify0.6
\[\leadsto \color{blue}{\left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right) - 27.0 \cdot \left(k \cdot j\right)\right)}\]
- Using strategy
rm Applied add-cube-cbrt0.7
\[\leadsto \left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(\color{blue}{\left(\sqrt[3]{t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right)} \cdot \sqrt[3]{t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right)}\right) \cdot \sqrt[3]{t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right)}} - 27.0 \cdot \left(k \cdot j\right)\right)\]
if 1.620828576697051e-140 < z
Initial program 5.4
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
Applied simplify8.1
\[\leadsto \color{blue}{\left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(t \cdot \left(\left(18.0 \cdot x\right) \cdot \left(y \cdot z\right)\right) - 27.0 \cdot \left(k \cdot j\right)\right)}\]
Taylor expanded around inf 3.2
\[\leadsto \left(b \cdot c - 4.0 \cdot \left(x \cdot i + a \cdot t\right)\right) + \left(\color{blue}{18.0 \cdot \left(z \cdot \left(y \cdot \left(t \cdot x\right)\right)\right)} - 27.0 \cdot \left(k \cdot j\right)\right)\]
- Recombined 3 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 c i j k)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, E"
:herbie-target
(if (< t -1.6210815397541398e-69) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b))) (if (< t 165.68027943805222) (+ (- (* (* 18.0 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4.0)) (- (* c b) (* 27.0 (* k j)))) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b)))))
(- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))