Average Error: 15.2 → 0.2
Time: 1.6s
Precision: binary64
\[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.79882819304230529 \cdot 10^{47} \lor \neg \left(y \le 3.09619529082247742 \cdot 10^{47}\right):\\ \;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{y + x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y \cdot \frac{x}{\frac{y + x}{2}}}\\ \end{array}\]
\frac{x + y}{\left(x \cdot 2\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;y \le -1.79882819304230529 \cdot 10^{47} \lor \neg \left(y \le 3.09619529082247742 \cdot 10^{47}\right):\\
\;\;\;\;\frac{1}{x \cdot 2} \cdot \frac{y + x}{y}\\

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

\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 <= -1.7988281930423053e+47) || !(y <= 3.0961952908224774e+47))) {
		VAR = ((double) (((double) (1.0 / ((double) (x * 2.0)))) * ((double) (((double) (y + x)) / y))));
	} else {
		VAR = ((double) (1.0 / ((double) (y * ((double) (x / ((double) (((double) (y + x)) / 2.0))))))));
	}
	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.2
Target0.0
Herbie0.2
\[\frac{0.5}{x} + \frac{0.5}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.79882819304230529e47 or 3.09619529082247742e47 < y

    1. Initial program 17.5

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

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

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

    if -1.79882819304230529e47 < y < 3.09619529082247742e47

    1. Initial program 13.5

      \[\frac{x + y}{\left(x \cdot 2\right) \cdot y}\]
    2. Using strategy rm
    3. Applied clear-num13.4

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

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

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

Reproduce

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

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

  (/ (+ x y) (* (* x 2.0) y)))