?

Average Error: 24.5 → 7.7
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 -620000:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+26}:\\ \;\;\;\;\frac{z}{\sqrt{z \cdot z - t \cdot a}} \cdot \left(y \cdot x\right)\\ \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 -620000.0)
   (* y (- x))
   (if (<= z 1.2e+26) (* (/ z (sqrt (- (* z z) (* t a)))) (* y x)) (* 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 <= -620000.0) {
		tmp = y * -x;
	} else if (z <= 1.2e+26) {
		tmp = (z / sqrt(((z * z) - (t * a)))) * (y * x);
	} 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 <= (-620000.0d0)) then
        tmp = y * -x
    else if (z <= 1.2d+26) then
        tmp = (z / sqrt(((z * z) - (t * a)))) * (y * x)
    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 <= -620000.0) {
		tmp = y * -x;
	} else if (z <= 1.2e+26) {
		tmp = (z / Math.sqrt(((z * z) - (t * a)))) * (y * x);
	} 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 <= -620000.0:
		tmp = y * -x
	elif z <= 1.2e+26:
		tmp = (z / math.sqrt(((z * z) - (t * a)))) * (y * x)
	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 <= -620000.0)
		tmp = Float64(y * Float64(-x));
	elseif (z <= 1.2e+26)
		tmp = Float64(Float64(z / sqrt(Float64(Float64(z * z) - Float64(t * a)))) * Float64(y * x));
	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 <= -620000.0)
		tmp = y * -x;
	elseif (z <= 1.2e+26)
		tmp = (z / sqrt(((z * z) - (t * a)))) * (y * x);
	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, -620000.0], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 1.2e+26], N[(N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * x), $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 -620000:\\
\;\;\;\;y \cdot \left(-x\right)\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.5
Target7.9
Herbie7.7
\[\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 < -6.2e5

    1. Initial program 33.3

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

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

      [Start]33.3

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

      associate-*r/ [<=]30.7

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

      *-commutative [<=]30.7

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

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

      \[\leadsto \color{blue}{\left(-y\right) \cdot x} \]
      Proof

      [Start]5.7

      \[ -1 \cdot \left(y \cdot x\right) \]

      *-commutative [<=]5.7

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

      mul-1-neg [=>]5.7

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

      *-commutative [=>]5.7

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

      distribute-lft-neg-in [=>]5.7

      \[ \color{blue}{\left(-y\right) \cdot x} \]

    if -6.2e5 < z < 1.20000000000000002e26

    1. Initial program 11.9

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

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

      [Start]11.9

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

      associate-*r/ [<=]11.1

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

      *-commutative [<=]11.1

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

    if 1.20000000000000002e26 < z

    1. Initial program 34.8

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

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

      [Start]34.8

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

      associate-*r/ [<=]31.9

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

      *-commutative [<=]31.9

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

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

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

Alternatives

Alternative 1
Error7.6
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -620000:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+26}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error7.8
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -620000:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+26}:\\ \;\;\;\;y \cdot \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error12.4
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-69}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{t \cdot \left(-a\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)}\\ \end{array} \]
Alternative 4
Error12.5
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{-129}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-69}:\\ \;\;\;\;y \cdot \frac{x}{\frac{\sqrt{t \cdot \left(-a\right)}}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)}\\ \end{array} \]
Alternative 5
Error12.4
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{-128}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-68}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)}\\ \end{array} \]
Alternative 6
Error16.9
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -2.75 \cdot 10^{-132}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-93}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error17.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-136}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-159}:\\ \;\;\;\;-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 8
Error17.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{-130}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-161}:\\ \;\;\;\;-2 \cdot \left(\frac{z \cdot \left(z \cdot x\right)}{t} \cdot \frac{y}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 9
Error17.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{-136}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-167}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(\frac{-2}{t} \cdot \left(z \cdot \frac{y}{a}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Error17.2
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-166}:\\ \;\;\;\;y \cdot \left(\frac{-2}{a} \cdot \frac{z \cdot \left(z \cdot x\right)}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 11
Error16.9
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-132}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{\frac{z + -0.5 \cdot \frac{t \cdot a}{z}}{z}}\\ \end{array} \]
Alternative 12
Error16.1
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-135}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)}\\ \end{array} \]
Alternative 13
Error18.9
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{-269}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-131}:\\ \;\;\;\;\frac{x}{\frac{z}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Error17.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-171}:\\ \;\;\;\;\left(1 - y \cdot x\right) + -1\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 15
Error19.7
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-273}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 16
Error36.7
Cost192
\[y \cdot x \]

Error

Reproduce?

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