Average Error: 0.0 → 0.0
Time: 5.3s
Precision: binary64
Cost: 448
\[\frac{x - y}{1 - y} \]
\[\frac{y - x}{y + -1} \]
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
(FPCore (x y) :precision binary64 (/ (- y x) (+ y -1.0)))
double code(double x, double y) {
	return (x - y) / (1.0 - y);
}
double code(double x, double y) {
	return (y - x) / (y + -1.0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x - y) / (1.0d0 - y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (y - x) / (y + (-1.0d0))
end function
public static double code(double x, double y) {
	return (x - y) / (1.0 - y);
}
public static double code(double x, double y) {
	return (y - x) / (y + -1.0);
}
def code(x, y):
	return (x - y) / (1.0 - y)
def code(x, y):
	return (y - x) / (y + -1.0)
function code(x, y)
	return Float64(Float64(x - y) / Float64(1.0 - y))
end
function code(x, y)
	return Float64(Float64(y - x) / Float64(y + -1.0))
end
function tmp = code(x, y)
	tmp = (x - y) / (1.0 - y);
end
function tmp = code(x, y)
	tmp = (y - x) / (y + -1.0);
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(y - x), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]
\frac{x - y}{1 - y}
\frac{y - x}{y + -1}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\frac{x - y}{1 - y} \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{y - x}{y + -1}} \]
    Proof
    (/.f64 (-.f64 y x) (+.f64 y -1)): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 y x) (+.f64 y (Rewrite<= metadata-eval (neg.f64 1)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 y x) (Rewrite<= sub-neg_binary64 (-.f64 y 1))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (-.f64 y x) (-.f64 y 1)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 (-.f64 y x) (-.f64 y 1))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 (-.f64 y x)) (*.f64 -1 (-.f64 y 1)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 -1 (-.f64 y x)) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 y 1)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 -1 (-.f64 y x)) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 y 1)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 -1 (-.f64 y x)) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 y) 1))): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 -1 (-.f64 y x)) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 y)) 1)): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 -1 (-.f64 y x)) (Rewrite<= +-commutative_binary64 (+.f64 1 (neg.f64 y)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 -1 (-.f64 y x)) (Rewrite<= sub-neg_binary64 (-.f64 1 y))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 y x))) (-.f64 1 y)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 y x))) (-.f64 1 y)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 y) x)) (-.f64 1 y)): 0 points increase in error, 0 points decrease in error
    (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 y)) x) (-.f64 1 y)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 y))) (-.f64 1 y)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= sub-neg_binary64 (-.f64 x y)) (-.f64 1 y)): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

    \[\leadsto \frac{y - x}{y + -1} \]

Alternatives

Alternative 1
Error18.5
Cost1048
\[\begin{array}{l} t_0 := \frac{-x}{y}\\ \mathbf{if}\;y \leq -8.64343690593473 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -192994795141820.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.938365322591509 \cdot 10^{-22}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.42329780547036 \cdot 10^{+72}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.6849126385726293 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error18.5
Cost1048
\[\begin{array}{l} t_0 := \frac{-x}{y}\\ \mathbf{if}\;y \leq -8.64343690593473 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -192994795141820.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.938365322591509 \cdot 10^{-22}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.42329780547036 \cdot 10^{+72}:\\ \;\;\;\;1 + \frac{1}{y}\\ \mathbf{elif}\;y \leq 2.6849126385726293 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error18.5
Cost1048
\[\begin{array}{l} t_0 := \frac{-x}{y}\\ \mathbf{if}\;y \leq -8.64343690593473 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -192994795141820.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.938365322591509 \cdot 10^{-22}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x + y \cdot x\\ \mathbf{elif}\;y \leq 3.42329780547036 \cdot 10^{+72}:\\ \;\;\;\;1 + \frac{1}{y}\\ \mathbf{elif}\;y \leq 2.6849126385726293 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error11.1
Cost1048
\[\begin{array}{l} t_0 := 1 + \frac{1}{y}\\ t_1 := \frac{-x}{y}\\ \mathbf{if}\;y \leq -8.64343690593473 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -192994795141820.56:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8593051602052.214:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x - y\\ \mathbf{elif}\;y \leq 3.42329780547036 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.6849126385726293 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error10.7
Cost1048
\[\begin{array}{l} t_0 := \frac{-x}{y}\\ \mathbf{if}\;y \leq -8.64343690593473 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -192994795141820.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.434899206837755 \cdot 10^{-6}:\\ \;\;\;\;\frac{y}{y + -1}\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x - y\\ \mathbf{elif}\;y \leq 3.42329780547036 \cdot 10^{+72}:\\ \;\;\;\;1 + \frac{1}{y}\\ \mathbf{elif}\;y \leq 2.6849126385726293 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error2.0
Cost712
\[\begin{array}{l} t_0 := 1 + \frac{1 - x}{y}\\ \mathbf{if}\;y \leq -8593051602052.214:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x - y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error2.1
Cost584
\[\begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -8593051602052.214:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x - y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error17.1
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -0.006875490932459209:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3.9736313734522685 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error39.3
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022302 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, C"
  :precision binary64
  (/ (- x y) (- 1.0 y)))