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

Derivation

  1. Initial program 9.1

    \[\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))): 21 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 z 2)) z) (/.f64 2 z)) t))): 12 points increase in error, 21 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (/.f64 (*.f64 z 2) (Rewrite<= *-lft-identity_binary64 (*.f64 1 z))) (/.f64 2 z)) t))): 0 points increase in error, 12 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 (Rewrite=> times-frac_binary64 (*.f64 (/.f64 z 1) (/.f64 2 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 (*.f64 (Rewrite=> /-rgt-identity_binary64 z) (/.f64 2 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 (*.f64 z (/.f64 2 z)) (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 2 z)))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 (/.f64 2 z) (+.f64 z 1))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (*.f64 (/.f64 2 z) (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 z)) 1)) t))): 23 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 (*.f64 1 z) 1) t))))): 0 points increase in error, 23 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (Rewrite=> *-commutative_binary64 (*.f64 (/.f64 (+.f64 (*.f64 1 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 (*.f64 1 z) 1) 2) (*.f64 t z))))): 2 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (Rewrite<= distribute-rgt1-in_binary64 (+.f64 2 (*.f64 (*.f64 1 z) 2))) (*.f64 t z)))): 12 points increase in error, 2 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (*.f64 2 -1) (/.f64 (+.f64 2 (Rewrite<= associate-*r*_binary64 (*.f64 1 (*.f64 z 2)))) (*.f64 t z)))): 21 points increase in error, 14 points decrease in error
    (+.f64 (/.f64 x y) (Rewrite=> +-commutative_binary64 (+.f64 (/.f64 (+.f64 2 (*.f64 1 (*.f64 z 2))) (*.f64 t z)) (*.f64 2 -1)))): 0 points increase in error, 21 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (/.f64 (+.f64 2 (*.f64 1 (*.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 1 (*.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 1 (*.f64 z 2))) (*.f64 t z)) 2))): 23 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 1 (*.f64 z 2))) (*.f64 t z)) (Rewrite<= metadata-eval (*.f64 1 2)))): 0 points increase in error, 23 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 1 (*.f64 z 2))) (*.f64 t z)) (*.f64 (Rewrite<= *-inverses_binary64 (/.f64 (*.f64 t z) (*.f64 t z))) 2))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (-.f64 (/.f64 (+.f64 2 (*.f64 1 (*.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 1 (*.f64 z 2))) (*.f64 t z)) (/.f64 (Rewrite<= associate-*r*_binary64 (*.f64 t (*.f64 z 2))) (*.f64 t z)))): 13 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (Rewrite<= div-sub_binary64 (/.f64 (-.f64 (+.f64 2 (*.f64 1 (*.f64 z 2))) (*.f64 t (*.f64 z 2))) (*.f64 t z)))): 0 points increase in error, 13 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (Rewrite=> cancel-sign-sub-inv_binary64 (+.f64 (+.f64 2 (*.f64 1 (*.f64 z 2))) (*.f64 (neg.f64 t) (*.f64 z 2)))) (*.f64 t z))): 2 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (Rewrite<= associate-+r+_binary64 (+.f64 2 (+.f64 (*.f64 1 (*.f64 z 2)) (*.f64 (neg.f64 t) (*.f64 z 2))))) (*.f64 t z))): 13 points increase in error, 2 points decrease in error
    (+.f64 (/.f64 x y) (/.f64 (+.f64 2 (Rewrite<= distribute-rgt-in_binary64 (*.f64 (*.f64 z 2) (+.f64 1 (neg.f64 t))))) (*.f64 t z))): 0 points increase in error, 13 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
    (+.f64 (/.f64 x y) (Rewrite<= +-lft-identity_binary64 (+.f64 0 (/.f64 (+.f64 2 (*.f64 (*.f64 z 2) (-.f64 1 t))) (*.f64 t z))))): 13 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 x y) (+.f64 (Rewrite<= mul0-lft_binary64 (*.f64 0 (/.f64 2 (*.f64 t z)))) (/.f64 (+.f64 2 (*.f64 (*.f64 z 2) (-.f64 1 t))) (*.f64 t z)))): 0 points increase in error, 1 points decrease in error
    (Rewrite=> associate-+r+_binary64 (+.f64 (+.f64 (/.f64 x y) (*.f64 0 (/.f64 2 (*.f64 t z)))) (/.f64 (+.f64 2 (*.f64 (*.f64 z 2) (-.f64 1 t))) (*.f64 t z)))): 2 points increase in error, 12 points decrease in error
    (+.f64 (+.f64 (/.f64 x y) (Rewrite=> mul0-lft_binary64 0)) (/.f64 (+.f64 2 (*.f64 (*.f64 z 2) (-.f64 1 t))) (*.f64 t z))): 0 points increase in error, 2 points decrease in error
    (+.f64 (Rewrite=> +-rgt-identity_binary64 (/.f64 x y)) (/.f64 (+.f64 2 (*.f64 (*.f64 z 2) (-.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
Error27.4
Cost1377
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ t_2 := \frac{x}{y} + -2\\ \mathbf{if}\;z \leq -1.05 \cdot 10^{-43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.6 \cdot 10^{-260}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+139} \lor \neg \left(z \leq 8.8 \cdot 10^{+269}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \end{array} \]
Alternative 2
Error27.5
Cost1377
\[\begin{array}{l} t_1 := \frac{x}{y} + -2\\ t_2 := \frac{2}{z \cdot t}\\ \mathbf{if}\;z \leq -1.1 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{2}{t}}{z}\\ \mathbf{elif}\;z \leq -3.05 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{-179}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-27}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+139} \lor \neg \left(z \leq 1.6 \cdot 10^{+267}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \end{array} \]
Alternative 3
Error18.1
Cost1372
\[\begin{array}{l} t_1 := \frac{\frac{2}{t}}{z}\\ t_2 := \frac{x}{y} + \frac{2}{t}\\ t_3 := \frac{x}{y} + -2\\ \mathbf{if}\;t \leq -6.2 \cdot 10^{+44}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -5.8 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-171}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -4.4 \cdot 10^{-206}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;t \leq 7.8 \cdot 10^{-123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{-81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error13.1
Cost1369
\[\begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;z \leq -6 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{2}{t}}{z}\\ \mathbf{elif}\;z \leq -1.95 \cdot 10^{-259}:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{-179} \lor \neg \left(z \leq 1.1 \cdot 10^{-126}\right) \land z \leq 3.1 \cdot 10^{-29}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error30.7
Cost1232
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 6.2 \cdot 10^{-154}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq 8.6 \cdot 10^{-114}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq 12200:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 6
Error5.4
Cost1225
\[\begin{array}{l} t_1 := \frac{2}{z \cdot t}\\ \mathbf{if}\;\frac{x}{y} \leq -35 \lor \neg \left(\frac{x}{y} \leq 2.2 \cdot 10^{+15}\right):\\ \;\;\;\;\frac{x}{y} + t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{t} + \left(-2 + t_1\right)\\ \end{array} \]
Alternative 7
Error6.3
Cost1106
\[\begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-14} \lor \neg \left(z \leq -9 \cdot 10^{-75}\right) \land \left(z \leq -1.35 \cdot 10^{-112} \lor \neg \left(z \leq 5.4 \cdot 10^{-9}\right)\right):\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \frac{2}{z \cdot t}\\ \end{array} \]
Alternative 8
Error19.8
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -35:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 3.7 \cdot 10^{+15}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 9
Error19.7
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -0.68:\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{elif}\;\frac{x}{y} \leq 1.4 \cdot 10^{+15}:\\ \;\;\;\;-2 + \frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 10
Error12.8
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -3.4 \cdot 10^{+44} \lor \neg \left(t \leq 2.5 \cdot 10^{+21}\right):\\ \;\;\;\;\frac{x}{y} + -2\\ \mathbf{else}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \end{array} \]
Alternative 11
Error33.3
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -1:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 1:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 12
Error47.7
Cost64
\[-2 \]

Error

Reproduce

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