Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C

Percentage Accurate: 59.1% → 95.2%
Time: 3.9s
Alternatives: 4
Speedup: 0.5×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\begin{array}{l} \\ \frac{\left(x - 2\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} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (/
  (*
   (- 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) {
	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);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - 2.0d0) * ((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z)) / (((((((x + 43.3400022514d0) * x) + 263.505074721d0) * x) + 313.399215894d0) * x) + 47.066876606d0)
end function
public static 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);
}
def code(x, y, 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)
function code(x, y, z)
	return Float64(Float64(Float64(x - 2.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606))
end
function tmp = code(x, y, z)
	tmp = ((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);
end
code[x_, y_, z_] := N[(N[(N[(x - 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(x + 43.3400022514), $MachinePrecision] * x), $MachinePrecision] + 263.505074721), $MachinePrecision] * x), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(x - 2\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}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 59.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(x - 2\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} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (/
  (*
   (- 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) {
	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);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - 2.0d0) * ((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z)) / (((((((x + 43.3400022514d0) * x) + 263.505074721d0) * x) + 313.399215894d0) * x) + 47.066876606d0)
end function
public static 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);
}
def code(x, y, 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)
function code(x, y, z)
	return Float64(Float64(Float64(x - 2.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606))
end
function tmp = code(x, y, z)
	tmp = ((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);
end
code[x_, y_, z_] := N[(N[(N[(x - 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(x + 43.3400022514), $MachinePrecision] * x), $MachinePrecision] + 263.505074721), $MachinePrecision] * x), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(x - 2\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}
\end{array}

Alternative 1: 95.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(x - 2\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}\\ \mathbf{if}\;t\_0 \leq 2 \cdot 10^{+280}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot 4.16438922228\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0
         (/
          (*
           (- 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))))
   (if (<= t_0 2e+280) t_0 (* x 4.16438922228))))
