Average Error: 3.3 → 0.5
Time: 1.3m
Precision: 64
Internal Precision: 384
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \le -1.2018128981968222 \cdot 10^{-61}:\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\\
\mathbf{if}\;z \le 1.0607797663860536 \cdot 10^{-27}:\\
\;\;\;\;x - \frac{0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\\
\end{array}\]
Target
| Original | 3.3 |
|---|
| Target | 1.9 |
|---|
| Herbie | 0.5 |
|---|
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{\frac{t}{z \cdot 3.0}}{y}\]
Derivation
- Split input into 3 regimes
if z < -1.2018128981968222e-61
Initial program 0.6
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
- Using strategy
rm Applied associate-/r*0.6
\[\leadsto \left(x - \color{blue}{\frac{\frac{y}{z}}{3.0}}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
if -1.2018128981968222e-61 < z < 1.0607797663860536e-27
Initial program 11.6
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
Taylor expanded around 0 11.6
\[\leadsto \color{blue}{\left(x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\right) - 0.3333333333333333 \cdot \frac{y}{z}}\]
Applied simplify0.2
\[\leadsto \color{blue}{x - \frac{0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)}\]
if 1.0607797663860536e-27 < z
Initial program 0.5
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
- Using strategy
rm Applied associate-/r*0.5
\[\leadsto \left(x - \color{blue}{\frac{\frac{y}{z}}{3.0}}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))