Average Error: 3.4 → 0.8
Time: 33.8s
Precision: 64
Internal precision: 128
\[\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}\;z \le -2.2705645183745452 \cdot 10^{-110}:\\
\;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(z \cdot \left(y \cdot t\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\\
\mathbf{if}\;z \le 3.312219404886358 \cdot 10^{+35}:\\
\;\;\;\;\left(x \cdot 2.0 - \left(9.0 \cdot \left(z \cdot y\right)\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(z \cdot \left(y \cdot t\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\\
\end{array}\]
Target
| Original | 3.4 |
| Comparison | 2.4 |
| Herbie | 0.8 |
\[ \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 z < -2.2705645183745452e-110 or 3.312219404886358e+35 < z
Initial program 6.3
\[\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\]
Applied taylor 1.1
\[\leadsto \left(x \cdot 2.0 - 9.0 \cdot \left(z \cdot \left(y \cdot t\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\]
Taylor expanded around inf 1.1
\[\leadsto \left(x \cdot 2.0 - \color{blue}{9.0 \cdot \left(z \cdot \left(y \cdot t\right)\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
if -2.2705645183745452e-110 < z < 3.312219404886358e+35
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\]
Applied taylor 0.5
\[\leadsto \left(x \cdot 2.0 - \left(9.0 \cdot \left(z \cdot y\right)\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
Taylor expanded around 0 0.5
\[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(9.0 \cdot \left(z \cdot y\right)\right)} \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1949458275 2014334845 2071894301 1864689860 3065213165 1681962525)'
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A"
: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)))