Average Error: 20.2 → 0.4
Time: 9.7s
Precision: binary64
Cost: 1352
\[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} t_0 := x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\ \mathbf{if}\;z \leq -1932794297.6222742:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.11217360939673404:\\ \;\;\;\;x + y \cdot \left(0.08333333333333323 + z \cdot \left(-0.00277777777751721 + z \cdot \left(0.0007936505811533442 + z \cdot -0.0005951669793454025\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+
  x
  (/
   (*
    y
    (+
     (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
     0.279195317918525))
   (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (/ y (+ 14.431876219268936 (/ -15.646356830292042 z))))))
   (if (<= z -1932794297.6222742)
     t_0
     (if (<= z 0.11217360939673404)
       (+
        x
        (*
         y
         (+
          0.08333333333333323
          (*
           z
           (+
            -0.00277777777751721
            (* z (+ 0.0007936505811533442 (* z -0.0005951669793454025))))))))
       t_0))))
double code(double x, double y, double z) {
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
double code(double x, double y, double z) {
	double t_0 = x + (y / (14.431876219268936 + (-15.646356830292042 / z)));
	double tmp;
	if (z <= -1932794297.6222742) {
		tmp = t_0;
	} else if (z <= 0.11217360939673404) {
		tmp = x + (y * (0.08333333333333323 + (z * (-0.00277777777751721 + (z * (0.0007936505811533442 + (z * -0.0005951669793454025)))))));
	} 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
    code = x + ((y * ((((z * 0.0692910599291889d0) + 0.4917317610505968d0) * z) + 0.279195317918525d0)) / (((z + 6.012459259764103d0) * z) + 3.350343815022304d0))
end function
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 + (y / (14.431876219268936d0 + ((-15.646356830292042d0) / z)))
    if (z <= (-1932794297.6222742d0)) then
        tmp = t_0
    else if (z <= 0.11217360939673404d0) then
        tmp = x + (y * (0.08333333333333323d0 + (z * ((-0.00277777777751721d0) + (z * (0.0007936505811533442d0 + (z * (-0.0005951669793454025d0))))))))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
public static double code(double x, double y, double z) {
	double t_0 = x + (y / (14.431876219268936 + (-15.646356830292042 / z)));
	double tmp;
	if (z <= -1932794297.6222742) {
		tmp = t_0;
	} else if (z <= 0.11217360939673404) {
		tmp = x + (y * (0.08333333333333323 + (z * (-0.00277777777751721 + (z * (0.0007936505811533442 + (z * -0.0005951669793454025)))))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304))
def code(x, y, z):
	t_0 = x + (y / (14.431876219268936 + (-15.646356830292042 / z)))
	tmp = 0
	if z <= -1932794297.6222742:
		tmp = t_0
	elif z <= 0.11217360939673404:
		tmp = x + (y * (0.08333333333333323 + (z * (-0.00277777777751721 + (z * (0.0007936505811533442 + (z * -0.0005951669793454025)))))))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	return Float64(x + Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304)))
end
function code(x, y, z)
	t_0 = Float64(x + Float64(y / Float64(14.431876219268936 + Float64(-15.646356830292042 / z))))
	tmp = 0.0
	if (z <= -1932794297.6222742)
		tmp = t_0;
	elseif (z <= 0.11217360939673404)
		tmp = Float64(x + Float64(y * Float64(0.08333333333333323 + Float64(z * Float64(-0.00277777777751721 + Float64(z * Float64(0.0007936505811533442 + Float64(z * -0.0005951669793454025))))))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
end
function tmp_2 = code(x, y, z)
	t_0 = x + (y / (14.431876219268936 + (-15.646356830292042 / z)));
	tmp = 0.0;
	if (z <= -1932794297.6222742)
		tmp = t_0;
	elseif (z <= 0.11217360939673404)
		tmp = x + (y * (0.08333333333333323 + (z * (-0.00277777777751721 + (z * (0.0007936505811533442 + (z * -0.0005951669793454025)))))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(x + N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y / N[(14.431876219268936 + N[(-15.646356830292042 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1932794297.6222742], t$95$0, If[LessEqual[z, 0.11217360939673404], N[(x + N[(y * N[(0.08333333333333323 + N[(z * N[(-0.00277777777751721 + N[(z * N[(0.0007936505811533442 + N[(z * -0.0005951669793454025), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
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}
t_0 := x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\
\mathbf{if}\;z \leq -1932794297.6222742:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 0.11217360939673404:\\
\;\;\;\;x + y \cdot \left(0.08333333333333323 + z \cdot \left(-0.00277777777751721 + z \cdot \left(0.0007936505811533442 + z \cdot -0.0005951669793454025\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.2
Target0.4
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;z < -8120153.652456675:\\ \;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y - \left(\frac{0.40462203869992125 \cdot y}{z \cdot z} - x\right)\\ \mathbf{elif}\;z < 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 \cdot z} - x\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if z < -1932794297.62227416 or 0.11217360939673404 < z

    1. Initial program 40.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} \]
    2. Applied egg-rr34.0

      \[\leadsto x + \color{blue}{{\left(\frac{\frac{\mathsf{fma}\left(z, z + 6.012459259764103, 3.350343815022304\right)}{y}}{\mathsf{fma}\left(z, \mathsf{fma}\left(z, 0.0692910599291889, 0.4917317610505968\right), 0.279195317918525\right)}\right)}^{-1}} \]
    3. Taylor expanded in z around inf 0.4

      \[\leadsto x + {\color{blue}{\left(14.431876219268936 \cdot \frac{1}{y} - 15.646356830292042 \cdot \frac{1}{y \cdot z}\right)}}^{-1} \]
    4. Taylor expanded in y around 0 0.3

      \[\leadsto x + \color{blue}{\frac{y}{14.431876219268936 - 15.646356830292042 \cdot \frac{1}{z}}} \]
    5. Simplified0.3

      \[\leadsto x + \color{blue}{\frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}} \]

    if -1932794297.62227416 < z < 0.11217360939673404

    1. Initial program 0.2

      \[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} \]
    2. Simplified0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(z, 0.0692910599291889, 0.4917317610505968\right), 0.279195317918525\right)}{\mathsf{fma}\left(z, z + 6.012459259764103, 3.350343815022304\right)}, x\right)} \]
    3. Taylor expanded in z around 0 0.6

      \[\leadsto \color{blue}{0.0007936505811533442 \cdot \left(y \cdot {z}^{2}\right) + \left(0.08333333333333323 \cdot y + \left(-0.00277777777751721 \cdot \left(y \cdot z\right) + \left(-0.0005951669793454025 \cdot \left(y \cdot {z}^{3}\right) + x\right)\right)\right)} \]
    4. Simplified0.6

      \[\leadsto \color{blue}{x + y \cdot \left(0.08333333333333323 + z \cdot \left(-0.00277777777751721 + z \cdot \left(0.0007936505811533442 + z \cdot -0.0005951669793454025\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1932794297.6222742:\\ \;\;\;\;x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\ \mathbf{elif}\;z \leq 0.11217360939673404:\\ \;\;\;\;x + y \cdot \left(0.08333333333333323 + z \cdot \left(-0.00277777777751721 + z \cdot \left(0.0007936505811533442 + z \cdot -0.0005951669793454025\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.6
Cost840
\[\begin{array}{l} t_0 := x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\ \mathbf{if}\;z \leq -1932794297.6222742:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.11217360939673404:\\ \;\;\;\;x + y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.5
Cost840
\[\begin{array}{l} t_0 := x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\ \mathbf{if}\;z \leq -1932794297.6222742:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.11217360939673404:\\ \;\;\;\;x + y \cdot \left(0.08333333333333323 + z \cdot -0.00277777777751721\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error26.5
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9890781985568904 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.67467369352959 \cdot 10^{-86}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;x \leq 4.2870804349140725 \cdot 10^{-75}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.6087828347219503 \cdot 10^{+77}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error25.4
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9890781985568904 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8066412522704427 \cdot 10^{-98}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;x \leq 0.011543943462413794:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error14.0
Cost584
\[\begin{array}{l} t_0 := x + \frac{y}{14.431876219268936}\\ \mathbf{if}\;z \leq -4.6319475226751326 \cdot 10^{-260}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.921974487974353 \cdot 10^{-203}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.7
Cost584
\[\begin{array}{l} t_0 := x + \frac{y}{14.431876219268936}\\ \mathbf{if}\;z \leq -1932794297.6222742:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.11217360939673404:\\ \;\;\;\;x + y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error31.5
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (if (< z -8120153.652456675) (- (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) (- (/ (* 0.40462203869992125 y) (* z z)) x)) (if (< z 6.576118972787377e+20) (+ x (* (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (/ 1.0 (+ (* (+ z 6.012459259764103) z) 3.350343815022304)))) (- (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) (- (/ (* 0.40462203869992125 y) (* z z)) x))))

  (+ x (/ (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))