Average Error: 20.2 → 0.9
Time: 11.4s
Precision: binary64
Cost: 26696
\[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 \leq -1.944676140676365 \cdot 10^{+52}:\\ \;\;\;\;x + {\left(\frac{14.431876219268936}{y}\right)}^{-1}\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \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
 (if (<= z -1.944676140676365e+52)
   (+ x (pow (/ 14.431876219268936 y) -1.0))
   (if (<= z 1.1625408330131266e-29)
     (fma
      y
      (/
       (fma z (fma z 0.0692910599291889 0.4917317610505968) 0.279195317918525)
       (fma z (+ z 6.012459259764103) 3.350343815022304))
      x)
     (+ x (* y 0.0692910599291889)))))
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 tmp;
	if (z <= -1.944676140676365e+52) {
		tmp = x + pow((14.431876219268936 / y), -1.0);
	} else if (z <= 1.1625408330131266e-29) {
		tmp = fma(y, (fma(z, fma(z, 0.0692910599291889, 0.4917317610505968), 0.279195317918525) / fma(z, (z + 6.012459259764103), 3.350343815022304)), x);
	} else {
		tmp = x + (y * 0.0692910599291889);
	}
	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)
	tmp = 0.0
	if (z <= -1.944676140676365e+52)
		tmp = Float64(x + (Float64(14.431876219268936 / y) ^ -1.0));
	elseif (z <= 1.1625408330131266e-29)
		tmp = fma(y, Float64(fma(z, fma(z, 0.0692910599291889, 0.4917317610505968), 0.279195317918525) / fma(z, Float64(z + 6.012459259764103), 3.350343815022304)), x);
	else
		tmp = Float64(x + Float64(y * 0.0692910599291889));
	end
	return 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_] := If[LessEqual[z, -1.944676140676365e+52], N[(x + N[Power[N[(14.431876219268936 / y), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.1625408330131266e-29], N[(y * N[(N[(z * N[(z * 0.0692910599291889 + 0.4917317610505968), $MachinePrecision] + 0.279195317918525), $MachinePrecision] / N[(z * N[(z + 6.012459259764103), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(y * 0.0692910599291889), $MachinePrecision]), $MachinePrecision]]]
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 \leq -1.944676140676365 \cdot 10^{+52}:\\
\;\;\;\;x + {\left(\frac{14.431876219268936}{y}\right)}^{-1}\\

\mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\
\;\;\;\;\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)\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot 0.0692910599291889\\


\end{array}

Error

Target

Original20.2
Target0.4
Herbie0.9
\[\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 3 regimes
  2. if z < -1.9446761406763649e52

    1. Initial program 46.9

      \[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-rr46.9

      \[\leadsto x + \color{blue}{{\left(\frac{\mathsf{fma}\left(z, z + 6.012459259764103, 3.350343815022304\right)}{y \cdot \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.1

      \[\leadsto x + {\color{blue}{\left(\frac{14.431876219268936}{y}\right)}}^{-1} \]

    if -1.9446761406763649e52 < z < 1.1625408330131266e-29

    1. Initial program 0.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} \]
    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)} \]
      Proof
      (fma.f64 y (/.f64 (fma.f64 z (fma.f64 z 692910599291889/10000000000000000 307332350656623/625000000000000) 11167812716741/40000000000000) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (fma.f64 z (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000)) 11167812716741/40000000000000) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000)) 11167812716741/40000000000000)) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z)) 11167812716741/40000000000000) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (+.f64 z 6012459259764103/1000000000000000)) 104698244219447/31250000000000))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z)) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000))) x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000))) x): 31 points increase in error, 6 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000)))): 0 points increase in error, 0 points decrease in error

    if 1.1625408330131266e-29 < z

    1. Initial program 36.9

      \[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. Simplified29.4

      \[\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)} \]
      Proof
      (fma.f64 y (/.f64 (fma.f64 z (fma.f64 z 692910599291889/10000000000000000 307332350656623/625000000000000) 11167812716741/40000000000000) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (fma.f64 z (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000)) 11167812716741/40000000000000) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000)) 11167812716741/40000000000000)) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z)) 11167812716741/40000000000000) (fma.f64 z (+.f64 z 6012459259764103/1000000000000000) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (+.f64 z 6012459259764103/1000000000000000)) 104698244219447/31250000000000))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 y (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z)) 104698244219447/31250000000000)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000))) x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000))) x): 31 points increase in error, 6 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000)))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in z around inf 3.0

      \[\leadsto \color{blue}{0.0692910599291889 \cdot y + x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.944676140676365 \cdot 10^{+52}:\\ \;\;\;\;x + {\left(\frac{14.431876219268936}{y}\right)}^{-1}\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \end{array} \]

Alternatives

Alternative 1
Error1.0
Cost20424
\[\begin{array}{l} \mathbf{if}\;z \leq -4.992361991635503 \cdot 10^{+43}:\\ \;\;\;\;x + {\left(\frac{14.431876219268936}{y}\right)}^{-1}\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(z, 0.0692910599291889, 0.4917317610505968\right), 0.279195317918525\right)}{\frac{\mathsf{fma}\left(z, z + 6.012459259764103, 3.350343815022304\right)}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 2
Error1.1
Cost6916
\[\begin{array}{l} \mathbf{if}\;z \leq -5.94908189944784 \cdot 10^{+22}:\\ \;\;\;\;x + {\left(\frac{14.431876219268936}{y}\right)}^{-1}\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{y \cdot \left(z \cdot \left(0.4917317610505968 + z \cdot 0.0692910599291889\right)\right) + y \cdot 0.279195317918525}{3.350343815022304 + z \cdot \left(z + 6.012459259764103\right)}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 3
Error1.1
Cost1736
\[\begin{array}{l} t_0 := x + y \cdot 0.0692910599291889\\ \mathbf{if}\;z \leq -5.94908189944784 \cdot 10^{+22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{y \cdot \left(z \cdot \left(0.4917317610505968 + z \cdot 0.0692910599291889\right)\right) + y \cdot 0.279195317918525}{3.350343815022304 + z \cdot \left(z + 6.012459259764103\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.1
Cost1608
\[\begin{array}{l} t_0 := x + y \cdot 0.0692910599291889\\ \mathbf{if}\;z \leq -5.94908189944784 \cdot 10^{+22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{y \cdot \left(0.279195317918525 + z \cdot \left(0.4917317610505968 + z \cdot 0.0692910599291889\right)\right)}{3.350343815022304 + z \cdot \left(z + 6.012459259764103\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.1
Cost1352
\[\begin{array}{l} \mathbf{if}\;z \leq -6106.130271590426:\\ \;\;\;\;x + y \cdot \left(0.0692910599291889 + \frac{0.07512208616047561}{z}\right)\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;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 + y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 6
Error1.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -6106.130271590426:\\ \;\;\;\;x + y \cdot \left(0.0692910599291889 + \frac{0.07512208616047561}{z}\right)\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + y \cdot \left(0.08333333333333323 + z \cdot \left(-0.00277777777751721 + z \cdot 0.0007936505811533442\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 7
Error1.1
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -6106.130271590426:\\ \;\;\;\;x + y \cdot \left(0.0692910599291889 + \frac{0.07512208616047561}{z}\right)\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + y \cdot \left(0.08333333333333323 + z \cdot -0.00277777777751721\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 8
Error1.1
Cost708
\[\begin{array}{l} \mathbf{if}\;z \leq -6106.130271590426:\\ \;\;\;\;x + y \cdot \left(0.0692910599291889 + \frac{0.07512208616047561}{z}\right)\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 9
Error1.2
Cost584
\[\begin{array}{l} t_0 := x + y \cdot 0.0692910599291889\\ \mathbf{if}\;z \leq -6106.130271590426:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.1625408330131266 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error13.2
Cost320
\[x + \frac{y}{12.000000000000014} \]
Alternative 11
Error32.0
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022291 
(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))))