?

Average Accuracy: 68.4% → 98.2%
Time: 12.1s
Precision: binary64
Cost: 841

?

\[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 -5.5 \lor \neg \left(z \leq 2.55 \cdot 10^{-31}\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936 - \frac{15.646356830292042}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \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 (or (<= z -5.5) (not (<= z 2.55e-31)))
   (+ x (/ y (- 14.431876219268936 (/ 15.646356830292042 z))))
   (+ x (/ y 12.000000000000014))))
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 <= -5.5) || !(z <= 2.55e-31)) {
		tmp = x + (y / (14.431876219268936 - (15.646356830292042 / z)));
	} else {
		tmp = x + (y / 12.000000000000014);
	}
	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) :: tmp
    if ((z <= (-5.5d0)) .or. (.not. (z <= 2.55d-31))) then
        tmp = x + (y / (14.431876219268936d0 - (15.646356830292042d0 / z)))
    else
        tmp = x + (y / 12.000000000000014d0)
    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 tmp;
	if ((z <= -5.5) || !(z <= 2.55e-31)) {
		tmp = x + (y / (14.431876219268936 - (15.646356830292042 / z)));
	} else {
		tmp = x + (y / 12.000000000000014);
	}
	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):
	tmp = 0
	if (z <= -5.5) or not (z <= 2.55e-31):
		tmp = x + (y / (14.431876219268936 - (15.646356830292042 / z)))
	else:
		tmp = x + (y / 12.000000000000014)
	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 <= -5.5) || !(z <= 2.55e-31))
		tmp = Float64(x + Float64(y / Float64(14.431876219268936 - Float64(15.646356830292042 / z))));
	else
		tmp = Float64(x + Float64(y / 12.000000000000014));
	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)
	tmp = 0.0;
	if ((z <= -5.5) || ~((z <= 2.55e-31)))
		tmp = x + (y / (14.431876219268936 - (15.646356830292042 / z)));
	else
		tmp = x + (y / 12.000000000000014);
	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_] := If[Or[LessEqual[z, -5.5], N[Not[LessEqual[z, 2.55e-31]], $MachinePrecision]], N[(x + N[(y / N[(14.431876219268936 - N[(15.646356830292042 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / 12.000000000000014), $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 -5.5 \lor \neg \left(z \leq 2.55 \cdot 10^{-31}\right):\\
\;\;\;\;x + \frac{y}{14.431876219268936 - \frac{15.646356830292042}{z}}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{12.000000000000014}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original68.4%
Target99.4%
Herbie98.2%
\[\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 < -5.5 or 2.5499999999999999e-31 < z

    1. Initial program 40.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. Simplified51.4%

      \[\leadsto \color{blue}{x + \frac{y}{\frac{\mathsf{fma}\left(z + 6.012459259764103, z, 3.350343815022304\right)}{\mathsf{fma}\left(\mathsf{fma}\left(z, 0.0692910599291889, 0.4917317610505968\right), z, 0.279195317918525\right)}}} \]
      Proof

      [Start]40.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} \]

      associate-/l* [=>]51.4

      \[ x + \color{blue}{\frac{y}{\frac{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}{\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525}}} \]

      fma-def [=>]51.4

      \[ x + \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z + 6.012459259764103, z, 3.350343815022304\right)}}{\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525}} \]

      fma-def [=>]51.4

      \[ x + \frac{y}{\frac{\mathsf{fma}\left(z + 6.012459259764103, z, 3.350343815022304\right)}{\color{blue}{\mathsf{fma}\left(z \cdot 0.0692910599291889 + 0.4917317610505968, z, 0.279195317918525\right)}}} \]

      fma-def [=>]51.4

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

      \[\leadsto x + \frac{y}{\color{blue}{14.431876219268936 - 15.646356830292042 \cdot \frac{1}{z}}} \]
    4. Simplified97.1%

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

      [Start]97.1

      \[ x + \frac{y}{14.431876219268936 - 15.646356830292042 \cdot \frac{1}{z}} \]

      associate-*r/ [=>]97.1

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

      metadata-eval [=>]97.1

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

    if -5.5 < z < 2.5499999999999999e-31

    1. Initial program 99.6%

      \[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. Simplified99.3%

      \[\leadsto \color{blue}{x + \frac{y}{\frac{\mathsf{fma}\left(z + 6.012459259764103, z, 3.350343815022304\right)}{\mathsf{fma}\left(\mathsf{fma}\left(z, 0.0692910599291889, 0.4917317610505968\right), z, 0.279195317918525\right)}}} \]
      Proof

      [Start]99.6

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

      associate-/l* [=>]99.3

      \[ x + \color{blue}{\frac{y}{\frac{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}{\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525}}} \]

      fma-def [=>]99.3

      \[ x + \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z + 6.012459259764103, z, 3.350343815022304\right)}}{\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525}} \]

      fma-def [=>]99.3

      \[ x + \frac{y}{\frac{\mathsf{fma}\left(z + 6.012459259764103, z, 3.350343815022304\right)}{\color{blue}{\mathsf{fma}\left(z \cdot 0.0692910599291889 + 0.4917317610505968, z, 0.279195317918525\right)}}} \]

      fma-def [=>]99.3

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

      \[\leadsto x + \frac{y}{\color{blue}{12.000000000000014}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \lor \neg \left(z \leq 2.55 \cdot 10^{-31}\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936 - \frac{15.646356830292042}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy50.6%
Cost1644
\[\begin{array}{l} \mathbf{if}\;z \leq -1.16 \cdot 10^{+41}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -5500000000000:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-96}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-142}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-197}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-254}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-131}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+34}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+250}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 2
Accuracy78.1%
Cost982
\[\begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+47} \lor \neg \left(z \leq -1.06 \cdot 10^{+15}\right) \land \left(z \leq 2.12 \cdot 10^{+36} \lor \neg \left(z \leq 6.6 \cdot 10^{+150}\right) \land z \leq 4.5 \cdot 10^{+255}\right):\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 3
Accuracy98.4%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-23}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(0.0692910599291889 + \frac{0.07512208616047561}{z}\right)\\ \end{array} \]
Alternative 4
Accuracy60.3%
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1.32 \cdot 10^{+138}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{+110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4.05 \cdot 10^{+37}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+154}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \end{array} \]
Alternative 5
Accuracy98.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5 \lor \neg \left(z \leq 2.55 \cdot 10^{-31}\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \end{array} \]
Alternative 6
Accuracy50.2%
Cost64
\[x \]

Error

Reproduce?

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