?

Average Accuracy: 69.0% → 99.7%
Time: 16.0s
Precision: binary64
Cost: 26697

?

\[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 -4.4 \cdot 10^{+26} \lor \neg \left(z \leq 300000\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\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)}, y, x\right)\\ \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 -4.4e+26) (not (<= z 300000.0)))
   (+ x (/ y 14.431876219268936))
   (fma
    (/
     (fma z (fma z 0.0692910599291889 0.4917317610505968) 0.279195317918525)
     (fma z (+ z 6.012459259764103) 3.350343815022304))
    y
    x)))
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 <= -4.4e+26) || !(z <= 300000.0)) {
		tmp = x + (y / 14.431876219268936);
	} else {
		tmp = fma((fma(z, fma(z, 0.0692910599291889, 0.4917317610505968), 0.279195317918525) / fma(z, (z + 6.012459259764103), 3.350343815022304)), y, x);
	}
	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 <= -4.4e+26) || !(z <= 300000.0))
		tmp = Float64(x + Float64(y / 14.431876219268936));
	else
		tmp = fma(Float64(fma(z, fma(z, 0.0692910599291889, 0.4917317610505968), 0.279195317918525) / fma(z, Float64(z + 6.012459259764103), 3.350343815022304)), y, x);
	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[Or[LessEqual[z, -4.4e+26], N[Not[LessEqual[z, 300000.0]], $MachinePrecision]], N[(x + N[(y / 14.431876219268936), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * N[(z * 0.0692910599291889 + 0.4917317610505968), $MachinePrecision] + 0.279195317918525), $MachinePrecision] / N[(z * N[(z + 6.012459259764103), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision] * y + x), $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 -4.4 \cdot 10^{+26} \lor \neg \left(z \leq 300000\right):\\
\;\;\;\;x + \frac{y}{14.431876219268936}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\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)}, y, x\right)\\


\end{array}

Error?

Target

Original69.0%
Target99.5%
Herbie99.7%
\[\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 < -4.40000000000000014e26 or 3e5 < z

    1. Initial program 34.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. Simplified47.8%

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

      associate-/l* [=>]47.7

      \[ 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 [=>]47.8

      \[ 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 [=>]47.7

      \[ 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 [=>]47.8

      \[ 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 99.6%

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

    if -4.40000000000000014e26 < z < 3e5

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\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)}, y, x\right)} \]
      Proof

      [Start]99.4

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

      +-commutative [=>]99.4

      \[ \color{blue}{\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} + x} \]

      associate-*r/ [<=]99.8

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

      *-commutative [<=]99.8

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

      fma-def [=>]99.8

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

      *-commutative [=>]99.8

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

      fma-def [=>]99.8

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

      fma-def [=>]99.8

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

      *-commutative [=>]99.8

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

      fma-def [=>]99.8

      \[ \mathsf{fma}\left(\frac{\mathsf{fma}\left(z, \mathsf{fma}\left(z, 0.0692910599291889, 0.4917317610505968\right), 0.279195317918525\right)}{\color{blue}{\mathsf{fma}\left(z, z + 6.012459259764103, 3.350343815022304\right)}}, y, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+26} \lor \neg \left(z \leq 300000\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\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)}, y, x\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.6%
Cost8009
\[\begin{array}{l} \mathbf{if}\;z \leq -3.9 \cdot 10^{+48} \lor \neg \left(z \leq 300000\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\mathsf{fma}\left(z, z + 6.012459259764103, 3.350343815022304\right)} \cdot \left(\left(0.279195317918525 + z \cdot \left(z \cdot 0.0692910599291889\right)\right) + z \cdot 0.4917317610505968\right)\\ \end{array} \]
Alternative 2
Accuracy99.5%
Cost1609
\[\begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+26} \lor \neg \left(z \leq 300000\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;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)}\\ \end{array} \]
Alternative 3
Accuracy99.5%
Cost1097
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \lor \neg \left(z \leq 6.2\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936 + \frac{\frac{101.23733352003822}{z} + -15.646356830292042}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z \cdot 0.39999999996247915 + 12.000000000000014}\\ \end{array} \]
Alternative 4
Accuracy59.6%
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+115}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+19}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;y \leq -2.05 \cdot 10^{+18}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq 2.65 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+21}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+158}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \end{array} \]
Alternative 5
Accuracy59.6%
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+115}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+19}:\\ \;\;\;\;\frac{y}{12.000000000000014}\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{+19}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+19}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+159}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{12.000000000000014}\\ \end{array} \]
Alternative 6
Accuracy78.9%
Cost848
\[\begin{array}{l} t_0 := x + \frac{y}{12.000000000000014}\\ \mathbf{if}\;z \leq 3.7 \cdot 10^{+145}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+185}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+216}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+252}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Accuracy99.2%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \lor \neg \left(z \leq 6\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z \cdot 0.39999999996247915 + 12.000000000000014}\\ \end{array} \]
Alternative 8
Accuracy99.5%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \lor \neg \left(z \leq 6.5\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936 + \frac{-15.646356830292042}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z \cdot 0.39999999996247915 + 12.000000000000014}\\ \end{array} \]
Alternative 9
Accuracy59.5%
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1400000000000:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+24}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+158}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.08333333333333323\\ \end{array} \]
Alternative 10
Accuracy99.0%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \lor \neg \left(z \leq 5.4\right):\\ \;\;\;\;x + \frac{y}{14.431876219268936}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{12.000000000000014}\\ \end{array} \]
Alternative 11
Accuracy50.9%
Cost64
\[x \]

Error

Reproduce?

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