?

Average Accuracy: 89.3% → 97.5%
Time: 11.0s
Precision: binary64
Cost: 2892

?

\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} t_1 := \frac{\frac{x}{y - t}}{z \cdot 0.5}\\ t_2 := \frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;t_2 \leq 10^{+204}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (- y t)) (* z 0.5)))
        (t_2 (/ (* x 2.0) (- (* y z) (* z t)))))
   (if (<= t_2 -1e+27)
     t_1
     (if (<= t_2 0.0)
       (/ (/ (* x 2.0) z) (- y t))
       (if (<= t_2 1e+204) (/ x (/ (* z (- y t)) 2.0)) t_1)))))
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 / (y - t)) / (z * 0.5);
	double t_2 = (x * 2.0) / ((y * z) - (z * t));
	double tmp;
	if (t_2 <= -1e+27) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = ((x * 2.0) / z) / (y - t);
	} else if (t_2 <= 1e+204) {
		tmp = x / ((z * (y - t)) / 2.0);
	} else {
		tmp = t_1;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = (x / (y - t)) / (z * 0.5d0)
    t_2 = (x * 2.0d0) / ((y * z) - (z * t))
    if (t_2 <= (-1d+27)) then
        tmp = t_1
    else if (t_2 <= 0.0d0) then
        tmp = ((x * 2.0d0) / z) / (y - t)
    else if (t_2 <= 1d+204) then
        tmp = x / ((z * (y - t)) / 2.0d0)
    else
        tmp = t_1
    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 / (y - t)) / (z * 0.5);
	double t_2 = (x * 2.0) / ((y * z) - (z * t));
	double tmp;
	if (t_2 <= -1e+27) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = ((x * 2.0) / z) / (y - t);
	} else if (t_2 <= 1e+204) {
		tmp = x / ((z * (y - t)) / 2.0);
	} else {
		tmp = t_1;
	}
	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 / (y - t)) / (z * 0.5)
	t_2 = (x * 2.0) / ((y * z) - (z * t))
	tmp = 0
	if t_2 <= -1e+27:
		tmp = t_1
	elif t_2 <= 0.0:
		tmp = ((x * 2.0) / z) / (y - t)
	elif t_2 <= 1e+204:
		tmp = x / ((z * (y - t)) / 2.0)
	else:
		tmp = t_1
	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 / Float64(y - t)) / Float64(z * 0.5))
	t_2 = Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(z * t)))
	tmp = 0.0
	if (t_2 <= -1e+27)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = Float64(Float64(Float64(x * 2.0) / z) / Float64(y - t));
	elseif (t_2 <= 1e+204)
		tmp = Float64(x / Float64(Float64(z * Float64(y - t)) / 2.0));
	else
		tmp = t_1;
	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 / (y - t)) / (z * 0.5);
	t_2 = (x * 2.0) / ((y * z) - (z * t));
	tmp = 0.0;
	if (t_2 <= -1e+27)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = ((x * 2.0) / z) / (y - t);
	elseif (t_2 <= 1e+204)
		tmp = x / ((z * (y - t)) / 2.0);
	else
		tmp = t_1;
	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 / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(z * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+27], t$95$1, If[LessEqual[t$95$2, 0.0], N[(N[(N[(x * 2.0), $MachinePrecision] / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+204], N[(x / N[(N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := \frac{\frac{x}{y - t}}{z \cdot 0.5}\\
t_2 := \frac{x \cdot 2}{y \cdot z - z \cdot t}\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{+27}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;t_2 \leq 10^{+204}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original89.3%
Target96.6%
Herbie97.5%
\[\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))) < -1e27 or 9.99999999999999989e203 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z)))

    1. Initial program 81.4%

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

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

      [Start]81.4

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

      *-commutative [=>]81.4

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

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

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

      times-frac [=>]93.2

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

      associate-*r/ [=>]72.0

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

      associate-/l* [=>]93.6

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

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

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

      [Start]93.6

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

      unpow-1 [=>]93.6

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

      associate-/r* [=>]93.2

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

      *-lft-identity [<=]93.2

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

      associate-*r/ [=>]93.2

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

      associate-*l/ [<=]93.1

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

      associate-/r* [=>]93.2

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

      associate-/r/ [=>]93.4

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

      metadata-eval [=>]93.4

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

      associate-*r/ [<=]93.4

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

      *-lft-identity [=>]93.4

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

    if -1e27 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -0.0

    1. Initial program 86.6%

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

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

      [Start]86.6

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

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

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

      associate-/r* [=>]98.0

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

    if -0.0 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < 9.99999999999999989e203

    1. Initial program 99.4%

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

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

      [Start]99.4

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

      associate-/l* [=>]99.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -1 \cdot 10^{+27}:\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 0:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 10^{+204}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy95.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+104} \lor \neg \left(x \leq 2.75 \cdot 10^{+107}\right):\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array} \]
Alternative 2
Accuracy95.5%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+104} \lor \neg \left(x \leq 5.4 \cdot 10^{+91}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{z \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array} \]
Alternative 3
Accuracy72.7%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -800000 \lor \neg \left(t \leq 1.8 \cdot 10^{-37}\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 -5500000 \lor \neg \left(t \leq 1.3 \cdot 10^{-36}\right):\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 5
Accuracy72.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -2150000000:\\ \;\;\;\;x \cdot \frac{-2}{z \cdot t}\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{-36}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \end{array} \]
Alternative 6
Accuracy73.0%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -21000000:\\ \;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\ \mathbf{elif}\;t \leq 1.16 \cdot 10^{-36}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-2}{z}\\ \end{array} \]
Alternative 7
Accuracy72.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -17500000000:\\ \;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{-37}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\frac{z}{\frac{x}{t}}}\\ \end{array} \]
Alternative 8
Accuracy72.7%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -230000000:\\ \;\;\;\;\frac{x \cdot -2}{z \cdot t}\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{-36}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\frac{z}{\frac{x}{t}}}\\ \end{array} \]
Alternative 9
Accuracy90.9%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{+233}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{y \cdot \frac{z}{x}}\\ \end{array} \]
Alternative 10
Accuracy50.7%
Cost448
\[x \cdot \frac{-2}{z \cdot t} \]

Error

Reproduce?

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