Average Error: 9.5 → 0.1
Time: 34.2s
Precision: 64
Internal precision: 128
\[\frac{x}{y} + \frac{2.0 + \left(z \cdot 2.0\right) \cdot \left(1.0 - t\right)}{t \cdot z}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -5.070143915338624 \cdot 10^{-32}:\\
\;\;\;\;\frac{{\left(\frac{2.0}{z}\right)}^2 - {2.0}^2}{t \cdot \left(\frac{2.0}{z} - 2.0\right)} - \left(2.0 - \frac{x}{y}\right)\\
\mathbf{if}\;z \le 9.246126022216187 \cdot 10^{-153}:\\
\;\;\;\;\frac{x}{y} + \frac{2.0 + \left(z \cdot 2.0\right) \cdot \left(1.0 - t\right)}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\frac{2.0}{z}\right)}^2 - {2.0}^2}{t \cdot \left(\frac{2.0}{z} - 2.0\right)} - \left(2.0 - \frac{x}{y}\right)\\
\end{array}\]
Target
| Original | 9.5 |
| Comparison | 0.1 |
| Herbie | 0.1 |
\[ \frac{\frac{2.0}{z} + 2.0}{t} - \left(2.0 - \frac{x}{y}\right) \]
Derivation
- Split input into 2 regimes.
-
if z < -5.070143915338624e-32 or 9.246126022216187e-153 < z
Initial program 13.2
\[\frac{x}{y} + \frac{2.0 + \left(z \cdot 2.0\right) \cdot \left(1.0 - t\right)}{t \cdot z}\]
Applied taylor 0.0
\[\leadsto \frac{x}{y} + \left(\left(2.0 \cdot \frac{1}{t} + 2.0 \cdot \frac{1}{t \cdot z}\right) - 2.0\right)\]
Taylor expanded around 0 0.0
\[\leadsto \frac{x}{y} + \color{blue}{\left(\left(2.0 \cdot \frac{1}{t} + 2.0 \cdot \frac{1}{t \cdot z}\right) - 2.0\right)}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\frac{\frac{2.0}{z} + 2.0}{t} - \left(2.0 - \frac{x}{y}\right)}\]
- Using strategy
rm
Applied flip-+ 0.0
\[\leadsto \frac{\color{blue}{\frac{{\left(\frac{2.0}{z}\right)}^2 - {2.0}^2}{\frac{2.0}{z} - 2.0}}}{t} - \left(2.0 - \frac{x}{y}\right)\]
Applied associate-/l/ 0.1
\[\leadsto \color{blue}{\frac{{\left(\frac{2.0}{z}\right)}^2 - {2.0}^2}{t \cdot \left(\frac{2.0}{z} - 2.0\right)}} - \left(2.0 - \frac{x}{y}\right)\]
if -5.070143915338624e-32 < z < 9.246126022216187e-153
Initial program 0.2
\[\frac{x}{y} + \frac{2.0 + \left(z \cdot 2.0\right) \cdot \left(1.0 - t\right)}{t \cdot z}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3458829069 2671581822 1264888354 3098179637 198302602 327550699)'
(FPCore (x y z t)
:name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
:target
(- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y)))
(+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))