Average Error: 24.3 → 7.4
Time: 25.0s
Precision: binary64
Cost: 7496
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+56}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+33}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \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
 (if (<= z -1.9e+56)
   (* y (- x))
   (if (<= z 2.2e+33) (* x (/ (* z y) (sqrt (- (* z z) (* t a))))) (* 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 tmp;
	if (z <= -1.9e+56) {
		tmp = y * -x;
	} else if (z <= 2.2e+33) {
		tmp = x * ((z * y) / sqrt(((z * z) - (t * a))));
	} else {
		tmp = y * x;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((x * y) * z) / sqrt(((z * z) - (t * a)))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if (z <= (-1.9d+56)) then
        tmp = y * -x
    else if (z <= 2.2d+33) then
        tmp = x * ((z * y) / sqrt(((z * z) - (t * a))))
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) * z) / Math.sqrt(((z * z) - (t * a)));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -1.9e+56) {
		tmp = y * -x;
	} else if (z <= 2.2e+33) {
		tmp = x * ((z * y) / Math.sqrt(((z * z) - (t * a))));
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y, z, t, a):
	return ((x * y) * z) / math.sqrt(((z * z) - (t * a)))
def code(x, y, z, t, a):
	tmp = 0
	if z <= -1.9e+56:
		tmp = y * -x
	elif z <= 2.2e+33:
		tmp = x * ((z * y) / math.sqrt(((z * z) - (t * a))))
	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)
	tmp = 0.0
	if (z <= -1.9e+56)
		tmp = Float64(y * Float64(-x));
	elseif (z <= 2.2e+33)
		tmp = Float64(x * Float64(Float64(z * y) / sqrt(Float64(Float64(z * z) - Float64(t * a)))));
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) * z) / sqrt(((z * z) - (t * a)));
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (z <= -1.9e+56)
		tmp = y * -x;
	elseif (z <= 2.2e+33)
		tmp = x * ((z * y) / sqrt(((z * z) - (t * a))));
	else
		tmp = y * x;
	end
	tmp_2 = 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, -1.9e+56], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 2.2e+33], N[(x * N[(N[(z * y), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+56}:\\
\;\;\;\;y \cdot \left(-x\right)\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.3
Target7.8
Herbie7.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 < -1.89999999999999998e56

    1. Initial program 37.9

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot x\right)} \]
    4. Simplified3.6

      \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
      Proof
      (*.f64 y (neg.f64 x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y x))): 0 points increase in error, 0 points decrease in error

    if -1.89999999999999998e56 < z < 2.19999999999999994e33

    1. Initial program 11.3

      \[\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}}} \]
      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))))): 40 points increase in error, 13 points decrease in error
      (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 8 points increase in error, 35 points decrease in error

    if 2.19999999999999994e33 < z

    1. Initial program 35.6

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

      \[\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))))): 40 points increase in error, 13 points decrease in error
      (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 8 points increase in error, 35 points decrease in error
    3. Taylor expanded in z around inf 4.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+56}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+33}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Alternatives

Alternative 1
Error8.1
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -140:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+33}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error12.6
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -2.95 \cdot 10^{-151}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-74}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error16.3
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-152}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+33}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 4
Error17.6
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-152}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-74}:\\ \;\;\;\;x \cdot \left(-2 \cdot \left(z \cdot \frac{y}{t \cdot \frac{a}{z}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Error18.2
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{-157}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-134}:\\ \;\;\;\;x \cdot \left(\left(y + 1\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error17.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-179}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-72}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error19.8
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-278}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Error37.3
Cost192
\[y \cdot x \]

Error

Reproduce

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