Average Error: 34.1 → 6.0
Time: 3.5m
Precision: 64
Internal Precision: 1408
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1.0 - z\right) - b\right)}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le 3.439646959482297 \cdot 10^{-130}:\\
\;\;\;\;\left(x \cdot e^{\left(\log \left(1.0 - z\right) - b\right) \cdot a}\right) \cdot {\left(\left(z + \frac{1}{2} \cdot \left(z \cdot {t}^{2}\right)\right) - z \cdot t\right)}^{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot e^{\left(\log \left(1.0 - z\right) - b\right) \cdot a}\right) \cdot {\left(\frac{z}{e^{t}}\right)}^{y}\\
\end{array}\]
Target
| Original | 34.1 |
|---|
| Target | 34.1 |
|---|
| Herbie | 6.0 |
|---|
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1.0 - z\right) - b\right)}\]
Derivation
- Split input into 2 regimes
if y < 3.439646959482297e-130
Initial program 34.1
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1.0 - z\right) - b\right)}\]
Applied simplify30.2
\[\leadsto \color{blue}{\left(x \cdot {\left(\frac{1.0 - z}{e^{b}}\right)}^{a}\right) \cdot {\left(\frac{z}{e^{t}}\right)}^{y}}\]
Taylor expanded around 0 17.5
\[\leadsto \left(x \cdot {\left(\frac{1.0 - z}{e^{b}}\right)}^{a}\right) \cdot {\color{blue}{\left(\left(z + \frac{1}{2} \cdot \left(z \cdot {t}^{2}\right)\right) - z \cdot t\right)}}^{y}\]
- Using strategy
rm Applied add-exp-log17.5
\[\leadsto \left(x \cdot {\left(\frac{\color{blue}{e^{\log \left(1.0 - z\right)}}}{e^{b}}\right)}^{a}\right) \cdot {\left(\left(z + \frac{1}{2} \cdot \left(z \cdot {t}^{2}\right)\right) - z \cdot t\right)}^{y}\]
Applied div-exp17.5
\[\leadsto \left(x \cdot {\color{blue}{\left(e^{\log \left(1.0 - z\right) - b}\right)}}^{a}\right) \cdot {\left(\left(z + \frac{1}{2} \cdot \left(z \cdot {t}^{2}\right)\right) - z \cdot t\right)}^{y}\]
Applied pow-exp9.4
\[\leadsto \left(x \cdot \color{blue}{e^{\left(\log \left(1.0 - z\right) - b\right) \cdot a}}\right) \cdot {\left(\left(z + \frac{1}{2} \cdot \left(z \cdot {t}^{2}\right)\right) - z \cdot t\right)}^{y}\]
if 3.439646959482297e-130 < y
Initial program 34.1
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1.0 - z\right) - b\right)}\]
Applied simplify7.1
\[\leadsto \color{blue}{\left(x \cdot {\left(\frac{1.0 - z}{e^{b}}\right)}^{a}\right) \cdot {\left(\frac{z}{e^{t}}\right)}^{y}}\]
- Using strategy
rm Applied add-exp-log7.1
\[\leadsto \left(x \cdot {\left(\frac{\color{blue}{e^{\log \left(1.0 - z\right)}}}{e^{b}}\right)}^{a}\right) \cdot {\left(\frac{z}{e^{t}}\right)}^{y}\]
Applied div-exp7.1
\[\leadsto \left(x \cdot {\color{blue}{\left(e^{\log \left(1.0 - z\right) - b}\right)}}^{a}\right) \cdot {\left(\frac{z}{e^{t}}\right)}^{y}\]
Applied pow-exp1.1
\[\leadsto \left(x \cdot \color{blue}{e^{\left(\log \left(1.0 - z\right) - b\right) \cdot a}}\right) \cdot {\left(\frac{z}{e^{t}}\right)}^{y}\]
- 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 t a b)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
:herbie-target
(* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b)))))
(* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))