Average Error: 26.5 → 0.9
Time: 10.2s
Precision: 64
\[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.3588681134848813 \cdot 10^{42} \lor \neg \left(x \le 1.38820808193331251 \cdot 10^{24}\right):\\ \;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\\ \end{array}\]
\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}
\begin{array}{l}
\mathbf{if}\;x \le -1.3588681134848813 \cdot 10^{42} \lor \neg \left(x \le 1.38820808193331251 \cdot 10^{24}\right):\\
\;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\\

\end{array}
double code(double x, double y, double z) {
	return (((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));
}
double code(double x, double y, double z) {
	double temp;
	if (((x <= -1.3588681134848813e+42) || !(x <= 1.3882080819333125e+24))) {
		temp = (((y / pow(x, 2.0)) + (4.16438922228 * x)) - 110.1139242984811);
	} else {
		temp = (((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));
	}
	return temp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.5
Target0.5
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;x \lt -3.3261287258700048 \cdot 10^{62}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{elif}\;x \lt 9.4299917145546727 \cdot 10^{55}:\\ \;\;\;\;\frac{x - 2}{1} \cdot \frac{\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z}{\left(\left(263.50507472100003 \cdot x + \left(43.3400022514000014 \cdot \left(x \cdot x\right) + x \cdot \left(x \cdot x\right)\right)\right) + 313.399215894\right) \cdot x + 47.066876606000001}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x \cdot x} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.3588681134848813e+42 or 1.3882080819333125e+24 < x

    1. Initial program 59.0

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
    2. Simplified54.9

      \[\leadsto \color{blue}{\frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity54.9

      \[\leadsto \frac{x - 2}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}{\color{blue}{1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    5. Applied add-sqr-sqrt54.9

      \[\leadsto \frac{x - 2}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}}{1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\]
    6. Applied times-frac54.9

      \[\leadsto \frac{x - 2}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    7. Applied *-un-lft-identity54.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - 2\right)}}{\frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\]
    8. Applied times-frac54.9

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{1}} \cdot \frac{x - 2}{\frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}}\]
    9. Simplified54.9

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}} \cdot \frac{x - 2}{\frac{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x + 43.3400022514000014, x, 263.50507472100003\right), x, 313.399215894\right), x, 47.066876606000001\right)}}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 4.16438922227999964, 78.6994924154000017\right), x, 137.51941641600001\right), x, y\right), x, z\right)}}\]
    10. Taylor expanded around inf 1.1

      \[\leadsto \color{blue}{\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109}\]

    if -1.3588681134848813e+42 < x < 1.3882080819333125e+24

    1. Initial program 0.7

      \[\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.3588681134848813 \cdot 10^{42} \lor \neg \left(x \le 1.38820808193331251 \cdot 10^{24}\right):\\ \;\;\;\;\left(\frac{y}{{x}^{2}} + 4.16438922227999964 \cdot x\right) - 110.11392429848109\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - 2\right) \cdot \left(\left(\left(\left(x \cdot 4.16438922227999964 + 78.6994924154000017\right) \cdot x + 137.51941641600001\right) \cdot x + y\right) \cdot x + z\right)}{\left(\left(\left(x + 43.3400022514000014\right) \cdot x + 263.50507472100003\right) \cdot x + 313.399215894\right) \cdot x + 47.066876606000001}\\ \end{array}\]

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< x -3.326128725870005e+62) (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811) (if (< x 9.429991714554673e+55) (* (/ (- x 2) 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) (+ (* (+ (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x) y) x) z)) (+ (* (+ (* (+ (* (+ x 43.3400022514) x) 263.505074721) x) 313.399215894) x) 47.066876606)))