?

Average Error: 6.8 → 5.6
Time: 18.5s
Precision: binary64
Cost: 576

?

\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\frac{x \cdot 2}{z \cdot \left(y - t\right)} \]
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t) :precision binary64 (/ (* 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) {
	return (x * 2.0) / (z * (y - t));
}
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
    code = (x * 2.0d0) / (z * (y - t))
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) {
	return (x * 2.0) / (z * (y - t));
}
def code(x, y, z, t):
	return (x * 2.0) / ((y * z) - (t * z))
def code(x, y, z, t):
	return (x * 2.0) / (z * (y - t))
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)
	return Float64(Float64(x * 2.0) / Float64(z * Float64(y - t)))
end
function tmp = code(x, y, z, t)
	tmp = (x * 2.0) / ((y * z) - (t * z));
end
function tmp = code(x, y, z, t)
	tmp = (x * 2.0) / (z * (y - t));
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_] := N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\frac{x \cdot 2}{z \cdot \left(y - t\right)}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.8
Target2.3
Herbie5.6
\[\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. Initial program 6.8

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

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

    [Start]6.8

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

    rational.json-simplify-2 [=>]6.8

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

    rational.json-simplify-48 [=>]5.6

    \[ \frac{x \cdot 2}{\color{blue}{z \cdot \left(y - t\right)}} \]
  3. Final simplification5.6

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

Alternatives

Alternative 1
Error17.5
Cost976
\[\begin{array}{l} t_1 := \frac{x \cdot 2}{y \cdot z}\\ t_2 := -2 \cdot \frac{x}{z \cdot t}\\ \mathbf{if}\;t \leq -5.4 \cdot 10^{+66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9.5 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -6.5 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 5.7 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error17.5
Cost976
\[\begin{array}{l} t_1 := \frac{x \cdot 2}{y \cdot z}\\ t_2 := -2 \cdot \frac{x}{z \cdot t}\\ \mathbf{if}\;t \leq -2.4 \cdot 10^{+66}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(-t\right)}\\ \mathbf{elif}\;t \leq -1.35 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.3 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.1 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error31.0
Cost448
\[-2 \cdot \frac{x}{z \cdot t} \]

Error

Reproduce?

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