?

Average Error: 14.59% → 0.12%
Time: 12.1s
Precision: binary64
Cost: 832

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.59%
Target0.12%
Herbie0.12%
\[\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right) \]

Derivation?

  1. Initial program 14.59

    \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
  2. Simplified0.12

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

    [Start]14.59

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

    +-rgt-identity [<=]14.59

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

    mul0-lft [<=]14.59

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

    associate-+r+ [<=]14.59

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

    mul0-lft [=>]14.59

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

    +-lft-identity [=>]14.59

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

    sub-neg [=>]14.59

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

    distribute-rgt-in [=>]14.58

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

    associate-+r+ [=>]14.58

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

    cancel-sign-sub-inv [<=]14.58

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

    div-sub [=>]14.58

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

    associate-*r* [=>]14.58

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

    associate-*l/ [<=]14.58

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

    *-inverses [=>]0.25

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

    metadata-eval [=>]0.25

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

    sub-neg [=>]0.25

    \[ \frac{x}{y} + \color{blue}{\left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} + \left(-2\right)\right)} \]
  3. Final simplification0.12

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

Alternatives

Alternative 1
Error47.83%
Cost1232
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -45000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -6.1 \cdot 10^{-65}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq 1.2 \cdot 10^{-18}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq 7.5 \cdot 10^{+36}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 2
Error10%
Cost1232
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := -2 + \frac{2}{t}\\ t_3 := \frac{x}{y} + t_2\\ \mathbf{if}\;z \leq -3.3 \cdot 10^{-25}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-132}:\\ \;\;\;\;-2 + t_1\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-113}:\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{elif}\;z \leq 2500:\\ \;\;\;\;\frac{\frac{2}{t}}{z} + t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error21.61%
Cost1108
\[\begin{array}{l} t_1 := -2 + \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -8 \cdot 10^{+209}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -660000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.6:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{elif}\;t \leq 1.36 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error10.25%
Cost1104
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := -2 + t_1\\ t_3 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -4.1 \cdot 10^{-26}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.26 \cdot 10^{-113}:\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{elif}\;z \leq 0.00135:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error10.04%
Cost1104
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{-25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-132}:\\ \;\;\;\;-2 + t_1\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-113}:\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{elif}\;z \leq 14200:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error12.36%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -4.1 \cdot 10^{-25} \lor \neg \left(z \leq 2.8 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2}{z \cdot t}\\ \end{array} \]
Alternative 7
Error31.44%
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -28000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 8.5 \cdot 10^{+30}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 8
Error36.81%
Cost716
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -0.0305:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-69}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+87}:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error36.79%
Cost716
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -0.032:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-69}:\\ \;\;\;\;\frac{\frac{2}{z}}{t}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{+88}:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error29.47%
Cost716
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 135:\\ \;\;\;\;-2 + \frac{2}{z \cdot t}\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error30.94%
Cost585
\[\begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{-10} \lor \neg \left(t \leq 31\right):\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \end{array} \]
Alternative 12
Error52.63%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -150:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 80000000000000:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 13
Error73.45%
Cost64
\[-2 \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y z t)
  :name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
  :precision binary64

  :herbie-target
  (- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y)))

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