Average Error: 26.0 → 0.3
Time: 7.0m
Precision: 64
Internal Precision: 384
\[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -2.7093826433504146 \cdot 10^{+43}:\\
\;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922228 \cdot x\right) - 110.1139242984811\\
\mathbf{if}\;x \le 4.256900496243778 \cdot 10^{+44}:\\
\;\;\;\;\frac{x - 2.0}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922228 \cdot x\right) - 110.1139242984811\\
\end{array}\]
Target
| Original | 26.0 |
|---|
| Target | 0.6 |
|---|
| Herbie | 0.3 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \lt -3.326128725870005 \cdot 10^{+62}:\\
\;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\
\mathbf{if}\;x \lt 9.429991714554673 \cdot 10^{+55}:\\
\;\;\;\;\frac{x - 2.0}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.505074721 \cdot x + \left(43.3400022514 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\
\end{array}\]
Derivation
- Split input into 2 regimes
if x < -2.7093826433504146e+43 or 4.256900496243778e+44 < x
Initial program 58.7
\[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
Taylor expanded around inf 0.0
\[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922228 \cdot x\right) - 110.1139242984811}\]
if -2.7093826433504146e+43 < x < 4.256900496243778e+44
Initial program 1.0
\[\frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}\]
- Using strategy
rm Applied *-un-lft-identity1.0
\[\leadsto \frac{\left(x - 2.0\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z\right)}{\color{blue}{1 \cdot \left(\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606\right)}}\]
Applied times-frac0.4
\[\leadsto \color{blue}{\frac{x - 2.0}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922228 + 78.6994924154\right) \cdot x + 137.519416416\right) \cdot x + y\right) \cdot x + z}{\left(\left(\left(x + 43.3400022514\right) \cdot x + 263.505074721\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606}}\]
- Recombined 2 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)
:name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"
:herbie-target
(if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2.0) 1) (/ (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z) (+ (* (+ (+ (* 263.505074721 x) (+ (* 43.3400022514 (* x x)) (* x (* x x)))) 313.399215894) x) 47.066876606))) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811)))
(/ (* (- x 2.0) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))