Average Error: 16.7 → 9.5
Time: 2.0m
Precision: 64
Internal Precision: 1920
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \le -4.193402137698978 \cdot 10^{-168}:\\
\;\;\;\;\left(x + y\right) - \frac{\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}}{1} \cdot \frac{\sqrt[3]{z - t}}{\frac{a - t}{y}}\\
\mathbf{if}\;a \le 2.179660528406852 \cdot 10^{-239}:\\
\;\;\;\;\frac{z \cdot y}{t} + x\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) - \left(z - t\right) \cdot \frac{y}{a - t}\\
\end{array}\]
Target
| Original | 16.7 |
|---|
| Target | 8.8 |
|---|
| Herbie | 9.5 |
|---|
\[\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 3 regimes
if a < -4.193402137698978e-168
Initial program 15.6
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
- Using strategy
rm Applied associate-/l*9.9
\[\leadsto \left(x + y\right) - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\]
- Using strategy
rm Applied *-un-lft-identity9.9
\[\leadsto \left(x + y\right) - \frac{z - t}{\color{blue}{1 \cdot \frac{a - t}{y}}}\]
Applied add-cube-cbrt10.0
\[\leadsto \left(x + y\right) - \frac{\color{blue}{\left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right) \cdot \sqrt[3]{z - t}}}{1 \cdot \frac{a - t}{y}}\]
Applied times-frac10.0
\[\leadsto \left(x + y\right) - \color{blue}{\frac{\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}}{1} \cdot \frac{\sqrt[3]{z - t}}{\frac{a - t}{y}}}\]
if -4.193402137698978e-168 < a < 2.179660528406852e-239
Initial program 23.6
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
Taylor expanded around inf 3.8
\[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
if 2.179660528406852e-239 < a
Initial program 15.5
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
Taylor expanded around inf 15.5
\[\leadsto \left(x + y\right) - \frac{\color{blue}{z \cdot y - y \cdot t}}{a - t}\]
Applied simplify10.9
\[\leadsto \color{blue}{\left(y + x\right) - \left(z - t\right) \cdot \frac{y}{a - t}}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:herbie-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))))