double code(double x, double y, double z) {
	double t_0 = ((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 tmp;
	if (t_0 <= 2e+280) {
		tmp = t_0;
	} else {
		tmp = x * 4.16438922228;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((x - 2.0d0) * ((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z)) / (((((((x + 43.3400022514d0) * x) + 263.505074721d0) * x) + 313.399215894d0) * x) + 47.066876606d0)
    if (t_0 <= 2d+280) then
        tmp = t_0
    else
        tmp = x * 4.16438922228d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((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 tmp;
	if (t_0 <= 2e+280) {
		tmp = t_0;
	} else {
		tmp = x * 4.16438922228;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((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)
	tmp = 0
	if t_0 <= 2e+280:
		tmp = t_0
	else:
		tmp = x * 4.16438922228
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(x - 2.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(x + 43.3400022514) * x) + 263.505074721) * x) + 313.399215894) * x) + 47.066876606))
	tmp = 0.0
	if (t_0 <= 2e+280)
		tmp = t_0;
	else
		tmp = Float64(x * 4.16438922228);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((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);
	tmp = 0.0;
	if (t_0 <= 2e+280)
		tmp = t_0;
	else
		tmp = x * 4.16438922228;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(x + 43.3400022514), $MachinePrecision] * x), $MachinePrecision] + 263.505074721), $MachinePrecision] * x), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+280], t$95$0, N[(x * 4.16438922228), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(x - 2\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}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+280}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;x \cdot 4.16438922228\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (-.f64 x #s(literal 2 binary64)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x #s(literal 104109730557/25000000000 binary64)) #s(literal 393497462077/5000000000 binary64)) x) #s(literal 4297481763/31250000 binary64)) x) y) x) z)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 x #s(literal 216700011257/5000000000 binary64)) x) #s(literal 263505074721/1000000000 binary64)) x) #s(literal 156699607947/500000000 binary64)) x) #s(literal 23533438303/500000000 binary64))) < 2.0000000000000001e280

    1. Initial program 98.9%

      \[\frac{\left(x - 2\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} \]
    2. Add Preprocessing

    if 2.0000000000000001e280 < (/.f64 (*.f64 (-.f64 x #s(literal 2 binary64)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x #s(literal 104109730557/25000000000 binary64)) #s(literal 393497462077/5000000000 binary64)) x) #s(literal 4297481763/31250000 binary64)) x) y) x) z)) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 x #s(literal 216700011257/5000000000 binary64)) x) #s(literal 263505074721/1000000000 binary64)) x) #s(literal 156699607947/500000000 binary64)) x) #s(literal 23533438303/500000000 binary64)))

    1. Initial program 0.2%

      \[\frac{\left(x - 2\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} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-1000000000}{23533438303} \cdot z + x \cdot \left(\left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) + x \cdot \left(\frac{500000000}{23533438303} \cdot \left(y - \frac{4297481763}{15625000}\right) - \left(\frac{-131752537360500000000}{553822718361107519809} \cdot z + \frac{156699607947}{23533438303} \cdot \left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)\right)\right)\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)} \]
    4. Applied rewrites16.8%

      \[\leadsto \color{blue}{x - 2} \]
    5. Taylor expanded in x around 0

      \[\leadsto -2 \]
    6. Applied rewrites95.5%

      \[\leadsto x \cdot \color{blue}{4.16438922228} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 50.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1600000000:\\ \;\;\;\;x \cdot 4.16438922228\\ \mathbf{elif}\;x \leq 680:\\ \;\;\;\;\left(x - 2\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)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 4.16438922228\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1600000000.0)
   (* x 4.16438922228)
   (if (<= x 680.0)
     (*
      (- x 2.0)
      (+
       (*
        (+
         (* (+ (* (+ (* x 4.16438922228) 78.6994924154) x) 137.519416416) x)
         y)
        x)
       z))
     (* x 4.16438922228))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1600000000.0) {
		tmp = x * 4.16438922228;
	} else if (x <= 680.0) {
		tmp = (x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z);
	} else {
		tmp = x * 4.16438922228;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-1600000000.0d0)) then
        tmp = x * 4.16438922228d0
    else if (x <= 680.0d0) then
        tmp = (x - 2.0d0) * ((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z)
    else
        tmp = x * 4.16438922228d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1600000000.0) {
		tmp = x * 4.16438922228;
	} else if (x <= 680.0) {
		tmp = (x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z);
	} else {
		tmp = x * 4.16438922228;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1600000000.0:
		tmp = x * 4.16438922228
	elif x <= 680.0:
		tmp = (x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z)
	else:
		tmp = x * 4.16438922228
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1600000000.0)
		tmp = Float64(x * 4.16438922228);
	elseif (x <= 680.0)
		tmp = Float64(Float64(x - 2.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z));
	else
		tmp = Float64(x * 4.16438922228);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1600000000.0)
		tmp = x * 4.16438922228;
	elseif (x <= 680.0)
		tmp = (x - 2.0) * ((((((((x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z);
	else
		tmp = x * 4.16438922228;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1600000000.0], N[(x * 4.16438922228), $MachinePrecision], If[LessEqual[x, 680.0], N[(N[(x - 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(x * 4.16438922228), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1600000000:\\
\;\;\;\;x \cdot 4.16438922228\\

\mathbf{elif}\;x \leq 680:\\
\;\;\;\;\left(x - 2\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)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 4.16438922228\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6e9 or 680 < x

    1. Initial program 19.0%

      \[\frac{\left(x - 2\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} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-1000000000}{23533438303} \cdot z + x \cdot \left(\left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) + x \cdot \left(\frac{500000000}{23533438303} \cdot \left(y - \frac{4297481763}{15625000}\right) - \left(\frac{-131752537360500000000}{553822718361107519809} \cdot z + \frac{156699607947}{23533438303} \cdot \left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)\right)\right)\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)} \]
    4. Applied rewrites16.1%

      \[\leadsto \color{blue}{x - 2} \]
    5. Taylor expanded in x around 0

      \[\leadsto -2 \]
    6. Applied rewrites89.2%

      \[\leadsto x \cdot \color{blue}{4.16438922228} \]

    if -1.6e9 < x < 680

    1. Initial program 99.6%

      \[\frac{\left(x - 2\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} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-1000000000}{23533438303} \cdot z + x \cdot \left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)} \]
    4. Applied rewrites14.6%

      \[\leadsto \color{blue}{\left(x - 2\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)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 44.9% accurate, 13.2× speedup?

\[\begin{array}{l} \\ x \cdot 4.16438922228 \end{array} \]
(FPCore (x y z) :precision binary64 (* x 4.16438922228))
double code(double x, double y, double z) {
	return x * 4.16438922228;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x * 4.16438922228d0
end function
public static double code(double x, double y, double z) {
	return x * 4.16438922228;
}
def code(x, y, z):
	return x * 4.16438922228
function code(x, y, z)
	return Float64(x * 4.16438922228)
end
function tmp = code(x, y, z)
	tmp = x * 4.16438922228;
end
code[x_, y_, z_] := N[(x * 4.16438922228), $MachinePrecision]
\begin{array}{l}

\\
x \cdot 4.16438922228
\end{array}
Derivation
  1. Initial program 59.9%

    \[\frac{\left(x - 2\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} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{-1000000000}{23533438303} \cdot z + x \cdot \left(\left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) + x \cdot \left(\frac{500000000}{23533438303} \cdot \left(y - \frac{4297481763}{15625000}\right) - \left(\frac{-131752537360500000000}{553822718361107519809} \cdot z + \frac{156699607947}{23533438303} \cdot \left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)\right)\right)\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)} \]
  4. Applied rewrites9.7%

    \[\leadsto \color{blue}{x - 2} \]
  5. Taylor expanded in x around 0

    \[\leadsto -2 \]
  6. Applied rewrites45.8%

    \[\leadsto x \cdot \color{blue}{4.16438922228} \]
  7. Add Preprocessing

Alternative 4: 9.7% accurate, 19.8× speedup?

\[\begin{array}{l} \\ x - 2 \end{array} \]
(FPCore (x y z) :precision binary64 (- x 2.0))
double code(double x, double y, double z) {
	return x - 2.0;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x - 2.0d0
end function
public static double code(double x, double y, double z) {
	return x - 2.0;
}
def code(x, y, z):
	return x - 2.0
function code(x, y, z)
	return Float64(x - 2.0)
end
function tmp = code(x, y, z)
	tmp = x - 2.0;
end
code[x_, y_, z_] := N[(x - 2.0), $MachinePrecision]
\begin{array}{l}

\\
x - 2
\end{array}
Derivation
  1. Initial program 59.9%

    \[\frac{\left(x - 2\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} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{-1000000000}{23533438303} \cdot z + x \cdot \left(\left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) + x \cdot \left(\frac{500000000}{23533438303} \cdot \left(y - \frac{4297481763}{15625000}\right) - \left(\frac{-131752537360500000000}{553822718361107519809} \cdot z + \frac{156699607947}{23533438303} \cdot \left(\frac{500000000}{23533438303} \cdot \left(z + -2 \cdot y\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)\right)\right)\right) - \frac{-156699607947000000000}{553822718361107519809} \cdot z\right)} \]
  4. Applied rewrites9.7%

    \[\leadsto \color{blue}{x - 2} \]
  5. Add Preprocessing

Developer Target 1: 98.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\ \mathbf{if}\;x < -3.326128725870005 \cdot 10^{+62}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x < 9.429991714554673 \cdot 10^{+55}:\\ \;\;\;\;\frac{x - 2}{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}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (+ (/ y (* x x)) (* 4.16438922228 x)) 110.1139242984811)))
   (if (< x -3.326128725870005e+62)
     t_0
     (if (< x 9.429991714554673e+55)
       (*
        (/ (- x 2.0) 1.0)
        (/
         (+
          (*
           (+
            (* (+ (* (+ (* 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)))
       t_0))))
double code(double x, double y, double z) {
	double t_0 = ((y / (x * x)) + (4.16438922228 * x)) - 110.1139242984811;
	double tmp;
	if (x < -3.326128725870005e+62) {
		tmp = t_0;
	} else if (x < 9.429991714554673e+55) {
		tmp = ((x - 2.0) / 1.0) * (((((((((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));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((y / (x * x)) + (4.16438922228d0 * x)) - 110.1139242984811d0
    if (x < (-3.326128725870005d+62)) then
        tmp = t_0
    else if (x < 9.429991714554673d+55) then
        tmp = ((x - 2.0d0) / 1.0d0) * (((((((((x * 4.16438922228d0) + 78.6994924154d0) * x) + 137.519416416d0) * x) + y) * x) + z) / (((((263.505074721d0 * x) + ((43.3400022514d0 * (x * x)) + (x * (x * x)))) + 313.399215894d0) * x) + 47.066876606d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((y / (x * x)) + (4.16438922228 * x)) - 110.1139242984811;
	double tmp;
	if (x < -3.326128725870005e+62) {
		tmp = t_0;
	} else if (x < 9.429991714554673e+55) {
		tmp = ((x - 2.0) / 1.0) * (((((((((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));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((y / (x * x)) + (4.16438922228 * x)) - 110.1139242984811
	tmp = 0
	if x < -3.326128725870005e+62:
		tmp = t_0
	elif x < 9.429991714554673e+55:
		tmp = ((x - 2.0) / 1.0) * (((((((((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))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(y / Float64(x * x)) + Float64(4.16438922228 * x)) - 110.1139242984811)
	tmp = 0.0
	if (x < -3.326128725870005e+62)
		tmp = t_0;
	elseif (x < 9.429991714554673e+55)
		tmp = Float64(Float64(Float64(x - 2.0) / 1.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 4.16438922228) + 78.6994924154) * x) + 137.519416416) * x) + y) * x) + z) / Float64(Float64(Float64(Float64(Float64(263.505074721 * x) + Float64(Float64(43.3400022514 * Float64(x * x)) + Float64(x * Float64(x * x)))) + 313.399215894) * x) + 47.066876606)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((y / (x * x)) + (4.16438922228 * x)) - 110.1139242984811;
	tmp = 0.0;
	if (x < -3.326128725870005e+62)
		tmp = t_0;
	elseif (x < 9.429991714554673e+55)
		tmp = ((x - 2.0) / 1.0) * (((((((((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));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(4.16438922228 * x), $MachinePrecision]), $MachinePrecision] - 110.1139242984811), $MachinePrecision]}, If[Less[x, -3.326128725870005e+62], t$95$0, If[Less[x, 9.429991714554673e+55], N[(N[(N[(x - 2.0), $MachinePrecision] / 1.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(N[(x * 4.16438922228), $MachinePrecision] + 78.6994924154), $MachinePrecision] * x), $MachinePrecision] + 137.519416416), $MachinePrecision] * x), $MachinePrecision] + y), $MachinePrecision] * x), $MachinePrecision] + z), $MachinePrecision] / N[(N[(N[(N[(N[(263.505074721 * x), $MachinePrecision] + N[(N[(43.3400022514 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 313.399215894), $MachinePrecision] * x), $MachinePrecision] + 47.066876606), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\frac{y}{x \cdot x} + 4.16438922228 \cdot x\right) - 110.1139242984811\\
\mathbf{if}\;x < -3.326128725870005 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x < 9.429991714554673 \cdot 10^{+55}:\\
\;\;\;\;\frac{x - 2}{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}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024321 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, C"
  :precision binary64
  :pre (TRUE)

  :alt
  (! :herbie-platform default (if (< x -332612872587000500000000000000000000000000000000000000000000000) (- (+ (/ y (* x x)) (* 104109730557/25000000000 x)) 1101139242984811/10000000000000) (if (< x 94299917145546730000000000000000000000000000000000000000) (* (/ (- x 2) 1) (/ (+ (* (+ (* (+ (* (+ (* x 104109730557/25000000000) 393497462077/5000000000) x) 4297481763/31250000) x) y) x) z) (+ (* (+ (+ (* 263505074721/1000000000 x) (+ (* 216700011257/5000000000 (* x x)) (* x (* x x)))) 156699607947/500000000) x) 23533438303/500000000))) (- (+ (/ y (* x x)) (* 104109730557/25000000000 x)) 1101139242984811/10000000000000))))

  (/ (* (- 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)))