Average Error: 17.0 → 7.4
Time: 33.8s
Precision: 64
Internal precision: 128
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;t \le -1.4870814148066594 \cdot 10^{+93}:\\
\;\;\;\;\frac{z \cdot y}{t} + x\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - \left(z - t\right) \cdot \frac{y}{a - t}\right)\\
\end{array}\]
Target
| Original | 17.0 |
| Comparison | 9.6 |
| Herbie | 7.4 |
\[ \begin{array}{l}
\mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.3664970889390727 \cdot 10^{-07}:\\
\;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\
\mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt 1.4754293444577233 \cdot 10^{-239}:\\
\;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if t < -1.4870814148066594e+93
Initial program 32.0
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
Applied taylor 5.9
\[\leadsto \frac{z \cdot y}{t} + x\]
Taylor expanded around inf 5.9
\[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
if -1.4870814148066594e+93 < t
Initial program 13.5
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
- Using strategy
rm
Applied associate-/l* 9.8
\[\leadsto \left(x + y\right) - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\]
- Using strategy
rm
Applied associate--l+ 7.6
\[\leadsto \color{blue}{x + \left(y - \frac{z - t}{\frac{a - t}{y}}\right)}\]
- Using strategy
rm
Applied div-inv 8.2
\[\leadsto x + \left(y - \color{blue}{\left(z - t\right) \cdot \frac{1}{\frac{a - t}{y}}}\right)\]
Applied simplify 7.7
\[\leadsto x + \left(y - \left(z - t\right) \cdot \color{blue}{\frac{y}{a - t}}\right)\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1106470522 307320770 2981921710 3117656402 3903939474 1142827929)'
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:target
(if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y))))
(- (+ x y) (/ (* (- z t) y) (- a t))))