?

Average Error: 24.7 → 5.5
Time: 34.1s
Precision: binary64
Cost: 7496

?

\[ \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} \mathbf{if}\;z \leq -1.15 \cdot 10^{+153}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 40:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\sqrt{1 - \frac{a}{\frac{z}{\frac{t}{z}}}}}\\ \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.15e+153)
   (* y (- x))
   (if (<= z 40.0)
     (* x (* y (/ z (sqrt (- (* z z) (* t a))))))
     (* x (/ y (sqrt (- 1.0 (/ a (/ z (/ 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 <= -1.15e+153) {
		tmp = y * -x;
	} else if (z <= 40.0) {
		tmp = x * (y * (z / sqrt(((z * z) - (t * a)))));
	} else {
		tmp = x * (y / sqrt((1.0 - (a / (z / (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 <= (-1.15d+153)) then
        tmp = y * -x
    else if (z <= 40.0d0) then
        tmp = x * (y * (z / sqrt(((z * z) - (t * a)))))
    else
        tmp = x * (y / sqrt((1.0d0 - (a / (z / (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 <= -1.15e+153) {
		tmp = y * -x;
	} else if (z <= 40.0) {
		tmp = x * (y * (z / Math.sqrt(((z * z) - (t * a)))));
	} else {
		tmp = x * (y / Math.sqrt((1.0 - (a / (z / (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 <= -1.15e+153:
		tmp = y * -x
	elif z <= 40.0:
		tmp = x * (y * (z / math.sqrt(((z * z) - (t * a)))))
	else:
		tmp = x * (y / math.sqrt((1.0 - (a / (z / (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 <= -1.15e+153)
		tmp = Float64(y * Float64(-x));
	elseif (z <= 40.0)
		tmp = Float64(x * Float64(y * Float64(z / sqrt(Float64(Float64(z * z) - Float64(t * a))))));
	else
		tmp = Float64(x * Float64(y / sqrt(Float64(1.0 - Float64(a / Float64(z / 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 <= -1.15e+153)
		tmp = y * -x;
	elseif (z <= 40.0)
		tmp = x * (y * (z / sqrt(((z * z) - (t * a)))));
	else
		tmp = x * (y / sqrt((1.0 - (a / (z / (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, -1.15e+153], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 40.0], 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[Sqrt[N[(1.0 - N[(a / N[(z / 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 -1.15 \cdot 10^{+153}:\\
\;\;\;\;y \cdot \left(-x\right)\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{\sqrt{1 - \frac{a}{\frac{z}{\frac{t}{z}}}}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.7
Target7.8
Herbie5.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 < -1.1500000000000001e153

    1. Initial program 54.4

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

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

      [Start]54.4

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

      *-commutative [=>]54.4

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

      associate-*l* [=>]54.7

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

      associate-*l/ [<=]54.5

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

      *-commutative [=>]54.5

      \[ \color{blue}{\left(x \cdot z\right) \cdot \frac{y}{\sqrt{z \cdot z - t \cdot a}}} \]
    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

      [Start]1.5

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

      associate-*r* [=>]1.5

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

      neg-mul-1 [<=]1.5

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

    if -1.1500000000000001e153 < z < 40

    1. Initial program 11.3

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

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

      [Start]11.3

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

      associate-*r/ [<=]9.1

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

      associate-*l* [=>]9.1

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

    if 40 < z

    1. Initial program 33.2

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

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

      [Start]33.2

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

      associate-*r/ [<=]30.4

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

      associate-*l* [=>]30.4

      \[ \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)} \]
    3. Applied egg-rr30.4

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

      \[\leadsto x \cdot \frac{y}{\color{blue}{\sqrt{\frac{z \cdot z - t \cdot a}{z \cdot z}}}} \]
    5. Simplified0.9

      \[\leadsto x \cdot \frac{y}{\color{blue}{\sqrt{1 - \frac{a}{\frac{z}{\frac{t}{z}}}}}} \]
      Proof

      [Start]35.5

      \[ x \cdot \frac{y}{\sqrt{\frac{z \cdot z - t \cdot a}{z \cdot z}}} \]

      *-commutative [=>]35.5

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

      div-sub [=>]35.5

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

      unpow2 [<=]35.5

      \[ x \cdot \frac{y}{\sqrt{\frac{\color{blue}{{z}^{2}}}{z \cdot z} - \frac{a \cdot t}{z \cdot z}}} \]

      unpow2 [<=]35.5

      \[ x \cdot \frac{y}{\sqrt{\frac{{z}^{2}}{\color{blue}{{z}^{2}}} - \frac{a \cdot t}{z \cdot z}}} \]

      *-inverses [=>]5.2

      \[ x \cdot \frac{y}{\sqrt{\color{blue}{1} - \frac{a \cdot t}{z \cdot z}}} \]

      unpow2 [<=]5.2

      \[ x \cdot \frac{y}{\sqrt{1 - \frac{a \cdot t}{\color{blue}{{z}^{2}}}}} \]

      associate-/l* [=>]1.5

      \[ x \cdot \frac{y}{\sqrt{1 - \color{blue}{\frac{a}{\frac{{z}^{2}}{t}}}}} \]

      unpow2 [=>]1.5

      \[ x \cdot \frac{y}{\sqrt{1 - \frac{a}{\frac{\color{blue}{z \cdot z}}{t}}}} \]

      associate-/l* [=>]0.9

      \[ x \cdot \frac{y}{\sqrt{1 - \frac{a}{\color{blue}{\frac{z}{\frac{t}{z}}}}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.5

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

Alternatives

Alternative 1
Error6.1
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+151}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+95}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error12.9
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -6.1 \cdot 10^{-120}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \frac{t \cdot a}{z} - z}\right)\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-234}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 3
Error12.2
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-118}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \frac{t \cdot a}{z} - z}\right)\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-152}:\\ \;\;\;\;\frac{x}{\sqrt{t \cdot \left(-a\right)}} \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\\ \end{array} \]
Alternative 4
Error15.4
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+35}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-241}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{\frac{\left(t \cdot a\right) \cdot -0.5}{z} - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 5
Error17.2
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{-181}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-125}:\\ \;\;\;\;x \cdot \left(\frac{-2}{t} \cdot \frac{y}{\frac{a}{z \cdot z}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error17.2
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{-180}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-127}:\\ \;\;\;\;x \cdot \frac{y}{-0.5 \cdot \left(\frac{t}{z} \cdot \frac{a}{z}\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error15.8
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.95 \cdot 10^{-181}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 8
Error15.6
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{-227}:\\ \;\;\;\;\frac{y \cdot x}{\frac{\frac{-0.5}{\frac{z}{t \cdot a}} - z}{z}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 9
Error15.4
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.42 \cdot 10^{-249}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \frac{t \cdot a}{z} - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 10
Error17.6
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1.32 \cdot 10^{-89}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-140}:\\ \;\;\;\;-1 + \left(1 + \frac{x}{\frac{-1}{y}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 11
Error18.0
Cost776
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-65}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-272}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot \left(-x\right)\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Error19.2
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{-255}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-307}:\\ \;\;\;\;\frac{x}{\frac{z}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 13
Error17.7
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-180}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-38}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Error19.5
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -1.88 \cdot 10^{-298}:\\ \;\;\;\;\frac{-1}{\frac{1}{y \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 15
Error19.4
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -1.88 \cdot 10^{-298}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 16
Error37.1
Cost192
\[y \cdot x \]

Error

Reproduce?

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