?

Average Error: 20.2 → 1.0
Time: 11.4s
Precision: binary64
Cost: 3912

?

\[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 := \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}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;y \cdot \left(0.0692910599291889 + 0.07512208616047561 \cdot \frac{1}{z}\right)\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+285}:\\ \;\;\;\;x + t_0\\ \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
 (let* ((t_0
         (/
          (*
           y
           (+
            (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
            0.279195317918525))
          (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
   (if (<= t_0 (- INFINITY))
     (* y (+ 0.0692910599291889 (* 0.07512208616047561 (/ 1.0 z))))
     (if (<= t_0 5e+285) (+ x t_0) (+ 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 t_0 = (y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = y * (0.0692910599291889 + (0.07512208616047561 * (1.0 / z)));
	} else if (t_0 <= 5e+285) {
		tmp = x + t_0;
	} else {
		tmp = x + (y * 0.0692910599291889);
	}
	return tmp;
}
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 = (y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = y * (0.0692910599291889 + (0.07512208616047561 * (1.0 / z)));
	} else if (t_0 <= 5e+285) {
		tmp = x + t_0;
	} else {
		tmp = x + (y * 0.0692910599291889);
	}
	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 = (y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = y * (0.0692910599291889 + (0.07512208616047561 * (1.0 / z)))
	elif t_0 <= 5e+285:
		tmp = x + t_0
	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)
	t_0 = Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(y * Float64(0.0692910599291889 + Float64(0.07512208616047561 * Float64(1.0 / z))));
	elseif (t_0 <= 5e+285)
		tmp = Float64(x + t_0);
	else
		tmp = Float64(x + Float64(y * 0.0692910599291889));
	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 = (y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = y * (0.0692910599291889 + (0.07512208616047561 * (1.0 / z)));
	elseif (t_0 <= 5e+285)
		tmp = x + t_0;
	else
		tmp = x + (y * 0.0692910599291889);
	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[(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]}, If[LessEqual[t$95$0, (-Infinity)], N[(y * N[(0.0692910599291889 + N[(0.07512208616047561 * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+285], N[(x + t$95$0), $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}
t_0 := \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}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;y \cdot \left(0.0692910599291889 + 0.07512208616047561 \cdot \frac{1}{z}\right)\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+285}:\\
\;\;\;\;x + t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.2
Target0.4
Herbie1.0
\[\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 (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000)) < -inf.0

    1. Initial program 64.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} \]
    2. Taylor expanded in z around inf 0.4

      \[\leadsto x + \color{blue}{\left(\left(0.4917317610505968 \cdot \frac{y}{z} + 0.0692910599291889 \cdot y\right) - 0.4166096748901212 \cdot \frac{y}{z}\right)} \]
    3. Applied egg-rr0.4

      \[\leadsto x + \color{blue}{\left(\frac{y}{z} \cdot -0.07512208616047561 - y \cdot 0.0692910599291889\right) \cdot -1} \]
    4. Simplified0.4

      \[\leadsto x + \color{blue}{\left(y \cdot 0.0692910599291889 - \frac{y}{z} \cdot -0.07512208616047561\right)} \]
      Proof

      [Start]0.4

      \[ x + \left(\frac{y}{z} \cdot -0.07512208616047561 - y \cdot 0.0692910599291889\right) \cdot -1 \]

      rational_best_oopsla_all_46_json_45_simplify-92 [=>]0.4

      \[ x + \color{blue}{\left(-\left(\frac{y}{z} \cdot -0.07512208616047561 - y \cdot 0.0692910599291889\right)\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-97 [=>]0.4

      \[ x + \color{blue}{\left(0 - \left(\frac{y}{z} \cdot -0.07512208616047561 - y \cdot 0.0692910599291889\right)\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-36 [=>]0.4

      \[ x + \color{blue}{\left(y \cdot 0.0692910599291889 - \left(\frac{y}{z} \cdot -0.07512208616047561 - 0\right)\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-81 [=>]0.4

      \[ x + \left(y \cdot 0.0692910599291889 - \color{blue}{\frac{y}{z} \cdot -0.07512208616047561}\right) \]
    5. Taylor expanded in x around 0 9.9

      \[\leadsto \color{blue}{0.0692910599291889 \cdot y - -0.07512208616047561 \cdot \frac{y}{z}} \]
    6. Simplified9.9

      \[\leadsto \color{blue}{y \cdot 0.0692910599291889 - -0.07512208616047561 \cdot \frac{y}{z}} \]
      Proof

      [Start]9.9

      \[ 0.0692910599291889 \cdot y - -0.07512208616047561 \cdot \frac{y}{z} \]

      rational_best_oopsla_all_46_json_45_simplify-74 [<=]9.9

      \[ \color{blue}{y \cdot 0.0692910599291889} - -0.07512208616047561 \cdot \frac{y}{z} \]
    7. Taylor expanded in y around 0 9.9

      \[\leadsto \color{blue}{y \cdot \left(0.0692910599291889 + 0.07512208616047561 \cdot \frac{1}{z}\right)} \]

    if -inf.0 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000)) < 5.00000000000000016e285

    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} \]

    if 5.00000000000000016e285 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z 692910599291889/10000000000000000) 307332350656623/625000000000000) z) 11167812716741/40000000000000)) (+.f64 (*.f64 (+.f64 z 6012459259764103/1000000000000000) z) 104698244219447/31250000000000))

    1. Initial program 62.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} \]
    2. Taylor expanded in z around inf 1.9

      \[\leadsto x + \color{blue}{0.0692910599291889 \cdot y} \]
    3. Simplified1.9

      \[\leadsto x + \color{blue}{y \cdot 0.0692910599291889} \]
      Proof

      [Start]1.9

      \[ x + 0.0692910599291889 \cdot y \]

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]1.9

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

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

Alternatives

Alternative 1
Error0.5
Cost1352
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;x + \left(y \cdot 0.0692910599291889 + \frac{y}{z} \cdot 0.07512208616047561\right)\\ \mathbf{elif}\;z \leq 5.2:\\ \;\;\;\;x + \left(y \cdot 0.08333333333333323 + z \cdot \left(y \cdot -0.00277777777751721\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\left(0.4917317610505968 \cdot \frac{y}{z} + 0.0692910599291889 \cdot y\right) - 0.4166096748901212 \cdot \frac{y}{z}\right)\\ \end{array} \]
Alternative 2
Error0.6
Cost968
\[\begin{array}{l} t_0 := x + \left(y \cdot 0.0692910599291889 + \frac{y}{z} \cdot 0.07512208616047561\right)\\ \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.3:\\ \;\;\;\;x + y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.5
Cost968
\[\begin{array}{l} t_0 := x + \left(y \cdot 0.0692910599291889 + \frac{y}{z} \cdot 0.07512208616047561\right)\\ \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.2:\\ \;\;\;\;x + \left(y \cdot 0.08333333333333323 + z \cdot \left(y \cdot -0.00277777777751721\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error25.4
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7.4 \cdot 10^{-213}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-255}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-239}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-45}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error14.0
Cost848
\[\begin{array}{l} t_0 := x + y \cdot 0.0692910599291889\\ \mathbf{if}\;x \leq -4.3 \cdot 10^{-217}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-258}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-229}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-182}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error26.1
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+146}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+119}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-57}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+83}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 7
Error0.8
Cost584
\[\begin{array}{l} t_0 := x + y \cdot 0.0692910599291889\\ \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.8:\\ \;\;\;\;x + y \cdot 0.08333333333333323\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error32.1
Cost64
\[x \]

Error

Reproduce?

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