Average Error: 9.3 → 0.1
Time: 16.9s
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))): 4 points increase in error, 0 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))): 0 points increase in error, 1 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))))): 52 points increase in error, 8 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))))): 19 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))): 40 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)))): 2 points increase in error, 2 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))): 1 points increase in error, 1 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
Error31.5
Cost1492
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -106.4603989295853:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -1.322234774983673 \cdot 10^{-170}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq -4.485578153984884 \cdot 10^{-205}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq 3.652987621178514 \cdot 10^{-185}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq 1.8977414785096288 \cdot 10^{+34}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 2
Error5.5
Cost1224
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ \mathbf{if}\;\frac{x}{y} \leq -4.772843299438608 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 1.8977414785096288 \cdot 10^{+34}:\\ \;\;\;\;\frac{\frac{2}{t}}{z} + t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{z \cdot t}\\ \end{array} \]
Alternative 3
Error23.7
Cost1112
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := \frac{\frac{2}{z}}{t}\\ t_3 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -3.666230350181237 \cdot 10^{+23}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -3.2799064600894703 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.4 \cdot 10^{-179}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-290}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-114}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 210269258469706050:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error23.7
Cost1112
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -3.666230350181237 \cdot 10^{+23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.2799064600894703 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.4 \cdot 10^{-179}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-290}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-114}:\\ \;\;\;\;\frac{\frac{2}{z}}{t}\\ \mathbf{elif}\;z \leq 210269258469706050:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error5.5
Cost1096
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -4.772843299438608 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{elif}\;\frac{x}{y} \leq 1.773330799941989 \cdot 10^{+35}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \frac{\frac{2}{t}}{z}\\ \end{array} \]
Alternative 6
Error5.5
Cost1096
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -4.772843299438608 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{elif}\;\frac{x}{y} \leq 1.8977414785096288 \cdot 10^{+34}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{z \cdot t}\\ \end{array} \]
Alternative 7
Error12.2
Cost972
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -7.807923211389485 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.737905137739322 \cdot 10^{-15}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{elif}\;t \leq 1.464667427219945 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{y} + \frac{\frac{2}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error19.2
Cost844
\[\begin{array}{l} t_1 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -3.666230350181237 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.2799064600894703 \cdot 10^{-54}:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{elif}\;z \leq 1.9518928766427539 \cdot 10^{-10}:\\ \;\;\;\;-2 + \frac{\frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error5.9
Cost840
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -1.6654633518536546 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.9518928766427539 \cdot 10^{-10}:\\ \;\;\;\;\frac{x}{y} + \frac{\frac{2}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error19.9
Cost716
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -1.6827032456677398 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{-98}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;t \leq 7.737905137739322 \cdot 10^{-15}:\\ \;\;\;\;\frac{\frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error12.7
Cost712
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -7.807923211389485 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.001894371348638763:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error20.1
Cost584
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -1.6827032456677398 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.737905137739322 \cdot 10^{-15}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error33.3
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -31.516396422147622:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 7.886223072007603 \cdot 10^{-6}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 14
Error47.2
Cost64
\[-2 \]

Error

Reproduce

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