?

Average Error: 15.46% → 0.13%
Time: 13.3s
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

Original15.46%
Target0.13%
Herbie0.13%
\[\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right) \]

Derivation?

  1. Initial program 15.46

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

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

    [Start]15.46

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

    +-rgt-identity [<=]15.46

    \[ \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 [<=]15.46

    \[ \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+ [<=]15.46

    \[ \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 [=>]15.46

    \[ \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 [=>]15.46

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

    sub-neg [=>]15.46

    \[ \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 [=>]15.46

    \[ \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+ [=>]15.46

    \[ \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 [<=]15.46

    \[ \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 [=>]15.44

    \[ \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* [=>]15.44

    \[ \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/ [<=]15.42

    \[ \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.22

    \[ \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.22

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

    sub-neg [=>]0.22

    \[ \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.13

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

Alternatives

Alternative 1
Error31.53%
Cost2272
\[\begin{array}{l} t_1 := -2 + \frac{2}{z \cdot t}\\ t_2 := -2 + \frac{2}{t}\\ \mathbf{if}\;\frac{x}{y} \leq -4.1 \cdot 10^{+49}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -9.2 \cdot 10^{-235}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{x}{y} \leq -4.8 \cdot 10^{-304}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 9.8 \cdot 10^{-256}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{x}{y} \leq 6.5 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 2.55 \cdot 10^{-116}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{x}{y} \leq 460000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 8.6 \cdot 10^{+49}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 2
Error20.37%
Cost1500
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ t_3 := \frac{x}{y} + t_1\\ \mathbf{if}\;t \leq -4.1 \cdot 10^{+190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5 \cdot 10^{+105}:\\ \;\;\;\;-2 + t_1\\ \mathbf{elif}\;t \leq -1.75 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9 \cdot 10^{-14}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -7.5 \cdot 10^{-64}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{elif}\;t \leq -1.2 \cdot 10^{-113}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4.6 \cdot 10^{-12}:\\ \;\;\;\;t_1 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error9%
Cost1225
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ \mathbf{if}\;\frac{x}{y} \leq -1.4 \cdot 10^{+56} \lor \neg \left(\frac{x}{y} \leq 8.5 \cdot 10^{+49}\right):\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{else}:\\ \;\;\;\;t_1 + \left(-2 + \frac{2}{t}\right)\\ \end{array} \]
Alternative 4
Error32.08%
Cost1112
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ t_3 := -2 + \frac{2}{t}\\ \mathbf{if}\;t \leq -2.2 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.45 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.6 \cdot 10^{-64}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -4.2 \cdot 10^{-155}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{-12}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error32.13%
Cost1112
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := -2 + \frac{2}{t}\\ \mathbf{if}\;t \leq -2.2 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{+22}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;t \leq -8.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5.5 \cdot 10^{-65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.3 \cdot 10^{-155}:\\ \;\;\;\;\frac{\frac{2}{t}}{z}\\ \mathbf{elif}\;t \leq 4.45 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error9.16%
Cost1097
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.15 \cdot 10^{+60} \lor \neg \left(\frac{x}{y} \leq 8.5 \cdot 10^{+49}\right):\\ \;\;\;\;\frac{x}{y} + \frac{2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \end{array} \]
Alternative 7
Error20.83%
Cost972
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -4.1 \cdot 10^{+190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.25 \cdot 10^{-11}:\\ \;\;\;\;-2 + t_1\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{-12}:\\ \;\;\;\;t_1 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error31.66%
Cost850
\[\begin{array}{l} \mathbf{if}\;t \leq -9.2 \cdot 10^{-14} \lor \neg \left(t \leq -9.8 \cdot 10^{-64}\right) \land \left(t \leq -6.2 \cdot 10^{-114} \lor \neg \left(t \leq 1.85 \cdot 10^{-12}\right)\right):\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \end{array} \]
Alternative 9
Error20.8%
Cost844
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -4.1 \cdot 10^{+190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.25 \cdot 10^{-11}:\\ \;\;\;\;-2 + \frac{2}{z \cdot t}\\ \mathbf{elif}\;t \leq 4.6 \cdot 10^{-12}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error32.11%
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.6 \cdot 10^{+41}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 8.5 \cdot 10^{+49}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 11
Error55.85%
Cost712
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.6 \cdot 10^{+41}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 8.5 \cdot 10^{+49}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 12
Error76.16%
Cost192
\[\frac{2}{t} \]

Error

Reproduce?

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