Average Error: 24.7 → 6.1
Time: 30.5s
Precision: binary64
Cost: 13964
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ [t, a] = \mathsf{sort}([t, a])\\ \end{array} \]
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} t_1 := \frac{t}{z} \cdot \frac{a}{z}\\ \mathbf{if}\;z \leq -2.25 \cdot 10^{+105}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-123}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-81}:\\ \;\;\;\;\left({\left(-t\right)}^{-0.5} \cdot {a}^{-0.5}\right) \cdot \left(x \cdot \left(z \cdot y\right)\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 (* (/ t z) (/ a z))))
   (if (<= z -2.25e+105)
     (/ (* x y) (fma 0.5 t_1 -1.0))
     (if (<= z -2.6e-123)
       (* x (/ (* z y) (sqrt (- (* z z) (* t a)))))
       (if (<= z 6.6e-81)
         (* (* (pow (- t) -0.5) (pow a -0.5)) (* x (* z y)))
         (/ (* 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 = (t / z) * (a / z);
	double tmp;
	if (z <= -2.25e+105) {
		tmp = (x * y) / fma(0.5, t_1, -1.0);
	} else if (z <= -2.6e-123) {
		tmp = x * ((z * y) / sqrt(((z * z) - (t * a))));
	} else if (z <= 6.6e-81) {
		tmp = (pow(-t, -0.5) * pow(a, -0.5)) * (x * (z * y));
	} 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(t / z) * Float64(a / z))
	tmp = 0.0
	if (z <= -2.25e+105)
		tmp = Float64(Float64(x * y) / fma(0.5, t_1, -1.0));
	elseif (z <= -2.6e-123)
		tmp = Float64(x * Float64(Float64(z * y) / sqrt(Float64(Float64(z * z) - Float64(t * a)))));
	elseif (z <= 6.6e-81)
		tmp = Float64(Float64((Float64(-t) ^ -0.5) * (a ^ -0.5)) * Float64(x * Float64(z * y)));
	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[(t / z), $MachinePrecision] * N[(a / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.25e+105], N[(N[(x * y), $MachinePrecision] / N[(0.5 * t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2.6e-123], N[(x * N[(N[(z * y), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.6e-81], N[(N[(N[Power[(-t), -0.5], $MachinePrecision] * N[Power[a, -0.5], $MachinePrecision]), $MachinePrecision] * N[(x * N[(z * y), $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{t}{z} \cdot \frac{a}{z}\\
\mathbf{if}\;z \leq -2.25 \cdot 10^{+105}:\\
\;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\

\mathbf{elif}\;z \leq -2.6 \cdot 10^{-123}:\\
\;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\

\mathbf{elif}\;z \leq 6.6 \cdot 10^{-81}:\\
\;\;\;\;\left({\left(-t\right)}^{-0.5} \cdot {a}^{-0.5}\right) \cdot \left(x \cdot \left(z \cdot y\right)\right)\\

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


\end{array}

Error

Target

Original24.7
Target8.0
Herbie6.1
\[\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 4 regimes
  2. if z < -2.2500000000000001e105

    1. Initial program 44.8

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
      Proof
      (/.f64 (*.f64 x y) (/.f64 (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))) z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (*.f64 x y) z) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 42 points increase in error, 7 points decrease in error
    3. Taylor expanded in z around -inf 6.6

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{\mathsf{fma}\left(0.5, \frac{t}{z} \cdot \frac{a}{z}, -1\right)}} \]
      Proof
      (fma.f64 1/2 (*.f64 (/.f64 t z) (/.f64 a z)) -1): 0 points increase in error, 0 points decrease in error
      (fma.f64 1/2 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 t a) (*.f64 z z))) -1): 22 points increase in error, 8 points decrease in error
      (fma.f64 1/2 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 a t)) (*.f64 z z)) -1): 0 points increase in error, 0 points decrease in error
      (fma.f64 1/2 (/.f64 (*.f64 a t) (Rewrite<= unpow2_binary64 (pow.f64 z 2))) -1): 0 points increase in error, 0 points decrease in error
      (fma.f64 1/2 (/.f64 (*.f64 a t) (pow.f64 z 2)) (Rewrite<= metadata-eval (neg.f64 1))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 1/2 (/.f64 (*.f64 a t) (pow.f64 z 2))) 1)): 0 points increase in error, 0 points decrease in error

    if -2.2500000000000001e105 < z < -2.59999999999999995e-123

    1. Initial program 7.7

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

      \[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
      Proof
      (*.f64 x (/.f64 (*.f64 y z) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x (*.f64 y z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 39 points increase in error, 15 points decrease in error
      (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 10 points increase in error, 41 points decrease in error

    if -2.59999999999999995e-123 < z < 6.59999999999999975e-81

    1. Initial program 16.0

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Applied egg-rr15.3

      \[\leadsto \color{blue}{{\left(z \cdot z - t \cdot a\right)}^{-0.5} \cdot \left(x \cdot \left(y \cdot z\right)\right)} \]
    3. Taylor expanded in a around inf 16.3

      \[\leadsto \color{blue}{e^{-0.5 \cdot \left(\log \left(-t\right) + -1 \cdot \log \left(\frac{1}{a}\right)\right)}} \cdot \left(x \cdot \left(y \cdot z\right)\right) \]
    4. Simplified14.0

      \[\leadsto \color{blue}{\left({\left(-t\right)}^{-0.5} \cdot {a}^{-0.5}\right)} \cdot \left(x \cdot \left(y \cdot z\right)\right) \]
      Proof
      (*.f64 (pow.f64 (neg.f64 t) -1/2) (pow.f64 a -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (neg.f64 t)) -1/2))) (pow.f64 a -1/2)): 90 points increase in error, 80 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 t)) -1/2)) (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 a) -1/2)))): 90 points increase in error, 83 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 t)) -1/2)) (exp.f64 (*.f64 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (log.f64 a)))) -1/2))): 0 points increase in error, 0 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 t)) -1/2)) (exp.f64 (*.f64 (neg.f64 (Rewrite<= log-rec_binary64 (log.f64 (/.f64 1 a)))) -1/2))): 0 points increase in error, 0 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 t)) -1/2)) (exp.f64 (*.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (log.f64 (/.f64 1 a)))) -1/2))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= exp-sum_binary64 (exp.f64 (+.f64 (*.f64 (log.f64 (neg.f64 t)) -1/2) (*.f64 (*.f64 -1 (log.f64 (/.f64 1 a))) -1/2)))): 52 points increase in error, 66 points decrease in error
      (exp.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 -1/2 (+.f64 (log.f64 (neg.f64 t)) (*.f64 -1 (log.f64 (/.f64 1 a))))))): 0 points increase in error, 0 points decrease in error

    if 6.59999999999999975e-81 < z

    1. Initial program 28.1

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
      Proof
      (/.f64 (*.f64 x y) (/.f64 (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))) z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (*.f64 x y) z) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 42 points increase in error, 7 points decrease in error
    3. Applied egg-rr30.9

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{\sqrt{1 - \frac{t}{z} \cdot \frac{a}{z}}}} \]
      Proof
      (sqrt.f64 (-.f64 1 (*.f64 (/.f64 t z) (/.f64 a z)))): 0 points increase in error, 0 points decrease in error
      (sqrt.f64 (-.f64 (Rewrite<= *-inverses_binary64 (/.f64 (*.f64 z z) (*.f64 z z))) (*.f64 (/.f64 t z) (/.f64 a z)))): 87 points increase in error, 0 points decrease in error
      (sqrt.f64 (-.f64 (/.f64 (*.f64 z z) (*.f64 z z)) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 t a) (*.f64 z z))))): 6 points increase in error, 5 points decrease in error
      (sqrt.f64 (Rewrite<= div-sub_binary64 (/.f64 (-.f64 (*.f64 z z) (*.f64 t a)) (*.f64 z z)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 4 regimes into one program.
  4. Final simplification6.1

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

Alternatives

Alternative 1
Error7.2
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+110}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+61}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error6.4
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -1.12 \cdot 10^{+106}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-81}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{1 - \frac{t}{z} \cdot \frac{a}{z}}}\\ \end{array} \]
Alternative 3
Error6.3
Cost7496
\[\begin{array}{l} t_1 := \frac{t}{z} \cdot \frac{a}{z}\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+107}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-81}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{1 - t_1}}\\ \end{array} \]
Alternative 4
Error6.5
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{+67}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \left(t \cdot \frac{a}{z}\right) - z}\right)\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-80}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{1 - \frac{t}{z} \cdot \frac{a}{z}}}\\ \end{array} \]
Alternative 5
Error11.5
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -5.7 \cdot 10^{-123}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \left(t \cdot \frac{a}{z}\right) - z}\right)\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-72}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 6
Error11.8
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{-137}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \left(t \cdot \frac{a}{z}\right) - z}\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-73}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error16.1
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq 4.8 \cdot 10^{-80}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \left(t \cdot \frac{a}{z}\right) - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 8
Error16.1
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq 1.5 \cdot 10^{-79}:\\ \;\;\;\;x \cdot \frac{y}{-1 + \frac{t}{\frac{z}{\frac{0.5 \cdot a}{z}}}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 9
Error17.6
Cost1032
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-46}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-80}:\\ \;\;\;\;\frac{-1 + \left(x \cdot \left(z \cdot y\right) + 1\right)}{-z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 10
Error18.1
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{-229}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-149}:\\ \;\;\;\;\frac{y}{\frac{z}{z \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 11
Error17.5
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{-236}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 10^{-76}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 12
Error17.7
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-46}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-80}:\\ \;\;\;\;-1 + \left(1 - x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 13
Error17.2
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{-194}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-78}:\\ \;\;\;\;1 + \left(-1 + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 14
Error19.3
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{-267}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 15
Error36.9
Cost192
\[x \cdot y \]

Error

Reproduce

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