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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.3
Target0.0
Herbie0.0
\[\frac{0.5}{y} - \frac{0.5}{x} \]

Derivation

  1. Initial program 15.3

    \[\frac{x - y}{\left(x \cdot 2\right) \cdot y} \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{0.5}{y} - \frac{0.5}{x}} \]
    Proof
    (-.f64 (/.f64 1/2 y) (/.f64 1/2 x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 1 2)) y) (/.f64 1/2 x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (/.f64 (Rewrite<= *-inverses_binary64 (/.f64 x x)) 2) y) (/.f64 1/2 x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 x 2))) y) (/.f64 1/2 x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 (*.f64 x 2) y))) (/.f64 1/2 x)): 69 points increase in error, 1 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (/.f64 (Rewrite<= metadata-eval (/.f64 1 2)) x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (/.f64 (/.f64 (Rewrite<= *-inverses_binary64 (/.f64 x x)) 2) x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (Rewrite<= associate-/r*_binary64 (/.f64 (/.f64 x x) (*.f64 2 x)))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (/.f64 (/.f64 x x) (Rewrite<= *-commutative_binary64 (*.f64 x 2)))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (/.f64 (Rewrite=> *-inverses_binary64 1) (*.f64 x 2))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (/.f64 (Rewrite<= *-inverses_binary64 (/.f64 y y)) (*.f64 x 2))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 x (*.f64 (*.f64 x 2) y)) (Rewrite=> associate-/l/_binary64 (/.f64 y (*.f64 (*.f64 x 2) y)))): 49 points increase in error, 9 points decrease in error
    (Rewrite<= div-sub_binary64 (/.f64 (-.f64 x y) (*.f64 (*.f64 x 2) y))): 1 points increase in error, 2 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error16.4
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+30}:\\ \;\;\;\;\frac{0.5}{y}\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-55}:\\ \;\;\;\;\frac{-0.5}{x}\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-85}:\\ \;\;\;\;\frac{0.5}{y}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-23}:\\ \;\;\;\;\frac{-0.5}{x}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+99}:\\ \;\;\;\;\frac{0.5}{y}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+116}:\\ \;\;\;\;\frac{-0.5}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{y}\\ \end{array} \]
Alternative 2
Error31.5
Cost192
\[\frac{-0.5}{x} \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (- (/ 0.5 y) (/ 0.5 x))

  (/ (- x y) (* (* x 2.0) y)))