Average Error: 5.9 → 1.5
Time: 31.6s
Precision: 64
Internal precision: 128
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;y \le -2.930244047323321 \cdot 10^{+18}:\\
\;\;\;\;x - y \cdot \frac{z - t}{a}\\
\mathbf{if}\;y \le 8.166728288538418 \cdot 10^{-294}:\\
\;\;\;\;x - \frac{1}{\frac{a}{y \cdot \left(z - t\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{a} \cdot \left(z - t\right)\\
\end{array}\]
Target
| Original | 5.9 |
| Comparison | 0.7 |
| Herbie | 1.5 |
\[ \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 y < -2.930244047323321e+18
Initial program 16.2
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
Applied taylor 16.3
\[\leadsto x - \left(\frac{y \cdot z}{a} - \frac{t \cdot y}{a}\right)\]
Taylor expanded around 0 16.3
\[\leadsto x - \color{blue}{\left(\frac{y \cdot z}{a} - \frac{t \cdot y}{a}\right)}\]
Applied simplify 3.6
\[\leadsto \color{blue}{x - \frac{y}{a} \cdot \left(z - t\right)}\]
- Using strategy
rm
Applied div-inv 3.7
\[\leadsto x - \color{blue}{\left(y \cdot \frac{1}{a}\right)} \cdot \left(z - t\right)\]
Applied associate-*l* 0.8
\[\leadsto x - \color{blue}{y \cdot \left(\frac{1}{a} \cdot \left(z - t\right)\right)}\]
Applied simplify 0.7
\[\leadsto x - y \cdot \color{blue}{\frac{z - t}{a}}\]
if -2.930244047323321e+18 < y < 8.166728288538418e-294
Initial program 0.5
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
- Using strategy
rm
Applied clear-num 0.5
\[\leadsto x - \color{blue}{\frac{1}{\frac{a}{y \cdot \left(z - t\right)}}}\]
if 8.166728288538418e-294 < y
Initial program 5.9
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
Applied taylor 5.9
\[\leadsto x - \left(\frac{y \cdot z}{a} - \frac{t \cdot y}{a}\right)\]
Taylor expanded around 0 5.9
\[\leadsto x - \color{blue}{\left(\frac{y \cdot z}{a} - \frac{t \cdot y}{a}\right)}\]
Applied simplify 2.5
\[\leadsto \color{blue}{x - \frac{y}{a} \cdot \left(z - t\right)}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3663857942 159484730 3367875525 4143958929 2381550403 3748760641)'
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
: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)))