?

Average Error: 37.71% → 9.27%
Time: 32.6s
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.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{z}{a \cdot \left(\frac{t}{z} \cdot 0.5\right) - z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+99}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\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 -1.35e+154)
   (* (/ z (- (* a (* (/ t z) 0.5)) z)) (* x y))
   (if (<= z 2.1e+99)
     (* x (* y (/ z (sqrt (- (* z z) (* a t))))))
     (* x (* y (/ z (+ z (* -0.5 (/ a (/ z t))))))))))
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.35e+154) {
		tmp = (z / ((a * ((t / z) * 0.5)) - z)) * (x * y);
	} else if (z <= 2.1e+99) {
		tmp = x * (y * (z / sqrt(((z * z) - (a * t)))));
	} else {
		tmp = x * (y * (z / (z + (-0.5 * (a / (z / t))))));
	}
	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.35d+154)) then
        tmp = (z / ((a * ((t / z) * 0.5d0)) - z)) * (x * y)
    else if (z <= 2.1d+99) then
        tmp = x * (y * (z / sqrt(((z * z) - (a * t)))))
    else
        tmp = x * (y * (z / (z + ((-0.5d0) * (a / (z / t))))))
    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.35e+154) {
		tmp = (z / ((a * ((t / z) * 0.5)) - z)) * (x * y);
	} else if (z <= 2.1e+99) {
		tmp = x * (y * (z / Math.sqrt(((z * z) - (a * t)))));
	} else {
		tmp = x * (y * (z / (z + (-0.5 * (a / (z / t))))));
	}
	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.35e+154:
		tmp = (z / ((a * ((t / z) * 0.5)) - z)) * (x * y)
	elif z <= 2.1e+99:
		tmp = x * (y * (z / math.sqrt(((z * z) - (a * t)))))
	else:
		tmp = x * (y * (z / (z + (-0.5 * (a / (z / t))))))
	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.35e+154)
		tmp = Float64(Float64(z / Float64(Float64(a * Float64(Float64(t / z) * 0.5)) - z)) * Float64(x * y));
	elseif (z <= 2.1e+99)
		tmp = Float64(x * Float64(y * Float64(z / sqrt(Float64(Float64(z * z) - Float64(a * t))))));
	else
		tmp = Float64(x * Float64(y * Float64(z / Float64(z + Float64(-0.5 * Float64(a / Float64(z / t)))))));
	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.35e+154)
		tmp = (z / ((a * ((t / z) * 0.5)) - z)) * (x * y);
	elseif (z <= 2.1e+99)
		tmp = x * (y * (z / sqrt(((z * z) - (a * t)))));
	else
		tmp = x * (y * (z / (z + (-0.5 * (a / (z / t))))));
	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.35e+154], N[(N[(z / N[(N[(a * N[(N[(t / z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e+99], N[(x * N[(y * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * N[(z / N[(z + N[(-0.5 * N[(a / N[(z / t), $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.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{z}{a \cdot \left(\frac{t}{z} \cdot 0.5\right) - z} \cdot \left(x \cdot y\right)\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.71%
Target11.69%
Herbie9.27%
\[\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.35000000000000003e154

    1. Initial program 84.45

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

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

      [Start]84.45

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

      associate-*r/ [<=]83.84

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

      *-commutative [<=]83.84

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

      \[\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-rr9.97

      \[\leadsto \frac{z}{\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.5}{\frac{z}{a}} \cdot t\right)} - 1\right)} + -1 \cdot z} \cdot \left(x \cdot y\right) \]
    5. Simplified1.71

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

      [Start]9.97

      \[ \frac{z}{\left(e^{\mathsf{log1p}\left(\frac{0.5}{\frac{z}{a}} \cdot t\right)} - 1\right) + -1 \cdot z} \cdot \left(x \cdot y\right) \]

      expm1-def [=>]9.97

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

      expm1-log1p [=>]1.71

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

      associate-/r/ [=>]1.71

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

      associate-*r* [<=]9.05

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

      associate-*l/ [=>]9.05

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

      associate-*r/ [<=]9.05

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

      *-commutative [=>]9.05

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

      associate-*r/ [<=]1.71

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

      associate-*l* [=>]1.71

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

    if -1.35000000000000003e154 < z < 2.1000000000000001e99

    1. Initial program 16.56

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

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

      [Start]16.56

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

      associate-*r/ [<=]13.35

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

      associate-*l* [=>]13.13

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

    if 2.1000000000000001e99 < z

    1. Initial program 67.41

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

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

      [Start]67.41

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

      associate-*r/ [<=]63.76

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

      associate-*l* [=>]63.75

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

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

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

      [Start]8.66

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

      associate-/l* [=>]3.16

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

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

Alternatives

Alternative 1
Error17.5%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{-28}:\\ \;\;\;\;\frac{z}{a \cdot \left(\frac{t}{z} \cdot 0.5\right) - z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-94}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{a \cdot \left(-t\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 2
Error17.06%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{-28}:\\ \;\;\;\;\frac{z}{a \cdot \left(\frac{t}{z} \cdot 0.5\right) - z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-97}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{\sqrt{a \cdot \left(-t\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 3
Error17.36%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{-28}:\\ \;\;\;\;\frac{z}{a \cdot \left(\frac{t}{z} \cdot 0.5\right) - z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-94}:\\ \;\;\;\;\frac{x}{\frac{\sqrt{a \cdot \left(-t\right)}}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 4
Error26.16%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{-156}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-137}:\\ \;\;\;\;-2 \cdot \left(\frac{y}{a} \cdot \frac{x \cdot \left(z \cdot z\right)}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 5
Error26.14%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -9.2 \cdot 10^{-159}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-132}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \left(\frac{2}{a} \cdot \frac{z \cdot z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 6
Error26.08%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -5.7 \cdot 10^{-160}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-134}:\\ \;\;\;\;\frac{-2}{a} \cdot \frac{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error24.14%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -8.7 \cdot 10^{-156}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 8
Error23.3%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{-239}:\\ \;\;\;\;x \cdot \frac{y}{\frac{0.5 \cdot \frac{a \cdot t}{z} - 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
Error22.17%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-241}:\\ \;\;\;\;\frac{z}{a \cdot \left(\frac{t}{z} \cdot 0.5\right) - z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 10
Error28.07%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-242}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-98}:\\ \;\;\;\;\frac{x}{\frac{z}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 11
Error27.46%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{-242}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-98}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 12
Error26.56%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-59}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-136}:\\ \;\;\;\;-1 + \left(1 - x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 13
Error30.19%
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 14
Error57.02%
Cost192
\[x \cdot y \]

Error

Reproduce?

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