Average Error: 31.9 → 13.9
Time: 1.3s
Precision: 64
\[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.80799321038943598 \cdot 10^{153}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.1149437194271418 \cdot 10^{-121}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 7.1840670810958776 \cdot 10^{-197}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 5.50179953423661776 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le 8.43377683451677154 \cdot 10^{-162}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 3.94437396474587124 \cdot 10^{146}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 1.56773528446000528 \cdot 10^{192}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;x \le -8.80799321038943598 \cdot 10^{153}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -1.1149437194271418 \cdot 10^{-121}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

\mathbf{elif}\;x \le 7.1840670810958776 \cdot 10^{-197}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 5.50179953423661776 \cdot 10^{-172}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le 8.43377683451677154 \cdot 10^{-162}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 3.94437396474587124 \cdot 10^{146}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

\mathbf{elif}\;x \le 1.56773528446000528 \cdot 10^{192}:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;1\\

\end{array}
double code(double x, double y) {
	return ((double) (((double) (((double) (x * x)) - ((double) (((double) (y * 4.0)) * y)))) / ((double) (((double) (x * x)) + ((double) (((double) (y * 4.0)) * y))))));
}
double code(double x, double y) {
	double VAR;
	if ((x <= -8.807993210389436e+153)) {
		VAR = 1.0;
	} else {
		double VAR_1;
		if ((x <= -1.1149437194271418e-121)) {
			VAR_1 = ((double) (((double) (((double) (x * x)) - ((double) (((double) (y * 4.0)) * y)))) / ((double) (((double) (x * x)) + ((double) (((double) (y * 4.0)) * y))))));
		} else {
			double VAR_2;
			if ((x <= 7.184067081095878e-197)) {
				VAR_2 = -1.0;
			} else {
				double VAR_3;
				if ((x <= 5.501799534236618e-172)) {
					VAR_3 = 1.0;
				} else {
					double VAR_4;
					if ((x <= 8.433776834516772e-162)) {
						VAR_4 = -1.0;
					} else {
						double VAR_5;
						if ((x <= 3.9443739647458712e+146)) {
							VAR_5 = ((double) (((double) (((double) (x * x)) - ((double) (((double) (y * 4.0)) * y)))) / ((double) (((double) (x * x)) + ((double) (((double) (y * 4.0)) * y))))));
						} else {
							double VAR_6;
							if ((x <= 1.5677352844600053e+192)) {
								VAR_6 = -1.0;
							} else {
								VAR_6 = 1.0;
							}
							VAR_5 = VAR_6;
						}
						VAR_4 = VAR_5;
					}
					VAR_3 = VAR_4;
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	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

Original31.9
Target31.6
Herbie13.9
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \lt 0.974323384962678118:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot y\right) \cdot 4} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{x}{\sqrt{x \cdot x + \left(y \cdot y\right) \cdot 4}}\right)}^{2} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -8.807993210389436e+153 or 7.184067081095878e-197 < x < 5.501799534236618e-172 or 1.5677352844600053e+192 < x

    1. Initial program 60.8

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Taylor expanded around inf 11.6

      \[\leadsto \color{blue}{1}\]

    if -8.807993210389436e+153 < x < -1.1149437194271418e-121 or 8.433776834516772e-162 < x < 3.9443739647458712e+146

    1. Initial program 15.5

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]

    if -1.1149437194271418e-121 < x < 7.184067081095878e-197 or 5.501799534236618e-172 < x < 8.433776834516772e-162 or 3.9443739647458712e+146 < x < 1.5677352844600053e+192

    1. Initial program 33.5

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Taylor expanded around 0 13.2

      \[\leadsto \color{blue}{-1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8.80799321038943598 \cdot 10^{153}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.1149437194271418 \cdot 10^{-121}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 7.1840670810958776 \cdot 10^{-197}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 5.50179953423661776 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le 8.43377683451677154 \cdot 10^{-162}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 3.94437396474587124 \cdot 10^{146}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 1.56773528446000528 \cdot 10^{192}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2020120 +o rules:numerics
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))))

  (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))))