?

Average Accuracy: 89.7% → 96.0%
Time: 15.5s
Precision: binary64
Cost: 1097

?

\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \leq -5 \cdot 10^{-97} \lor \neg \left(x \cdot 2 \leq 2 \cdot 10^{-43}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (* x 2.0) -5e-97) (not (<= (* x 2.0) 2e-43)))
   (/ (/ x (- y t)) (* z 0.5))
   (/ (/ (* x 2.0) z) (- y t))))
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 tmp;
	if (((x * 2.0) <= -5e-97) || !((x * 2.0) <= 2e-43)) {
		tmp = (x / (y - t)) / (z * 0.5);
	} else {
		tmp = ((x * 2.0) / z) / (y - t);
	}
	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) :: tmp
    if (((x * 2.0d0) <= (-5d-97)) .or. (.not. ((x * 2.0d0) <= 2d-43))) then
        tmp = (x / (y - t)) / (z * 0.5d0)
    else
        tmp = ((x * 2.0d0) / z) / (y - t)
    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 tmp;
	if (((x * 2.0) <= -5e-97) || !((x * 2.0) <= 2e-43)) {
		tmp = (x / (y - t)) / (z * 0.5);
	} else {
		tmp = ((x * 2.0) / z) / (y - t);
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * 2.0) / ((y * z) - (t * z))
def code(x, y, z, t):
	tmp = 0
	if ((x * 2.0) <= -5e-97) or not ((x * 2.0) <= 2e-43):
		tmp = (x / (y - t)) / (z * 0.5)
	else:
		tmp = ((x * 2.0) / z) / (y - t)
	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)
	tmp = 0.0
	if ((Float64(x * 2.0) <= -5e-97) || !(Float64(x * 2.0) <= 2e-43))
		tmp = Float64(Float64(x / Float64(y - t)) / Float64(z * 0.5));
	else
		tmp = Float64(Float64(Float64(x * 2.0) / z) / Float64(y - t));
	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)
	tmp = 0.0;
	if (((x * 2.0) <= -5e-97) || ~(((x * 2.0) <= 2e-43)))
		tmp = (x / (y - t)) / (z * 0.5);
	else
		tmp = ((x * 2.0) / z) / (y - t);
	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_] := If[Or[LessEqual[N[(x * 2.0), $MachinePrecision], -5e-97], N[Not[LessEqual[N[(x * 2.0), $MachinePrecision], 2e-43]], $MachinePrecision]], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(z * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \leq -5 \cdot 10^{-97} \lor \neg \left(x \cdot 2 \leq 2 \cdot 10^{-43}\right):\\
\;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original89.7%
Target96.6%
Herbie96.0%
\[\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 2 regimes
  2. if (*.f64 x 2) < -4.9999999999999995e-97 or 2.00000000000000015e-43 < (*.f64 x 2)

    1. Initial program 86.7%

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

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

      [Start]86.7

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

      *-commutative [=>]86.7

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

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

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

      times-frac [=>]95.8

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

      associate-*r/ [=>]86.3

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

      associate-/l* [=>]96.0

      \[ \color{blue}{\frac{\frac{2}{z}}{\frac{y - t}{x}}} \]
    3. Applied egg-rr95.5%

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

      [Start]96.0

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

      clear-num [=>]95.4

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

      inv-pow [=>]95.4

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

      div-inv [=>]95.4

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

      clear-num [<=]95.5

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

      div-inv [=>]95.5

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

      metadata-eval [=>]95.5

      \[ {\left(\frac{y - t}{x} \cdot \left(z \cdot \color{blue}{0.5}\right)\right)}^{-1} \]
    4. Simplified95.9%

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

      [Start]95.5

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

      unpow-1 [=>]95.5

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

      associate-/r* [=>]95.6

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

      *-lft-identity [<=]95.6

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

      associate-*r/ [=>]95.6

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

      associate-*l/ [<=]95.5

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

      associate-/r* [=>]95.8

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

      associate-/r/ [=>]95.9

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

      metadata-eval [=>]95.9

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

      associate-*r/ [<=]95.9

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

      *-lft-identity [=>]95.9

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

    if -4.9999999999999995e-97 < (*.f64 x 2) < 2.00000000000000015e-43

    1. Initial program 93.9%

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

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

      [Start]93.9

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

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

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

      associate-/r* [=>]96.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \leq -5 \cdot 10^{-97} \lor \neg \left(x \cdot 2 \leq 2 \cdot 10^{-43}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy96.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -8.8 \cdot 10^{+82} \lor \neg \left(z \leq 7 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{\left(y - t\right) \cdot z}{2}}\\ \end{array} \]
Alternative 2
Accuracy96.2%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -9.6 \cdot 10^{-44} \lor \neg \left(x \leq 2.2 \cdot 10^{+34}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \end{array} \]
Alternative 3
Accuracy73.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-48} \lor \neg \left(y \leq 1.78 \cdot 10^{+19}\right):\\ \;\;\;\;x \cdot \frac{2}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{-2}{t \cdot z}\\ \end{array} \]
Alternative 4
Accuracy73.2%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.45 \cdot 10^{-48} \lor \neg \left(y \leq 2.95 \cdot 10^{+20}\right):\\ \;\;\;\;x \cdot \frac{2}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\ \end{array} \]
Alternative 5
Accuracy73.2%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{-49}:\\ \;\;\;\;x \cdot \frac{2}{y \cdot z}\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+27}:\\ \;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\ \end{array} \]
Alternative 6
Accuracy73.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.55 \cdot 10^{-49}:\\ \;\;\;\;x \cdot \frac{2}{y \cdot z}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+23}:\\ \;\;\;\;\frac{-2}{t \cdot \frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\ \end{array} \]
Alternative 7
Accuracy73.2%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-48}:\\ \;\;\;\;\frac{2}{y \cdot \frac{z}{x}}\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+22}:\\ \;\;\;\;\frac{-2}{t \cdot \frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\ \end{array} \]
Alternative 8
Accuracy73.4%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.62 \cdot 10^{-49}:\\ \;\;\;\;\frac{2}{y \cdot \frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.52 \cdot 10^{+25}:\\ \;\;\;\;\frac{\frac{x \cdot -2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\ \end{array} \]
Alternative 9
Accuracy91.9%
Cost576
\[x \cdot \frac{\frac{2}{z}}{y - t} \]
Alternative 10
Accuracy50.5%
Cost448
\[x \cdot \frac{-2}{t \cdot z} \]

Error

Reproduce?

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