Average Error: 14.5 → 6.1
Time: 45.6s
Precision: 64
Internal Precision: 384
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -2.58053419571785 \cdot 10^{+22}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{if}\;y \le 9.019566302352389 \cdot 10^{-119}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{if}\;y \le 5.127878477553548 \cdot 10^{+249}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}\]
Target
| Original | 14.5 |
|---|
| Target | 1.4 |
|---|
| Herbie | 6.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.20672205123045 \cdot 10^{+245}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.907522236933906 \cdot 10^{-275}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.658954423153415 \cdot 10^{-65}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt 2.0087180502407133 \cdot 10^{+217}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\end{array}\]
Derivation
- Split input into 4 regimes
if y < -2.58053419571785e+22
Initial program 17.5
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
Applied simplify7.4
\[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
Taylor expanded around 0 8.4
\[\leadsto \color{blue}{\frac{y \cdot x}{z}}\]
if -2.58053419571785e+22 < y < 9.019566302352389e-119
Initial program 12.9
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
Applied simplify6.2
\[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
- Using strategy
rm Applied div-inv6.3
\[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{y}}}\]
Applied simplify5.7
\[\leadsto x \cdot \color{blue}{\frac{y}{z}}\]
if 9.019566302352389e-119 < y < 5.127878477553548e+249
Initial program 14.3
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
Applied simplify4.5
\[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
Taylor expanded around 0 4.8
\[\leadsto \color{blue}{\frac{y \cdot x}{z}}\]
if 5.127878477553548e+249 < y
Initial program 24.4
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
Applied simplify14.2
\[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
- Using strategy
rm Applied associate-/r/11.4
\[\leadsto \color{blue}{\frac{x}{z} \cdot y}\]
- Recombined 4 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)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:herbie-target
(if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))
(* x (/ (* (/ y z) t) t)))