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

Derivation

  1. Initial program 9.3

    \[\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))): 5 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))))): 50 points increase in error, 10 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))))): 18 points increase in error, 53 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))): 44 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))))): 1 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, 1 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))): 2 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
Error14.5
Cost1104
\[\begin{array}{l} t_1 := \frac{x}{y} + \frac{\frac{2}{t}}{z}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -6.509925310504709 \cdot 10^{+106}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.5 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.589554350267228 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t}\\ \mathbf{elif}\;t \leq 3.910965576672543 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error14.5
Cost1104
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -6.509925310504709 \cdot 10^{+106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.5 \cdot 10^{-117}:\\ \;\;\;\;\frac{x}{y} + \frac{\frac{2}{z}}{t}\\ \mathbf{elif}\;t \leq 7.589554350267228 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t}\\ \mathbf{elif}\;t \leq 3.910965576672543 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{y} + \frac{\frac{2}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error7.2
Cost968
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;t \leq -667.5808647849611:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.910965576672543 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{y} + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.7
Cost968
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -670326972.0801347:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.276182892104151:\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{\frac{2}{z}}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error5.8
Cost840
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -9.584613315431676 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.4363721972455625 \cdot 10^{-15}:\\ \;\;\;\;\frac{x}{y} + \frac{\frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error15.3
Cost712
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -667.5808647849611:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.05773752545554722:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error29.8
Cost320
\[\frac{x}{y} + -2 \]

Error

Reproduce

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