Average Error: 31.5 → 13.8
Time: 1.7s
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 \cdot x \le 5.17370770179536029 \cdot 10^{-272}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 2.4428144053544969 \cdot 10^{-230}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \cdot x \le 5.91172502428276112 \cdot 10^{-212}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.8714042555935421 \cdot 10^{-176}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \cdot x \le 8.29735288633369066 \cdot 10^{-53}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 2.90550718250568474 \cdot 10^{226}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \cdot x \le 1.0347887184723732 \cdot 10^{274}:\\ \;\;\;\;-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 \cdot x \le 5.17370770179536029 \cdot 10^{-272}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \cdot x \le 5.91172502428276112 \cdot 10^{-212}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \cdot x \le 8.29735288633369066 \cdot 10^{-53}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \cdot x \le 1.0347887184723732 \cdot 10^{274}:\\
\;\;\;\;-1\\

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

\end{array}
double code(double x, double y) {
	return (((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)));
}
double code(double x, double y) {
	double VAR;
	if (((x * x) <= 5.17370770179536e-272)) {
		VAR = -1.0;
	} else {
		double VAR_1;
		if (((x * x) <= 2.442814405354497e-230)) {
			VAR_1 = (1.0 / (((x * x) + ((y * 4.0) * y)) / ((x * x) - ((y * 4.0) * y))));
		} else {
			double VAR_2;
			if (((x * x) <= 5.911725024282761e-212)) {
				VAR_2 = -1.0;
			} else {
				double VAR_3;
				if (((x * x) <= 1.871404255593542e-176)) {
					VAR_3 = (1.0 / (((x * x) + ((y * 4.0) * y)) / ((x * x) - ((y * 4.0) * y))));
				} else {
					double VAR_4;
					if (((x * x) <= 8.297352886333691e-53)) {
						VAR_4 = -1.0;
					} else {
						double VAR_5;
						if (((x * x) <= 2.905507182505685e+226)) {
							VAR_5 = (1.0 / (((x * x) + ((y * 4.0) * y)) / ((x * x) - ((y * 4.0) * y))));
						} else {
							double VAR_6;
							if (((x * x) <= 1.0347887184723732e+274)) {
								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.5
Target31.2
Herbie13.8
\[\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 x) < 5.17370770179536e-272 or 2.442814405354497e-230 < (* x x) < 5.911725024282761e-212 or 1.871404255593542e-176 < (* x x) < 8.297352886333691e-53 or 2.905507182505685e+226 < (* x x) < 1.0347887184723732e+274

    1. Initial program 24.7

      \[\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 16.5

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

    if 5.17370770179536e-272 < (* x x) < 2.442814405354497e-230 or 5.911725024282761e-212 < (* x x) < 1.871404255593542e-176 or 8.297352886333691e-53 < (* x x) < 2.905507182505685e+226

    1. Initial program 14.2

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

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

    if 1.0347887184723732e+274 < (* x x)

    1. Initial program 59.0

      \[\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 9.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 5.17370770179536029 \cdot 10^{-272}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 2.4428144053544969 \cdot 10^{-230}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \cdot x \le 5.91172502428276112 \cdot 10^{-212}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.8714042555935421 \cdot 10^{-176}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \cdot x \le 8.29735288633369066 \cdot 10^{-53}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 2.90550718250568474 \cdot 10^{226}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \cdot x \le 1.0347887184723732 \cdot 10^{274}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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