Average Error: 9.6 → 0.1
Time: 16.6s
Precision: binary64
Cost: 960
\[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
\[\frac{x}{y} + \left(-2 + \frac{1}{t} \cdot \left(2 + \frac{2}{z}\right)\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 (* (/ 1.0 t) (+ 2.0 (/ 2.0 z))))))
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 + ((1.0 / t) * (2.0 + (2.0 / z))));
}
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) + ((1.0d0 / t) * (2.0d0 + (2.0d0 / z))))
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 + ((1.0 / t) * (2.0 + (2.0 / z))));
}
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 + ((1.0 / t) * (2.0 + (2.0 / z))))
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(1.0 / t) * Float64(2.0 + Float64(2.0 / z)))))
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 + ((1.0 / t) * (2.0 + (2.0 / z))));
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[(1.0 / t), $MachinePrecision] * N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision]), $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{1}{t} \cdot \left(2 + \frac{2}{z}\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 9.6

    \[\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))))): 48 points increase in error, 9 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))))): 9 points increase in error, 47 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))): 26 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, 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, 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. Applied egg-rr0.1

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

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

Alternatives

Alternative 1
Error24.6
Cost1640
\[\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 -4.88146129393592 \cdot 10^{+138}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.08 \cdot 10^{-150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-232}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-179}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3.239117773031044 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.203510316292866 \cdot 10^{+203}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 2.3807628322235074 \cdot 10^{+251}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error30.0
Cost1492
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -5.543413314817089 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -4.153040785521818 \cdot 10^{-12}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq -1.1449599997397869 \cdot 10^{-132}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq -3.2804819141557294 \cdot 10^{-221}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq 70181.00389210797:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 3
Error1.3
Cost1352
\[\begin{array}{l} t_1 := \frac{x}{y} + \frac{2 + 2 \cdot z}{t \cdot z}\\ \mathbf{if}\;\frac{x}{y} \leq -5.543413314817089 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 1.1249391322062652:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error8.8
Cost1096
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.2774809762828962 \cdot 10^{+60}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 1.0736819129393307 \cdot 10^{+62}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + -2\\ \end{array} \]
Alternative 5
Error5.4
Cost1096
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;\frac{x}{y} \leq -5.543413314817089 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 1.7137236222292127 \cdot 10^{-16}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error5.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -5.543413314817089 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\ \mathbf{elif}\;\frac{x}{y} \leq 1.7137236222292127 \cdot 10^{-16}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \end{array} \]
Alternative 7
Error20.7
Cost980
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := -2 + \frac{2}{t}\\ \mathbf{if}\;z \leq -4.88146129393592 \cdot 10^{+138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.00027700226174603364:\\ \;\;\;\;-2 + \frac{2}{t \cdot z}\\ \mathbf{elif}\;z \leq 2.203510316292866 \cdot 10^{+203}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.3807628322235074 \cdot 10^{+251}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error0.8
Cost968
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -15.297960698368332:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.00027700226174603364:\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t \cdot z}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error19.7
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -5.543413314817089 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 70181.00389210797:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 10
Error12.0
Cost840
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -65479.333014870856:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.871767737338084 \cdot 10^{-8}:\\ \;\;\;\;\frac{1}{t} \cdot \left(2 + \frac{2}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error0.1
Cost832
\[\frac{x}{y} + \left(-2 + \frac{2 + \frac{2}{z}}{t}\right) \]
Alternative 12
Error11.9
Cost712
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -65479.333014870856:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.871767737338084 \cdot 10^{-8}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error33.7
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -1884.1561765682204:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 4.871767737338084 \cdot 10^{-8}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 14
Error47.2
Cost64
\[-2 \]

Error

Reproduce

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