?

Average Accuracy: 89.4% → 95.0%
Time: 9.8s
Precision: binary64
Cost: 840

?

\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{-194}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{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 (<= z -6.8e-194)
   (/ (/ 2.0 z) (/ (- y t) x))
   (if (<= z 1.85e+52)
     (/ x (/ (* z (- y t)) 2.0))
     (/ (/ (* 2.0 x) 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 (z <= -6.8e-194) {
		tmp = (2.0 / z) / ((y - t) / x);
	} else if (z <= 1.85e+52) {
		tmp = x / ((z * (y - t)) / 2.0);
	} else {
		tmp = ((2.0 * x) / 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 (z <= (-6.8d-194)) then
        tmp = (2.0d0 / z) / ((y - t) / x)
    else if (z <= 1.85d+52) then
        tmp = x / ((z * (y - t)) / 2.0d0)
    else
        tmp = ((2.0d0 * x) / 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 (z <= -6.8e-194) {
		tmp = (2.0 / z) / ((y - t) / x);
	} else if (z <= 1.85e+52) {
		tmp = x / ((z * (y - t)) / 2.0);
	} else {
		tmp = ((2.0 * x) / 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 z <= -6.8e-194:
		tmp = (2.0 / z) / ((y - t) / x)
	elif z <= 1.85e+52:
		tmp = x / ((z * (y - t)) / 2.0)
	else:
		tmp = ((2.0 * x) / 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 (z <= -6.8e-194)
		tmp = Float64(Float64(2.0 / z) / Float64(Float64(y - t) / x));
	elseif (z <= 1.85e+52)
		tmp = Float64(x / Float64(Float64(z * Float64(y - t)) / 2.0));
	else
		tmp = Float64(Float64(Float64(2.0 * x) / 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 (z <= -6.8e-194)
		tmp = (2.0 / z) / ((y - t) / x);
	elseif (z <= 1.85e+52)
		tmp = x / ((z * (y - t)) / 2.0);
	else
		tmp = ((2.0 * x) / 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[LessEqual[z, -6.8e-194], N[(N[(2.0 / z), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.85e+52], N[(x / N[(N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * x), $MachinePrecision] / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{-194}:\\
\;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original89.4%
Target96.4%
Herbie95.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 3 regimes
  2. if z < -6.80000000000000018e-194

    1. Initial program 88.9%

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

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

      [Start]88.9

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

      *-commutative [=>]88.9

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

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

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

      times-frac [=>]94.7

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

      associate-*r/ [=>]94.2

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

      associate-/l* [=>]94.3

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

    if -6.80000000000000018e-194 < z < 1.85e52

    1. Initial program 95.0%

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

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

      [Start]95.0

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

      associate-/l* [=>]95.0

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

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

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

    if 1.85e52 < z

    1. Initial program 82.1%

      \[\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]82.1

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

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

      \[ \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 3 regimes into one program.
  4. Final simplification95.0%

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

Alternatives

Alternative 1
Accuracy95.2%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{-194} \lor \neg \left(z \leq 10^{+50}\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
Accuracy73.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -7.2 \cdot 10^{-6} \lor \neg \left(t \leq 4 \cdot 10^{+34}\right):\\ \;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{2}{z \cdot y}\\ \end{array} \]
Alternative 3
Accuracy73.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -7 \cdot 10^{-6} \lor \neg \left(t \leq 4.7 \cdot 10^{+33}\right):\\ \;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 4
Accuracy73.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -1.55 \cdot 10^{-6} \lor \neg \left(t \leq 1.6 \cdot 10^{+33}\right):\\ \;\;\;\;\frac{-2}{z} \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 5
Accuracy73.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -3.1 \cdot 10^{-6} \lor \neg \left(t \leq 5.4 \cdot 10^{+32}\right):\\ \;\;\;\;\frac{\frac{x \cdot -2}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 6
Accuracy73.1%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -1.52 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{-2}{z}}{\frac{t}{x}}\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{+40}:\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{z} \cdot \frac{x}{t}\\ \end{array} \]
Alternative 7
Accuracy90.6%
Cost576
\[x \cdot \frac{2}{z \cdot \left(y - t\right)} \]
Alternative 8
Accuracy91.2%
Cost576
\[x \cdot \frac{\frac{2}{z}}{y - t} \]
Alternative 9
Accuracy51.1%
Cost448
\[x \cdot \frac{2}{z \cdot y} \]

Error

Reproduce?

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