Average Error: 13.9 → 4.0
Time: 47.4s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \le -2.623960079892894 \cdot 10^{+119}:\\
\;\;\;\;\left(\frac{\frac{y}{z}}{z} \cdot x\right) \cdot \frac{1}{1.0 + z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{x}{z}}{z \cdot \left(z + 1.0\right)}\\
\end{array}\]
Target
| Original | 13.9 |
|---|
| Target | 4.0 |
|---|
| Herbie | 4.0 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt 249.6182814532307:\\
\;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\
\end{array}\]
Derivation
- Split input into 2 regimes
if z < -2.623960079892894e+119
Initial program 10.9
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}\]
Taylor expanded around 0 56.3
\[\leadsto \frac{x \cdot y}{\color{blue}{1.0 \cdot {z}^{2} + {z}^{3}}}\]
Applied simplify1.1
\[\leadsto \color{blue}{\frac{\frac{y}{z}}{z} \cdot \frac{x}{1.0 + z}}\]
- Using strategy
rm Applied div-inv1.2
\[\leadsto \frac{\frac{y}{z}}{z} \cdot \color{blue}{\left(x \cdot \frac{1}{1.0 + z}\right)}\]
Applied associate-*r*1.1
\[\leadsto \color{blue}{\left(\frac{\frac{y}{z}}{z} \cdot x\right) \cdot \frac{1}{1.0 + z}}\]
if -2.623960079892894e+119 < z
Initial program 14.7
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}\]
Taylor expanded around 0 14.7
\[\leadsto \frac{x \cdot y}{\color{blue}{1.0 \cdot {z}^{2} + {z}^{3}}}\]
Applied simplify6.5
\[\leadsto \color{blue}{\frac{\frac{y}{z}}{z} \cdot \frac{x}{1.0 + z}}\]
- Using strategy
rm Applied div-inv6.6
\[\leadsto \color{blue}{\left(\frac{y}{z} \cdot \frac{1}{z}\right)} \cdot \frac{x}{1.0 + z}\]
Applied associate-*l*3.9
\[\leadsto \color{blue}{\frac{y}{z} \cdot \left(\frac{1}{z} \cdot \frac{x}{1.0 + z}\right)}\]
Applied simplify3.8
\[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{\frac{x}{z}}{z + 1.0}}\]
- Using strategy
rm Applied frac-times4.8
\[\leadsto \color{blue}{\frac{y \cdot \frac{x}{z}}{z \cdot \left(z + 1.0\right)}}\]
- Recombined 2 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)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:herbie-target
(if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1 z)) x) z))
(/ (* x y) (* (* z z) (+ z 1.0))))