?

Average Accuracy: 61.6% → 90.4%
Time: 32.6s
Precision: binary64
Cost: 7496

?

\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} t_1 := \frac{a}{z \cdot z} \cdot t\\ \mathbf{if}\;z \leq -4 \cdot 10^{+142}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\ \mathbf{elif}\;z \leq 410:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{1 - t_1}}\\ \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
 (let* ((t_1 (* (/ a (* z z)) t)))
   (if (<= z -4e+142)
     (/ (* x y) (fma 0.5 t_1 -1.0))
     (if (<= z 410.0)
       (* x (* y (/ z (sqrt (- (* z z) (* a t))))))
       (/ (* x y) (sqrt (- 1.0 t_1)))))))
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 t_1 = (a / (z * z)) * t;
	double tmp;
	if (z <= -4e+142) {
		tmp = (x * y) / fma(0.5, t_1, -1.0);
	} else if (z <= 410.0) {
		tmp = x * (y * (z / sqrt(((z * z) - (a * t)))));
	} else {
		tmp = (x * y) / sqrt((1.0 - t_1));
	}
	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)
	t_1 = Float64(Float64(a / Float64(z * z)) * t)
	tmp = 0.0
	if (z <= -4e+142)
		tmp = Float64(Float64(x * y) / fma(0.5, t_1, -1.0));
	elseif (z <= 410.0)
		tmp = Float64(x * Float64(y * Float64(z / sqrt(Float64(Float64(z * z) - Float64(a * t))))));
	else
		tmp = Float64(Float64(x * y) / sqrt(Float64(1.0 - t_1)));
	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_] := Block[{t$95$1 = N[(N[(a / N[(z * z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z, -4e+142], N[(N[(x * y), $MachinePrecision] / N[(0.5 * t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 410.0], N[(x * N[(y * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \frac{a}{z \cdot z} \cdot t\\
\mathbf{if}\;z \leq -4 \cdot 10^{+142}:\\
\;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\

\mathbf{elif}\;z \leq 410:\\
\;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{\sqrt{1 - t_1}}\\


\end{array}

Error?

Target

Original61.6%
Target87.6%
Herbie90.4%
\[\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 < -4.0000000000000002e142

    1. Initial program 21.0%

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

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

      [Start]21.0

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

      associate-/l* [=>]23.1

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{0.5 \cdot \frac{a \cdot t}{{z}^{2}} - 1}} \]
    4. Simplified97.9%

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

      [Start]89.9

      \[ \frac{x \cdot y}{0.5 \cdot \frac{a \cdot t}{{z}^{2}} - 1} \]

      fma-neg [=>]89.9

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

      associate-/l* [=>]97.9

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

      associate-/r/ [=>]97.9

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

      unpow2 [=>]97.9

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

      metadata-eval [=>]97.9

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

    if -4.0000000000000002e142 < z < 410

    1. Initial program 81.6%

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

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

      [Start]81.6

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

      associate-*r/ [<=]84.2

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

      associate-*l* [=>]84.4

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

    if 410 < z

    1. Initial program 47.7%

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

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

      [Start]47.7

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

      associate-/l* [=>]51.7

      \[ \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    3. Applied egg-rr42.7%

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

      [Start]51.7

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

      add-sqr-sqrt [=>]51.6

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

      sqrt-unprod [=>]51.7

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

      frac-times [=>]42.7

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

      add-sqr-sqrt [<=]42.7

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

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

      [Start]42.7

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

      *-commutative [=>]42.7

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

      div-sub [=>]42.7

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

      unpow2 [<=]42.7

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

      unpow2 [<=]42.7

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

      *-inverses [=>]90.6

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

      unpow2 [<=]90.6

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

      associate-/l* [=>]97.4

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

      associate-/r/ [=>]97.4

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

      unpow2 [=>]97.4

      \[ \frac{x \cdot y}{\sqrt{1 - \frac{a}{\color{blue}{z \cdot z}} \cdot t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.4%

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

Alternatives

Alternative 1
Accuracy89.7%
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+142}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+39}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 2
Accuracy90.4%
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+141}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 500:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{1 - \frac{a}{z \cdot z} \cdot t}}\\ \end{array} \]
Alternative 3
Accuracy80.1%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-59}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{a \cdot \left(-t\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 4
Accuracy80.1%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-58}:\\ \;\;\;\;\frac{x}{\frac{\sqrt{a \cdot \left(-t\right)}}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 5
Accuracy76.6%
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -4.7 \cdot 10^{+41}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{-303}:\\ \;\;\;\;x \cdot \left(z \cdot \frac{y}{a \cdot \left(0.5 \cdot \frac{t}{z}\right) - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 6
Accuracy74.9%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-93}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 7
Accuracy76.1%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{-269}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \frac{a \cdot t}{z} - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 8
Accuracy70.2%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{-253}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-191}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 9
Accuracy71.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{-220}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-132}:\\ \;\;\;\;\frac{x}{\frac{z}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 10
Accuracy72.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.28 \cdot 10^{-92}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-143}:\\ \;\;\;\;-1 + \left(1 - x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 11
Accuracy69.6%
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -2.15 \cdot 10^{-290}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 12
Accuracy43.2%
Cost192
\[x \cdot y \]

Error

Reproduce?

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