Average Error: 3.4 → 0.4
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 -8.643245025974954 \cdot 10^{-54}:\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\\
\mathbf{if}\;z \le 9.281941309943775 \cdot 10^{-28}:\\
\;\;\;\;x - \frac{0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - 0.3333333333333333 \cdot \frac{y}{z}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\\
\end{array}\]
Target
| Original | 3.4 |
|---|
| Target | 1.9 |
|---|
| Herbie | 0.4 |
|---|
\[\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 < -8.643245025974954e-54
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}\]
if -8.643245025974954e-54 < z < 9.281941309943775e-28
Initial program 11.8
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
Taylor expanded around 0 11.8
\[\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 9.281941309943775e-28 < z
Initial program 0.5
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
Taylor expanded around 0 0.5
\[\leadsto \left(x - \color{blue}{0.3333333333333333 \cdot \frac{y}{z}}\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 +o reduce:binary-search
(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))))