Average Error: 5.9 → 1.1
Time: 1.1m
Precision: 64
Internal Precision: 384
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \le -5.273243369695188 \cdot 10^{-34}:\\
\;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\
\mathbf{if}\;a \le 1.4912760646799497 \cdot 10^{-24}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{z}{\frac{a}{y}} - \frac{t}{\frac{a}{y}}\right) + x\\
\end{array}\]
Target
| Original | 5.9 |
|---|
| Target | 0.7 |
|---|
| Herbie | 1.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \lt -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\
\mathbf{if}\;y \lt 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\
\end{array}\]
Derivation
- Split input into 3 regimes
if a < -5.273243369695188e-34
Initial program 8.6
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
- Using strategy
rm Applied associate-/l*0.6
\[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z - t}}}\]
if -5.273243369695188e-34 < a < 1.4912760646799497e-24
Initial program 0.8
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
if 1.4912760646799497e-24 < a
Initial program 8.0
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
Taylor expanded around 0 8.1
\[\leadsto x + \frac{\color{blue}{z \cdot y - y \cdot t}}{a}\]
Applied simplify1.8
\[\leadsto \color{blue}{\frac{z - t}{\frac{a}{y}} + x}\]
- Using strategy
rm Applied div-sub1.8
\[\leadsto \color{blue}{\left(\frac{z}{\frac{a}{y}} - \frac{t}{\frac{a}{y}}\right)} + x\]
- 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)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:herbie-target
(if (< y -1.0761266216389975e-10) (+ x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))
(+ x (/ (* y (- z t)) a)))