Average Error: 24.6 → 6.1
Time: 9.7s
Precision: binary64
\[ \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} t_1 := \frac{a}{z} \cdot t\\ \mathbf{if}\;z \leq -1.85 \cdot 10^{+155}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{z}{\mathsf{fma}\left(0.5, t_1, -z\right)}\right)\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{+129}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{z}{\mathsf{fma}\left(-0.5, t_1, z\right)}\right)\\ \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) t)))
   (if (<= z -1.85e+155)
     (* y (* x (/ z (fma 0.5 t_1 (- z)))))
     (if (<= z 8.8e+129)
       (* y (* x (/ z (sqrt (- (* z z) (* a t))))))
       (* y (* x (/ z (fma -0.5 t_1 z))))))))
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) * t;
	double tmp;
	if (z <= -1.85e+155) {
		tmp = y * (x * (z / fma(0.5, t_1, -z)));
	} else if (z <= 8.8e+129) {
		tmp = y * (x * (z / sqrt(((z * z) - (a * t)))));
	} else {
		tmp = y * (x * (z / fma(-0.5, t_1, z)));
	}
	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 / z) * t)
	tmp = 0.0
	if (z <= -1.85e+155)
		tmp = Float64(y * Float64(x * Float64(z / fma(0.5, t_1, Float64(-z)))));
	elseif (z <= 8.8e+129)
		tmp = Float64(y * Float64(x * Float64(z / sqrt(Float64(Float64(z * z) - Float64(a * t))))));
	else
		tmp = Float64(y * Float64(x * Float64(z / fma(-0.5, t_1, z))));
	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 / z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z, -1.85e+155], N[(y * N[(x * N[(z / N[(0.5 * t$95$1 + (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.8e+129], N[(y * N[(x * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * N[(z / N[(-0.5 * t$95$1 + z), $MachinePrecision]), $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 t\\
\mathbf{if}\;z \leq -1.85 \cdot 10^{+155}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{z}{\mathsf{fma}\left(0.5, t_1, -z\right)}\right)\\

\mathbf{elif}\;z \leq 8.8 \cdot 10^{+129}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{z}{\mathsf{fma}\left(-0.5, t_1, z\right)}\right)\\


\end{array}

Error

Target

Original24.6
Target7.5
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 3 regimes
  2. if z < -1.8499999999999999e155

    1. Initial program 53.8

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

      \[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
    3. Applied egg-rr53.5

      \[\leadsto \color{blue}{\frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. Applied egg-rr53.5

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

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

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

    if -1.8499999999999999e155 < z < 8.7999999999999997e129

    1. Initial program 11.1

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

      \[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
    3. Applied egg-rr9.2

      \[\leadsto \color{blue}{\frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. Applied egg-rr8.4

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

    if 8.7999999999999997e129 < z

    1. Initial program 48.6

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

      \[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
    3. Applied egg-rr46.8

      \[\leadsto \color{blue}{\frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. Applied egg-rr46.8

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

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

      \[\leadsto y \cdot \left(x \cdot \frac{z}{\color{blue}{\mathsf{fma}\left(-0.5, \frac{a}{z} \cdot t, z\right)}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.1

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

Reproduce

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