Average Error: 24.8 → 6.5
Time: 34.1s
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 -4.2 \cdot 10^{+157}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 10^{+95}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \left(a \cdot \frac{t}{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
 (if (<= z -4.2e+157)
   (* y (- x))
   (if (<= z 1e+95)
     (* x (* y (/ z (sqrt (- (* z z) (* t a))))))
     (* x (* y (/ z (+ z (* -0.5 (* a (/ t 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 tmp;
	if (z <= -4.2e+157) {
		tmp = y * -x;
	} else if (z <= 1e+95) {
		tmp = x * (y * (z / sqrt(((z * z) - (t * a)))));
	} else {
		tmp = x * (y * (z / (z + (-0.5 * (a * (t / z))))));
	}
	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 <= (-4.2d+157)) then
        tmp = y * -x
    else if (z <= 1d+95) then
        tmp = x * (y * (z / sqrt(((z * z) - (t * a)))))
    else
        tmp = x * (y * (z / (z + ((-0.5d0) * (a * (t / z))))))
    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 <= -4.2e+157) {
		tmp = y * -x;
	} else if (z <= 1e+95) {
		tmp = x * (y * (z / Math.sqrt(((z * z) - (t * a)))));
	} else {
		tmp = x * (y * (z / (z + (-0.5 * (a * (t / z))))));
	}
	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 <= -4.2e+157:
		tmp = y * -x
	elif z <= 1e+95:
		tmp = x * (y * (z / math.sqrt(((z * z) - (t * a)))))
	else:
		tmp = x * (y * (z / (z + (-0.5 * (a * (t / 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)
	tmp = 0.0
	if (z <= -4.2e+157)
		tmp = Float64(y * Float64(-x));
	elseif (z <= 1e+95)
		tmp = Float64(x * Float64(y * Float64(z / sqrt(Float64(Float64(z * z) - Float64(t * a))))));
	else
		tmp = Float64(x * Float64(y * Float64(z / Float64(z + Float64(-0.5 * Float64(a * Float64(t / z)))))));
	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 <= -4.2e+157)
		tmp = y * -x;
	elseif (z <= 1e+95)
		tmp = x * (y * (z / sqrt(((z * z) - (t * a)))));
	else
		tmp = x * (y * (z / (z + (-0.5 * (a * (t / z))))));
	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, -4.2e+157], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 1e+95], N[(x * N[(y * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * N[(z / N[(z + N[(-0.5 * N[(a * N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+157}:\\
\;\;\;\;y \cdot \left(-x\right)\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \left(a \cdot \frac{t}{z}\right)}\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.8
Target8.2
Herbie6.5
\[\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.2e157

    1. Initial program 54.2

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

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

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

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

    if -4.2e157 < z < 1.00000000000000002e95

    1. Initial program 11.7

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

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

    if 1.00000000000000002e95 < z

    1. Initial program 43.3

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

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

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

      \[\leadsto x \cdot \left(y \cdot \frac{z}{\color{blue}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}}\right) \]
      Proof
      (*.f64 (neg.f64 y) x): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 y)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r*_binary64 (*.f64 -1 (*.f64 y x))): 3 points increase in error, 0 points decrease in error
    5. Applied egg-rr2.6

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

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

Alternatives

Alternative 1
Error12.4
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -3.55 \cdot 10^{-56}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-183}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{t \cdot \left(-a\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \left(a \cdot \frac{t}{z}\right)}\right)\\ \end{array} \]
Alternative 2
Error12.1
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{-56}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-101}:\\ \;\;\;\;\frac{x}{\sqrt{t \cdot \left(-a\right)}} \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \left(a \cdot \frac{t}{z}\right)}\right)\\ \end{array} \]
Alternative 3
Error12.2
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.28 \cdot 10^{-55}:\\ \;\;\;\;\frac{x}{0.5 \cdot \frac{a}{\frac{y \cdot \left(z \cdot z\right)}{t}} + \frac{-1}{y}}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-183}:\\ \;\;\;\;\frac{x}{\frac{\sqrt{t \cdot \left(-a\right)}}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \left(a \cdot \frac{t}{z}\right)}\right)\\ \end{array} \]
Alternative 4
Error17.4
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{-181}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{-202}:\\ \;\;\;\;-2 \cdot \frac{y}{\frac{t \cdot a}{x \cdot \left(z \cdot z\right)}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Error17.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-146}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-164}:\\ \;\;\;\;2 \cdot \left(\frac{y}{a} \cdot \frac{x \cdot \left(z \cdot z\right)}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error17.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-173}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-149}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(\left(\frac{z}{t} \cdot \frac{y}{a}\right) \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error17.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{-141}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-155}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(2 \cdot \left(\frac{z}{t} \cdot \frac{y}{a}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Error17.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8 \cdot 10^{-148}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-164}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{\frac{t}{z} \cdot \left(a \cdot 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 9
Error17.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{-148}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-162}:\\ \;\;\;\;\frac{\left(y \cdot \frac{z}{t}\right) \cdot \left(z \cdot x\right)}{a \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Error15.8
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{-184}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \left(a \cdot \frac{t}{z}\right)}\right)\\ \end{array} \]
Alternative 11
Error17.5
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{-200}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-111}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Error17.4
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-153}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{-157}:\\ \;\;\;\;\left(1 - y \cdot x\right) + -1\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 13
Error19.1
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -3.3 \cdot 10^{-284}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Error37.0
Cost192
\[y \cdot x \]

Error

Reproduce

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