Average Error: 15.7 → 0.4
Time: 1.4s
Precision: binary64
\[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -322271592820320174000 \lor \neg \left(x \le 3.9295909093680808 \cdot 10^{-78}\right):\\ \;\;\;\;\frac{\frac{x - y}{x \cdot 2}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{y}\\ \end{array}\]
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;x \le -322271592820320174000 \lor \neg \left(x \le 3.9295909093680808 \cdot 10^{-78}\right):\\
\;\;\;\;\frac{\frac{x - y}{x \cdot 2}}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{x - y}{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 (((x <= -3.222715928203202e+20) || !(x <= 3.929590909368081e-78))) {
		VAR = ((double) (((double) (((double) (x - y)) / ((double) (x * 2.0)))) / y));
	} else {
		VAR = ((double) (((double) (1.0 / ((double) (x * 2.0)))) * ((double) (((double) (x - y)) / 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.7
Target0.0
Herbie0.4
\[\frac{0.5}{y} - \frac{0.5}{x}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -322271592820320174000 or 3.9295909093680808e-78 < x

    1. Initial program 14.7

      \[\frac{x - y}{\left(x \cdot 2\right) \cdot y}\]
    2. Using strategy rm
    3. Applied associate-/r*0.6

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

    if -322271592820320174000 < x < 3.9295909093680808e-78

    1. Initial program 16.9

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

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

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

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

Reproduce

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