?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{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

Original61.5%
Target88.5%
Herbie88.4%
\[\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.2e173

    1. Initial program 15.9%

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

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

      [Start]15.9

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

      *-commutative [=>]15.9

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

      associate-*l* [=>]15.4

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

      associate-*l/ [<=]15.6

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

      *-commutative [=>]15.6

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

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

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

      [Start]98.5

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

      associate-*r* [=>]98.5

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

      neg-mul-1 [<=]98.5

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

    if -1.2e173 < z < 1.2e64

    1. Initial program 80.4%

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

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

      [Start]80.4

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

      associate-*r/ [<=]82.9

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

      *-commutative [<=]82.9

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

    if 1.2e64 < z

    1. Initial program 40.1%

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

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

      [Start]40.1

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

      associate-*r/ [<=]44.5

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

      *-commutative [<=]44.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 92.3%

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

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

      [Start]92.3

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

      associate-/l* [=>]96.4

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

      associate-/r/ [=>]96.4

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

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

Alternatives

Alternative 1
Accuracy88.4%
Cost7760
\[\begin{array}{l} t_1 := \left(z \cdot x\right) \cdot \frac{y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{+66}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -7.7 \cdot 10^{-246}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.38 \cdot 10^{-241}:\\ \;\;\;\;\frac{z}{\sqrt{t \cdot \left(-a\right)}} \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;z \leq 1.66 \cdot 10^{+56}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)} \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 2
Accuracy82.5%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.12 \cdot 10^{-94}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-78}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)} \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 3
Accuracy81.8%
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-93}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{-82}:\\ \;\;\;\;\frac{z}{\sqrt{t \cdot \left(-a\right)}} \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)} \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 4
Accuracy73.9%
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-192}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{-191}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \frac{y}{z + -0.5 \cdot \frac{t \cdot a}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Accuracy73.3%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{-193}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-247}:\\ \;\;\;\;-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
Accuracy73.1%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-192}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-247}:\\ \;\;\;\;2 \cdot \frac{y}{\frac{t \cdot a}{x \cdot \left(z \cdot z\right)}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Accuracy73.2%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{-181}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-251}:\\ \;\;\;\;x \cdot \left(z \cdot \left(2 \cdot \left(\frac{z}{t} \cdot \frac{y}{a}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Accuracy73.2%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{-175}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-251}:\\ \;\;\;\;\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 9
Accuracy73.2%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{-173}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-251}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(2 \cdot \frac{y}{\frac{a}{\frac{z}{t}}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Accuracy75.7%
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-191}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{z + -0.5 \cdot \left(t \cdot \frac{a}{z}\right)} \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 11
Accuracy71.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{-193}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-251}:\\ \;\;\;\;y \cdot \frac{z \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Accuracy72.7%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3.35 \cdot 10^{-112}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-288}:\\ \;\;\;\;\left(1 - y \cdot x\right) + -1\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 13
Accuracy70.5%
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{-295}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Accuracy43.0%
Cost192
\[y \cdot x \]

Error

Reproduce?

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