Average Error: 19.7 → 0.0
Time: 1.6m
Precision: 64
Internal precision: 128
\[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -103.50161844807882:\\
\;\;\;\;\left(0.07512208616047561 - \frac{0.40462203869992125}{z}\right) \cdot \frac{y}{z} + \left(y \cdot 0.0692910599291889 + x\right)\\
\mathbf{if}\;z \le 85.36504497937187:\\
\;\;\;\;\left(x + \left(0.0007936505811533753 \cdot y\right) \cdot {z}^2\right) - y \cdot \left(z \cdot 0.0027777777775172263 - 0.08333333333333323\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.07512208616047561 - \frac{0.40462203869992125}{z}\right) \cdot \frac{y}{z} + \left(y \cdot 0.0692910599291889 + x\right)\\
\end{array}\]
Target
| Original | 19.7 |
| Comparison | 0.4 |
| Herbie | 0.0 |
\[ \begin{array}{l}
\mathbf{if}\;z \lt -8120153.652456675:\\
\;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y - \left(\frac{0.40462203869992125 \cdot y}{{z}^2} - x\right)\\
\mathbf{if}\;z \lt 6.576118972787377 \cdot 10^{+20}:\\
\;\;\;\;x + \left(y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)\right) \cdot \frac{1}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y - \left(\frac{0.40462203869992125 \cdot y}{{z}^2} - x\right)\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if z < -103.50161844807882 or 85.36504497937187 < z
Initial program 38.7
\[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\]
Applied taylor 0.0
\[\leadsto x + \left(\left(0.0692910599291889 \cdot y + 0.07512208616047561 \cdot \frac{y}{z}\right) - 0.40462203869992125 \cdot \frac{y}{{z}^2}\right)\]
Taylor expanded around inf 0.0
\[\leadsto x + \color{blue}{\left(\left(0.0692910599291889 \cdot y + 0.07512208616047561 \cdot \frac{y}{z}\right) - 0.40462203869992125 \cdot \frac{y}{{z}^2}\right)}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\left(0.07512208616047561 - \frac{0.40462203869992125}{z}\right) \cdot \frac{y}{z} + \left(y \cdot 0.0692910599291889 + x\right)}\]
if -103.50161844807882 < z < 85.36504497937187
Initial program 0.5
\[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\]
Applied taylor 0.0
\[\leadsto x + \left(\left(0.0007936505811533753 \cdot \left(y \cdot {z}^2\right) + 0.08333333333333323 \cdot y\right) - 0.0027777777775172263 \cdot \left(y \cdot z\right)\right)\]
Taylor expanded around 0 0.0
\[\leadsto x + \color{blue}{\left(\left(0.0007936505811533753 \cdot \left(y \cdot {z}^2\right) + 0.08333333333333323 \cdot y\right) - 0.0027777777775172263 \cdot \left(y \cdot z\right)\right)}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\left(x + \left(y \cdot z\right) \cdot \left(z \cdot 0.0007936505811533753\right)\right) - y \cdot \left(z \cdot 0.0027777777775172263 - 0.08333333333333323\right)}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\left(x + \left(0.0007936505811533753 \cdot y\right) \cdot {z}^2\right)} - y \cdot \left(z \cdot 0.0027777777775172263 - 0.08333333333333323\right)\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3601024 2862105533 1084549748 1545582408 1356355419 1818752773)'
(FPCore (x y z)
:name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, B"
:target
(if (< z -8120153.652456675) (- (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) (- (/ (* 0.40462203869992125 y) (sqr z)) x)) (if (< z 6.576118972787377e+20) (+ x (* (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (/ 1 (+ (* (+ z 6.012459259764103) z) 3.350343815022304)))) (- (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) (- (/ (* 0.40462203869992125 y) (sqr z)) x))))
(+ x (/ (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))