Average Error: 9.0 → 0.1
Time: 14.7s
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.0
Target0.1
Herbie0.1
\[\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right) \]

Derivation

  1. Initial program 9.0

    \[\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
    (+.f64 (/.f64 x y) (+.f64 -2 (/.f64 (+.f64 2 (/.f64 2 z)) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (Rewrite<= metadata-eval (*.f64 2 -1)) (/.f64 (+.f64 2 (/.f64 2 z)) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (Rewrite<= metadata-eval (/.f64 2 1)) (/.f64 2 z)) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (/.f64 2 (Rewrite<= *-inverses_binary64 (/.f64 z z))) (/.f64 2 z)) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 2 z) z)) (/.f64 2 z)) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 2 z) z)) (/.f64 2 z)) t))): 7 points increase in error, 1 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (*.f64 (/.f64 2 z) z) (Rewrite<= *-rgt-identity_binary64 (*.f64 (/.f64 2 z) 1))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (Rewrite<= distribute-lft-in_binary64 (*.f64 (/.f64 2 z) (+.f64 z 1))) t))): 1 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (Rewrite<= associate-*r/_binary64 (*.f64 (/.f64 2 z) (/.f64 (+.f64 z 1) t))))): 61 points increase in error, 6 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (Rewrite=> *-commutative_binary64 (*.f64 (/.f64 (+.f64 z 1) t) (/.f64 2 z))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (+.f64 z 1) 2) (*.f64 t z))))): 12 points increase in error, 63 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (Rewrite<= distribute-rgt1-in_binary64 (+.f64 2 (*.f64 z 2))) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (Rewrite=> +-commutative_binary64 (+.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (*.f64 2 -1)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (Rewrite=> metadata-eval -2))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (Rewrite<= metadata-eval (neg.f64 2)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (Rewrite<= sub-neg_binary64 (-.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) 2))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (Rewrite<= metadata-eval (*.f64 1 2)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (*.f64 (Rewrite<= *-inverses_binary64 (/.f64 (*.f64 t z) (*.f64 t z))) 2))): 35 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 (*.f64 t z) 2) (*.f64 t z))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t z)) (/.f64 (Rewrite<= associate-*r*_binary64 (*.f64 t (*.f64 z 2))) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (Rewrite<= div-sub_binary64 (/.f64 (-.f64 (+.f64 2 (*.f64 z 2)) (*.f64 t (*.f64 z 2))) (*.f64 t z)))): 1 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (Rewrite=> cancel-sign-sub-inv_binary64 (+.f64 (+.f64 2 (*.f64 z 2)) (*.f64 (neg.f64 t) (*.f64 z 2)))) (*.f64 t z))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (Rewrite<= associate-+r+_binary64 (+.f64 2 (+.f64 (*.f64 z 2) (*.f64 (neg.f64 t) (*.f64 z 2))))) (*.f64 t z))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (+.f64 2 (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (*.f64 z 2))) (*.f64 (neg.f64 t) (*.f64 z 2)))) (*.f64 t z))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (+.f64 2 (Rewrite=> distribute-rgt-out_binary64 (*.f64 (*.f64 z 2) (+.f64 1 (neg.f64 t))))) (*.f64 t z))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (+.f64 2 (*.f64 (*.f64 z 2) (Rewrite<= sub-neg_binary64 (-.f64 1 t)))) (*.f64 t z))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error20.0
Cost1360
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ \mathbf{if}\;\frac{x}{y} \leq -1168910850498.222:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{elif}\;\frac{x}{y} \leq -2.700554558700592 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 1.6553491821072694 \cdot 10^{-170}:\\ \;\;\;\;-2 + \frac{2}{z \cdot t}\\ \mathbf{elif}\;\frac{x}{y} \leq 1846905856050382300:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 2
Error1.1
Cost1352
\[\begin{array}{l} t_1 := \frac{x}{y} + \frac{2 + 2 \cdot z}{z \cdot t}\\ \mathbf{if}\;\frac{x}{y} \leq -1168910850498.222:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 8.044543930730885 \cdot 10^{-15}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error5.1
Cost1096
\[\begin{array}{l} t_1 := \frac{x}{y} + \frac{2}{t}\\ \mathbf{if}\;\frac{x}{y} \leq -1168910850498.222:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 0.01415147627440804:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error5.0
Cost1096
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.826648482449921 \cdot 10^{-15}:\\ \;\;\;\;\frac{2}{t} + \left(\frac{x}{y} + -2\right)\\ \mathbf{elif}\;\frac{x}{y} \leq 0.01415147627440804:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t}\\ \end{array} \]
Alternative 5
Error19.9
Cost980
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -268582.841076873:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9.831754152487704 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.6 \cdot 10^{-127}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-94}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8.406323118373682 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error15.5
Cost976
\[\begin{array}{l} t_1 := -2 + \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -268582.841076873:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9.831754152487704 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.0008227368820204887:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t}\\ \mathbf{elif}\;t \leq 4.070362620659169 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error12.4
Cost976
\[\begin{array}{l} t_1 := \frac{2 + \frac{2}{z}}{t}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -268582.841076873:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-94}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t}\\ \mathbf{elif}\;t \leq 8.406323118373682 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error19.7
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1168910850498.222:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 1846905856050382300:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 9
Error35.0
Cost712
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1168910850498.222:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 1846905856050382300:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 10
Error48.1
Cost192
\[\frac{2}{t} \]

Error

Reproduce

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