?

Average Accuracy: 61.8% → 88.6%
Time: 33.8s
Precision: binary64
Cost: 7496

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -3.9 \cdot 10^{+52}:\\ \;\;\;\;\frac{z}{\mathsf{fma}\left(0.5, \frac{a}{\frac{z}{t}}, -z\right)} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+75}:\\ \;\;\;\;y \cdot \frac{z}{\frac{\sqrt{z \cdot z - a \cdot t}}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= z -3.9e+52)
   (* (/ z (fma 0.5 (/ a (/ z t)) (- z))) (* x y))
   (if (<= z 6e+75) (* y (/ z (/ (sqrt (- (* z z) (* a t))) x))) (* x y))))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) * z) / sqrt(((z * z) - (t * a)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -3.9e+52) {
		tmp = (z / fma(0.5, (a / (z / t)), -z)) * (x * y);
	} else if (z <= 6e+75) {
		tmp = y * (z / (sqrt(((z * z) - (a * t))) / x));
	} else {
		tmp = x * y;
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) * z) / sqrt(Float64(Float64(z * z) - Float64(t * a))))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if (z <= -3.9e+52)
		tmp = Float64(Float64(z / fma(0.5, Float64(a / Float64(z / t)), Float64(-z))) * Float64(x * y));
	elseif (z <= 6e+75)
		tmp = Float64(y * Float64(z / Float64(sqrt(Float64(Float64(z * z) - Float64(a * t))) / x)));
	else
		tmp = Float64(x * y);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.9e+52], N[(N[(z / N[(0.5 * N[(a / N[(z / t), $MachinePrecision]), $MachinePrecision] + (-z)), $MachinePrecision]), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6e+75], N[(y * N[(z / N[(N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+52}:\\
\;\;\;\;\frac{z}{\mathsf{fma}\left(0.5, \frac{a}{\frac{z}{t}}, -z\right)} \cdot \left(x \cdot y\right)\\

\mathbf{elif}\;z \leq 6 \cdot 10^{+75}:\\
\;\;\;\;y \cdot \frac{z}{\frac{\sqrt{z \cdot z - a \cdot t}}{x}}\\

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


\end{array}

Error?

Target

Original61.8%
Target87.7%
Herbie88.6%
\[\begin{array}{l} \mathbf{if}\;z < -3.1921305903852764 \cdot 10^{+46}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z < 5.976268120920894 \cdot 10^{+90}:\\ \;\;\;\;\frac{x \cdot z}{\frac{\sqrt{z \cdot z - a \cdot t}}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if z < -3.9e52

    1. Initial program 42.6%

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Simplified46.0%

      \[\leadsto \color{blue}{\frac{z}{\sqrt{z \cdot z - t \cdot a}} \cdot \left(x \cdot y\right)} \]
      Proof

      [Start]42.6

      \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]

      associate-*r/ [<=]46.0

      \[ \color{blue}{\left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}} \]

      *-commutative [<=]46.0

      \[ \color{blue}{\frac{z}{\sqrt{z \cdot z - t \cdot a}} \cdot \left(x \cdot y\right)} \]
    3. Taylor expanded in z around -inf 89.7%

      \[\leadsto \frac{z}{\color{blue}{0.5 \cdot \frac{a \cdot t}{z} + -1 \cdot z}} \cdot \left(x \cdot y\right) \]
    4. Simplified94.6%

      \[\leadsto \frac{z}{\color{blue}{\mathsf{fma}\left(0.5, \frac{a}{\frac{z}{t}}, -z\right)}} \cdot \left(x \cdot y\right) \]
      Proof

      [Start]89.7

      \[ \frac{z}{0.5 \cdot \frac{a \cdot t}{z} + -1 \cdot z} \cdot \left(x \cdot y\right) \]

      mul-1-neg [=>]89.7

      \[ \frac{z}{0.5 \cdot \frac{a \cdot t}{z} + \color{blue}{\left(-z\right)}} \cdot \left(x \cdot y\right) \]

      fma-def [=>]89.7

      \[ \frac{z}{\color{blue}{\mathsf{fma}\left(0.5, \frac{a \cdot t}{z}, -z\right)}} \cdot \left(x \cdot y\right) \]

      associate-/l* [=>]94.6

      \[ \frac{z}{\mathsf{fma}\left(0.5, \color{blue}{\frac{a}{\frac{z}{t}}}, -z\right)} \cdot \left(x \cdot y\right) \]

    if -3.9e52 < z < 6e75

    1. Initial program 82.6%

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Simplified84.1%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)} \]
      Proof

      [Start]82.6

      \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]

      associate-*r/ [<=]83.8

      \[ \color{blue}{\left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}} \]

      associate-*l* [=>]84.1

      \[ \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)} \]
    3. Applied egg-rr42.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(y \cdot \frac{z \cdot x}{\sqrt{z \cdot z - t \cdot a}}\right)} - 1} \]
    4. Simplified82.4%

      \[\leadsto \color{blue}{y \cdot \frac{z}{\frac{\sqrt{z \cdot z - a \cdot t}}{x}}} \]
      Proof

      [Start]42.5

      \[ e^{\mathsf{log1p}\left(y \cdot \frac{z \cdot x}{\sqrt{z \cdot z - t \cdot a}}\right)} - 1 \]

      expm1-def [=>]69.7

      \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \frac{z \cdot x}{\sqrt{z \cdot z - t \cdot a}}\right)\right)} \]

      expm1-log1p [=>]83.1

      \[ \color{blue}{y \cdot \frac{z \cdot x}{\sqrt{z \cdot z - t \cdot a}}} \]

      associate-/l* [=>]82.4

      \[ y \cdot \color{blue}{\frac{z}{\frac{\sqrt{z \cdot z - t \cdot a}}{x}}} \]

      *-commutative [<=]82.4

      \[ y \cdot \frac{z}{\frac{\sqrt{z \cdot z - \color{blue}{a \cdot t}}}{x}} \]

    if 6e75 < z

    1. Initial program 37.8%

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Simplified42.1%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)} \]
      Proof

      [Start]37.8

      \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]

      associate-*r/ [<=]42.1

      \[ \color{blue}{\left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}} \]

      associate-*l* [=>]42.1

      \[ \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)} \]
    3. Taylor expanded in z around inf 95.5%

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.9 \cdot 10^{+52}:\\ \;\;\;\;\frac{z}{\mathsf{fma}\left(0.5, \frac{a}{\frac{z}{t}}, -z\right)} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+75}:\\ \;\;\;\;y \cdot \frac{z}{\frac{\sqrt{z \cdot z - a \cdot t}}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternatives

Alternative 1
Accuracy89.9%
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -1.28 \cdot 10^{+154}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+76}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Accuracy88.5%
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -2.35 \cdot 10^{+100}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+76}:\\ \;\;\;\;y \cdot \frac{z}{\frac{\sqrt{z \cdot z - a \cdot t}}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 3
Accuracy81.5%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 1.28 \cdot 10^{-71}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{a \cdot \left(-t\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a}{\frac{z}{t}} \cdot -0.5}\right)\\ \end{array} \]
Alternative 4
Accuracy81.5%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-106}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-71}:\\ \;\;\;\;y \cdot \frac{z}{\frac{\sqrt{a \cdot \left(-t\right)}}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a}{\frac{z}{t}} \cdot -0.5}\right)\\ \end{array} \]
Alternative 5
Accuracy73.2%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -9.8 \cdot 10^{-234}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-114}:\\ \;\;\;\;-2 \cdot \left(\left(z \cdot \left(z \cdot \frac{y}{t}\right)\right) \cdot \frac{x}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 6
Accuracy73.9%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -1.92 \cdot 10^{-174}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-126}:\\ \;\;\;\;2 \cdot \left(y \cdot \left(\frac{z}{a} \cdot \frac{z}{\frac{t}{x}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Accuracy74.1%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.56 \cdot 10^{-166}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{-126}:\\ \;\;\;\;2 \cdot \left(y \cdot \frac{z}{t \cdot \frac{a}{z \cdot x}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 8
Accuracy74.1%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-170}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-126}:\\ \;\;\;\;2 \cdot \frac{y}{t \cdot \frac{a}{z \cdot \left(z \cdot x\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 9
Accuracy74.0%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{-166}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-114}:\\ \;\;\;\;\frac{-2}{t} \cdot \frac{\left(z \cdot x\right) \cdot \left(z \cdot y\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 10
Accuracy76.0%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-161}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a}{\frac{z}{t}} \cdot -0.5}\right)\\ \end{array} \]
Alternative 11
Accuracy76.5%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{z}{0.5 \cdot \frac{a \cdot t}{z} - z}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{z}{z + \frac{a}{\frac{z}{t}} \cdot -0.5}\\ \end{array} \]
Alternative 12
Accuracy71.0%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{-260}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-114}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 13
Accuracy73.1%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{-257}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-114}:\\ \;\;\;\;\frac{x \cdot \left(z \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 14
Accuracy72.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{-256}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-122}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 15
Accuracy72.9%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-233}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.08 \cdot 10^{-126}:\\ \;\;\;\;-1 + \left(1 - x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 16
Accuracy70.3%
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 17
Accuracy43.7%
Cost192
\[x \cdot y \]

Error

Reproduce?

herbie shell --seed 2023141 
(FPCore (x y z t a)
  :name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))

  (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))