Average Error: 15.0 → 0.2
Time: 1.7s
Precision: binary64
\[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -8.2372799857811895 \cdot 10^{-37} \lor \neg \left(y \le 45469584158578664\right):\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{x \cdot 2} \cdot \frac{1}{y}\\ \end{array}\]
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;y \le -8.2372799857811895 \cdot 10^{-37} \lor \neg \left(y \le 45469584158578664\right):\\
\;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x - y}{x \cdot 2} \cdot \frac{1}{y}\\

\end{array}
double code(double x, double y) {
	return ((double) (((double) (x - y)) / ((double) (((double) (x * 2.0)) * y))));
}
double code(double x, double y) {
	double VAR;
	if (((y <= -8.23727998578119e-37) || !(y <= 45469584158578664.0))) {
		VAR = ((double) (((double) (1.0 / ((double) (x * 2.0)))) * ((double) (((double) (x - y)) / y))));
	} else {
		VAR = ((double) (((double) (((double) (x - y)) / ((double) (x * 2.0)))) * ((double) (1.0 / y))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if y < -8.2372799857811895e-37 or 45469584158578664 < y

    1. Initial program 14.3

      \[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity14.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - y\right)}}{\left(x \cdot 2\right) \cdot y}\]
    4. Applied times-frac0.3

      \[\leadsto \color{blue}{\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}}\]

    if -8.2372799857811895e-37 < y < 45469584158578664

    1. Initial program 15.8

      \[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity15.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - y\right)}}{\left(x \cdot 2\right) \cdot y}\]
    4. Applied times-frac16.8

      \[\leadsto \color{blue}{\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}}\]
    5. Using strategy rm
    6. Applied div-inv16.8

      \[\leadsto \frac{1}{x \cdot 2} \cdot \color{blue}{\left(\left(x - y\right) \cdot \frac{1}{y}\right)}\]
    7. Applied associate-*r*0.2

      \[\leadsto \color{blue}{\left(\frac{1}{x \cdot 2} \cdot \left(x - y\right)\right) \cdot \frac{1}{y}}\]
    8. Simplified0.1

      \[\leadsto \color{blue}{\frac{x - y}{x \cdot 2}} \cdot \frac{1}{y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -8.2372799857811895 \cdot 10^{-37} \lor \neg \left(y \le 45469584158578664\right):\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{x \cdot 2} \cdot \frac{1}{y}\\ \end{array}\]

Reproduce

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