?

Average Error: 9.2 → 0.1
Time: 13.6s
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

Original9.2
Target0.1
Herbie0.1
\[\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right) \]

Derivation?

  1. Initial program 9.2

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

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

    [Start]9.2

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

    +-rgt-identity [<=]9.2

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

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

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

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

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

    sub-neg [=>]9.2

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

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

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

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

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

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

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

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

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

    sub-neg [=>]0.1

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

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

Alternatives

Alternative 1
Error16.4
Cost2136
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ t_2 := \frac{2}{z \cdot t}\\ t_3 := \frac{x}{y} + t_2\\ \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{+31}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{x}{y} \leq -2.8 \cdot 10^{-117}:\\ \;\;\;\;t_2 + \frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq -6.7 \cdot 10^{-239}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{-319}:\\ \;\;\;\;-2 + \frac{\frac{2}{t}}{z}\\ \mathbf{elif}\;\frac{x}{y} \leq 1.25 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 1.8 \cdot 10^{-16}:\\ \;\;\;\;-2 + t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error19.5
Cost2008
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ t_2 := \frac{x}{y} + -2\\ t_3 := -2 + \frac{2}{z \cdot t}\\ \mathbf{if}\;\frac{x}{y} \leq -16000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{x}{y} \leq -2.2 \cdot 10^{-124}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{x}{y} \leq -6.2 \cdot 10^{-221}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{-319}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{x}{y} \leq 1.45 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 6.4 \cdot 10^{-10}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error26.3
Cost1904
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := -2 + \frac{2}{t}\\ t_3 := \frac{2}{z \cdot t}\\ \mathbf{if}\;z \leq -1.25 \cdot 10^{+191}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{+76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.25 \cdot 10^{+24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-107}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-163}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-70}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+291}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 4
Error26.4
Cost1904
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := -2 + \frac{2}{t}\\ t_3 := \frac{2}{z \cdot t}\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{+192}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{+76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.92 \cdot 10^{+25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.05 \cdot 10^{-110}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.45 \cdot 10^{-163}:\\ \;\;\;\;\frac{\frac{2}{t}}{z}\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+205}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+291}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 5
Error5.2
Cost1225
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ \mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+32} \lor \neg \left(\frac{x}{y} \leq 4 \cdot 10^{+14}\right):\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{t} + \left(-2 + t_1\right)\\ \end{array} \]
Alternative 6
Error5.2
Cost1097
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+32} \lor \neg \left(\frac{x}{y} \leq 4 \cdot 10^{+14}\right):\\ \;\;\;\;\frac{x}{y} + \frac{2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \end{array} \]
Alternative 7
Error12.1
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -0.0195 \lor \neg \left(t \leq 2 \cdot 10^{+30}\right):\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z \cdot t} + \frac{2}{t}\\ \end{array} \]
Alternative 8
Error19.8
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.55 \cdot 10^{+32}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 3.1 \cdot 10^{+14}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 9
Error12.1
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -0.0155 \lor \neg \left(t \leq 2 \cdot 10^{+30}\right):\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \end{array} \]
Alternative 10
Error29.8
Cost712
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -2:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 4.5 \cdot 10^{-6}:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 11
Error33.9
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -0.54:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 2 \cdot 10^{+30}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 12
Error47.2
Cost64
\[-2 \]

Error

Reproduce?

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