Average Error: 6.4 → 2.1
Time: 18.9s
Precision: 64
Internal precision: 128
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -1.3209176906660093 \cdot 10^{-170}:\\
\;\;\;\;\frac{z - x}{\frac{t}{y}} + x\\
\mathbf{if}\;x \le 2.0581640871701446 \cdot 10^{-95}:\\
\;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t} \cdot \left(z - x\right) + x\\
\end{array}\]
Target
| Original | 6.4 |
| Comparison | 2.0 |
| Herbie | 2.1 |
\[ x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]
Derivation
- Split input into 3 regimes.
-
if x < -1.3209176906660093e-170
Initial program 6.7
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
Applied taylor 6.7
\[\leadsto x + \left(\frac{y \cdot z}{t} - \frac{y \cdot x}{t}\right)\]
Taylor expanded around 0 6.7
\[\leadsto x + \color{blue}{\left(\frac{y \cdot z}{t} - \frac{y \cdot x}{t}\right)}\]
Applied simplify 0.7
\[\leadsto \color{blue}{\frac{z - x}{\frac{t}{y}} + x}\]
if -1.3209176906660093e-170 < x < 2.0581640871701446e-95
Initial program 5.2
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
if 2.0581640871701446e-95 < x
Initial program 7.3
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
Applied taylor 7.3
\[\leadsto x + \frac{y \cdot z - y \cdot x}{t}\]
Taylor expanded around 0 7.3
\[\leadsto x + \frac{\color{blue}{y \cdot z - y \cdot x}}{t}\]
Applied simplify 0.3
\[\leadsto \color{blue}{\frac{y}{t} \cdot \left(z - x\right) + x}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3177963436 888103403 3093071472 2189699733 2284055197 1183748214)'
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))