?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.9%
Target11.61%
Herbie9.44%
\[\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 < -2.00000000000000007e154

    1. Initial program 84.61

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

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

      [Start]84.61

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

      associate-*r/ [<=]83.96

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

      associate-*l* [=>]83.96

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

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

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

      [Start]2.27

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

      associate-*r* [=>]2.27

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

      mul-1-neg [=>]2.27

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

    if -2.00000000000000007e154 < z < 7.5999999999999997e74

    1. Initial program 17.3

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

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

      [Start]17.3

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

      associate-*r/ [<=]14.28

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

      associate-*l* [=>]13.33

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

    if 7.5999999999999997e74 < z

    1. Initial program 60.68

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

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

      [Start]60.68

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

      associate-*r/ [<=]56.5

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

      *-commutative [<=]56.5

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

      \[\leadsto \frac{z}{\color{blue}{0.5 \cdot \frac{a \cdot t}{z} + -1 \cdot z}} \cdot \left(x \cdot y\right) \]
    4. Applied egg-rr26.82

      \[\leadsto \color{blue}{\frac{z \cdot \left(x \cdot y\right)}{z - \frac{0.5}{\frac{z}{t}} \cdot a}} \]
    5. Simplified4.09

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

      [Start]26.82

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

      associate-/l* [=>]26.27

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

      associate-/r/ [=>]4.09

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

      cancel-sign-sub-inv [=>]4.09

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

      *-commutative [=>]4.09

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

      distribute-neg-frac [=>]4.09

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

      metadata-eval [=>]4.09

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

      *-commutative [<=]4.09

      \[ \frac{z}{z + a \cdot \frac{-0.5}{\frac{z}{t}}} \cdot \color{blue}{\left(y \cdot x\right)} \]
    6. Applied egg-rr4.09

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

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

Alternatives

Alternative 1
Error17.49%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{-90}:\\ \;\;\;\;\frac{z}{a \cdot \left(t \cdot \frac{0.5}{z}\right) - z} \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-153}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 2
Error17.82%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{-90}:\\ \;\;\;\;\frac{z}{a \cdot \left(t \cdot \frac{0.5}{z}\right) - z} \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-151}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 3
Error17.93%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{-90}:\\ \;\;\;\;\frac{z}{a \cdot \left(t \cdot \frac{0.5}{z}\right) - z} \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-188}:\\ \;\;\;\;\frac{x}{\frac{\sqrt{t \cdot \left(-a\right)}}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 4
Error23.23%
Cost1288
\[\begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{+66}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-307}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot \left(-x\right)\right)}{z + a \cdot \left(t \cdot \frac{-0.5}{z}\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 5
Error24.12%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-163}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 6
Error23.37%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{-301}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{0.5 \cdot \frac{t \cdot a}{z} - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 7
Error22.36%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{-303}:\\ \;\;\;\;\frac{z}{a \cdot \left(t \cdot \frac{0.5}{z}\right) - z} \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 8
Error22.36%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{-303}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\frac{0.5}{\frac{\frac{z}{a}}{t}} - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \frac{a \cdot -0.5}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 9
Error29.15%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.95 \cdot 10^{-166}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.56 \cdot 10^{-211}:\\ \;\;\;\;\frac{z \cdot x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Error27.39%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-166}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-197}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 11
Error26.78%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{-166}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-159}:\\ \;\;\;\;\frac{x \cdot \left(z \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Error26.64%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{-64}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-197}:\\ \;\;\;\;-1 + \left(1 - y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 13
Error29.72%
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -2.85 \cdot 10^{-304}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Error56.6%
Cost192
\[y \cdot x \]

Error

Reproduce?

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