Average Error: 24.9 → 6.4
Time: 37.1s
Precision: binary64
Cost: 14092
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} t_1 := \sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}\\ \mathbf{if}\;z \leq -4200000:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+93}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;y \cdot z \ne 0:\\ \;\;\;\;\frac{x}{\frac{t_1}{y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot y\right) \cdot z}{t_1}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \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 (sqrt (fma z z (- (* a t))))))
   (if (<= z -4200000.0)
     (- (* x y))
     (if (<= z 3.5e+93)
       (if (!= (* y z) 0.0) (/ x (/ t_1 (* y z))) (/ (* (* x y) z) t_1))
       (* y x)))))
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 = sqrt(fma(z, z, -(a * t)));
	double tmp;
	if (z <= -4200000.0) {
		tmp = -(x * y);
	} else if (z <= 3.5e+93) {
		double tmp_1;
		if ((y * z) != 0.0) {
			tmp_1 = x / (t_1 / (y * z));
		} else {
			tmp_1 = ((x * y) * z) / t_1;
		}
		tmp = tmp_1;
	} else {
		tmp = y * x;
	}
	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 = sqrt(fma(z, z, Float64(-Float64(a * t))))
	tmp = 0.0
	if (z <= -4200000.0)
		tmp = Float64(-Float64(x * y));
	elseif (z <= 3.5e+93)
		tmp_1 = 0.0
		if (Float64(y * z) != 0.0)
			tmp_1 = Float64(x / Float64(t_1 / Float64(y * z)));
		else
			tmp_1 = Float64(Float64(Float64(x * y) * z) / t_1);
		end
		tmp = tmp_1;
	else
		tmp = Float64(y * x);
	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[Sqrt[N[(z * z + (-N[(a * t), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -4200000.0], (-N[(x * y), $MachinePrecision]), If[LessEqual[z, 3.5e+93], If[Unequal[N[(y * z), $MachinePrecision], 0.0], N[(x / N[(t$95$1 / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] / t$95$1), $MachinePrecision]], N[(y * x), $MachinePrecision]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}\\
\mathbf{if}\;z \leq -4200000:\\
\;\;\;\;-x \cdot y\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;y \cdot z \ne 0:\\
\;\;\;\;\frac{x}{\frac{t_1}{y \cdot z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot y\right) \cdot z}{t_1}\\


\end{array}\\

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


\end{array}

Error

Target

Original24.9
Target7.5
Herbie6.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.2e6

    1. Initial program 33.6

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Taylor expanded in z around -inf 5.1

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot x\right)} \]
    3. Simplified5.1

      \[\leadsto \color{blue}{-x \cdot y} \]
      Proof

    if -4.2e6 < z < 3.49999999999999998e93

    1. Initial program 11.7

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

      \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;y \cdot z \ne 0:\\ \;\;\;\;\frac{x}{\frac{\frac{\sqrt{\mathsf{fma}\left(z, z, -t \cdot a\right)}}{z}}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot y\right) \cdot z}{\sqrt{\mathsf{fma}\left(z, z, -t \cdot a\right)}}\\ } \end{array}} \]
    3. Simplified9.0

      \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;y \cdot z \ne 0:\\ \;\;\;\;\frac{x}{\frac{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}}{y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot y\right) \cdot z}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}}\\ } \end{array}} \]
      Proof

    if 3.49999999999999998e93 < z

    1. Initial program 42.5

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Taylor expanded in z around inf 2.3

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error7.1
Cost13832
\[\begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+97}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{+95}:\\ \;\;\;\;\frac{y \cdot z}{\sqrt{\mathsf{fma}\left(z, z, -t \cdot a\right)}} \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error7.1
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{+102}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+90}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{z \cdot z - t \cdot a}} \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error12.5
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -5.7 \cdot 10^{-86}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-61}:\\ \;\;\;\;\frac{x \cdot y}{\sqrt{-a \cdot t}} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{\left(-0.5 \cdot a\right) \cdot t}{z} + z} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 4
Error12.5
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.85 \cdot 10^{-86}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-62}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot x}{\sqrt{-a \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{\left(-0.5 \cdot a\right) \cdot t}{z} + z} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 5
Error16.2
Cost1356
\[\begin{array}{l} t_1 := -x \cdot y\\ \mathbf{if}\;z \leq -4.35 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-157}:\\ \;\;\;\;\frac{x \cdot y}{0.5 \cdot \frac{a \cdot t}{z} + -1 \cdot z} \cdot z\\ \mathbf{elif}\;z \leq -8.6 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{\left(-0.5 \cdot a\right) \cdot t}{z} + z} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 6
Error15.9
Cost1352
\[\begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{-58}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-276}:\\ \;\;\;\;\frac{\left(x \cdot y\right) \cdot z}{0.5 \cdot \frac{a \cdot t}{z} + -1 \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{\left(-0.5 \cdot a\right) \cdot t}{z} + z} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 7
Error17.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -1.95 \cdot 10^{-112}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-143}:\\ \;\;\;\;\frac{-2 \cdot \left(\left(\left(z \cdot z\right) \cdot y\right) \cdot x\right)}{a \cdot t}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Error16.5
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-189}:\\ \;\;\;\;-x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{\left(-0.5 \cdot a\right) \cdot t}{z} + z} \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 9
Error17.2
Cost776
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-112}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-160}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot x}{-z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Error17.7
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-225}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 1.26 \cdot 10^{-154}:\\ \;\;\;\;\frac{\left(x \cdot y\right) \cdot z}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 11
Error17.3
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{-208}:\\ \;\;\;\;-x \cdot y\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-155}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Error19.1
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -2.75 \cdot 10^{-303}:\\ \;\;\;\;-x \cdot y\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 13
Error36.3
Cost192
\[y \cdot x \]

Error

Reproduce

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