?

Average Accuracy: 89.1% → 97.2%
Time: 10.9s
Precision: binary64
Cost: 2120

?

\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} t_1 := \frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-323}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\ \mathbf{elif}\;t_1 \leq 20:\\ \;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* x 2.0) (- (* y z) (* z t)))))
   (if (<= t_1 -2e-323)
     (/ x (* (- y t) (/ z 2.0)))
     (if (<= t_1 20.0)
       (* 2.0 (/ (/ x z) (- y t)))
       (/ (/ (* x 2.0) (- y t)) z)))))
double code(double x, double y, double z, double t) {
	return (x * 2.0) / ((y * z) - (t * z));
}
double code(double x, double y, double z, double t) {
	double t_1 = (x * 2.0) / ((y * z) - (z * t));
	double tmp;
	if (t_1 <= -2e-323) {
		tmp = x / ((y - t) * (z / 2.0));
	} else if (t_1 <= 20.0) {
		tmp = 2.0 * ((x / z) / (y - t));
	} else {
		tmp = ((x * 2.0) / (y - t)) / z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x * 2.0d0) / ((y * z) - (t * z))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * 2.0d0) / ((y * z) - (z * t))
    if (t_1 <= (-2d-323)) then
        tmp = x / ((y - t) * (z / 2.0d0))
    else if (t_1 <= 20.0d0) then
        tmp = 2.0d0 * ((x / z) / (y - t))
    else
        tmp = ((x * 2.0d0) / (y - t)) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x * 2.0) / ((y * z) - (t * z));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * 2.0) / ((y * z) - (z * t));
	double tmp;
	if (t_1 <= -2e-323) {
		tmp = x / ((y - t) * (z / 2.0));
	} else if (t_1 <= 20.0) {
		tmp = 2.0 * ((x / z) / (y - t));
	} else {
		tmp = ((x * 2.0) / (y - t)) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * 2.0) / ((y * z) - (t * z))
def code(x, y, z, t):
	t_1 = (x * 2.0) / ((y * z) - (z * t))
	tmp = 0
	if t_1 <= -2e-323:
		tmp = x / ((y - t) * (z / 2.0))
	elif t_1 <= 20.0:
		tmp = 2.0 * ((x / z) / (y - t))
	else:
		tmp = ((x * 2.0) / (y - t)) / z
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z)))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(z * t)))
	tmp = 0.0
	if (t_1 <= -2e-323)
		tmp = Float64(x / Float64(Float64(y - t) * Float64(z / 2.0)));
	elseif (t_1 <= 20.0)
		tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t)));
	else
		tmp = Float64(Float64(Float64(x * 2.0) / Float64(y - t)) / z);
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x * 2.0) / ((y * z) - (t * z));
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * 2.0) / ((y * z) - (z * t));
	tmp = 0.0;
	if (t_1 <= -2e-323)
		tmp = x / ((y - t) * (z / 2.0));
	elseif (t_1 <= 20.0)
		tmp = 2.0 * ((x / z) / (y - t));
	else
		tmp = ((x * 2.0) / (y - t)) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-323], N[(x / N[(N[(y - t), $MachinePrecision] * N[(z / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 20.0], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := \frac{x \cdot 2}{y \cdot z - z \cdot t}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-323}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\

\mathbf{elif}\;t_1 \leq 20:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original89.1%
Target96.5%
Herbie97.2%
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} < -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} < 1.045027827330126 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -1.97626e-323

    1. Initial program 97.1%

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
    2. Simplified97.2%

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

      [Start]97.1

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

      distribute-rgt-out-- [=>]97.1

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

      associate-/r* [=>]87.0

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

      associate-/l* [=>]87.0

      \[ \frac{\color{blue}{\frac{x}{\frac{z}{2}}}}{y - t} \]

      associate-/l/ [=>]97.2

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

    if -1.97626e-323 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < 20

    1. Initial program 86.0%

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
    2. Simplified98.0%

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

      [Start]86.0

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

      associate-*l/ [<=]86.0

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

      *-commutative [=>]86.0

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

      distribute-rgt-out-- [=>]86.0

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

      associate-/r* [=>]98.0

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

    if 20 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z)))

    1. Initial program 82.1%

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
    2. Simplified91.2%

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

      [Start]82.1

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

      associate-*r/ [<=]81.6

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

      distribute-rgt-out-- [=>]91.2

      \[ x \cdot \frac{2}{\color{blue}{z \cdot \left(y - t\right)}} \]
    3. Applied egg-rr94.8%

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

      [Start]91.2

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

      associate-*r/ [=>]91.6

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

      *-commutative [=>]91.6

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

      associate-/r* [=>]94.8

      \[ \color{blue}{\frac{\frac{x \cdot 2}{y - t}}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -2 \cdot 10^{-323}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 20:\\ \;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy96.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-92} \lor \neg \left(z \leq 7.2 \cdot 10^{+25}\right):\\ \;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{2}{z \cdot \left(y - t\right)}\\ \end{array} \]
Alternative 2
Accuracy95.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -3.1 \cdot 10^{+179} \lor \neg \left(z \leq 3.35 \cdot 10^{+24}\right):\\ \;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{-2}{t - y}}{z}\\ \end{array} \]
Alternative 3
Accuracy72.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -3.15 \cdot 10^{+19} \lor \neg \left(t \leq 2.4 \cdot 10^{-18}\right):\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y}\\ \end{array} \]
Alternative 4
Accuracy72.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{+17} \lor \neg \left(t \leq 3.6 \cdot 10^{-26}\right):\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\ \end{array} \]
Alternative 5
Accuracy72.9%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -2.85 \cdot 10^{+19} \lor \neg \left(t \leq 1.85 \cdot 10^{-24}\right):\\ \;\;\;\;\frac{x \cdot -2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\ \end{array} \]
Alternative 6
Accuracy90.6%
Cost576
\[2 \cdot \frac{\frac{x}{z}}{y - t} \]
Alternative 7
Accuracy50.4%
Cost448
\[x \cdot \frac{\frac{2}{y}}{z} \]
Alternative 8
Accuracy50.4%
Cost448
\[x \cdot \frac{\frac{2}{z}}{y} \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

  (/ (* x 2.0) (- (* y z) (* t z))))