Average Error: 31.1 → 13.7
Time: 2.5s
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}\;y \le -3.31141329817743227 \cdot 10^{130}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -6.9699508439260106 \cdot 10^{-99}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;y \le 3.4426870033043312 \cdot 10^{-70}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 1.5581991650942762 \cdot 10^{-21}:\\ \;\;\;\;\left(\sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;y \le 33120927224723735000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 1.10885773604264107 \cdot 10^{54}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;y \le 1.36256779205199092 \cdot 10^{79}:\\ \;\;\;\;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}\;y \le -3.31141329817743227 \cdot 10^{130}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;y \le 3.4426870033043312 \cdot 10^{-70}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \le 1.5581991650942762 \cdot 10^{-21}:\\
\;\;\;\;\left(\sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\

\mathbf{elif}\;y \le 33120927224723735000:\\
\;\;\;\;1\\

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

\mathbf{elif}\;y \le 1.36256779205199092 \cdot 10^{79}:\\
\;\;\;\;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 ((y <= -3.3114132981774323e+130)) {
		VAR = -1.0;
	} else {
		double VAR_1;
		if ((y <= -6.969950843926011e-99)) {
			VAR_1 = (((x * x) / ((x * x) + ((y * 4.0) * y))) - (((y * 4.0) * y) / ((x * x) + ((y * 4.0) * y))));
		} else {
			double VAR_2;
			if ((y <= 3.442687003304331e-70)) {
				VAR_2 = 1.0;
			} else {
				double VAR_3;
				if ((y <= 1.5581991650942762e-21)) {
					VAR_3 = ((cbrt((((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)))) * cbrt((((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y))))) * cbrt((((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)))));
				} else {
					double VAR_4;
					if ((y <= 3.3120927224723735e+19)) {
						VAR_4 = 1.0;
					} else {
						double VAR_5;
						if ((y <= 1.108857736042641e+54)) {
							VAR_5 = (((x * x) / ((x * x) + ((y * 4.0) * y))) - (((y * 4.0) * y) / ((x * x) + ((y * 4.0) * y))));
						} else {
							double VAR_6;
							if ((y <= 1.362567792051991e+79)) {
								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.1
Target30.8
Herbie13.7
\[\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 4 regimes
  2. if y < -3.3114132981774323e+130 or 1.362567792051991e+79 < y

    1. Initial program 52.3

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

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

    if -3.3114132981774323e+130 < y < -6.969950843926011e-99 or 3.3120927224723735e+19 < y < 1.108857736042641e+54

    1. Initial program 14.7

      \[\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 div-sub14.7

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

    if -6.969950843926011e-99 < y < 3.442687003304331e-70 or 1.5581991650942762e-21 < y < 3.3120927224723735e+19 or 1.108857736042641e+54 < y < 1.362567792051991e+79

    1. Initial program 24.3

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

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

    if 3.442687003304331e-70 < y < 1.5581991650942762e-21

    1. Initial program 17.0

      \[\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 add-cube-cbrt17.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification13.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.31141329817743227 \cdot 10^{130}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -6.9699508439260106 \cdot 10^{-99}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;y \le 3.4426870033043312 \cdot 10^{-70}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 1.5581991650942762 \cdot 10^{-21}:\\ \;\;\;\;\left(\sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;y \le 33120927224723735000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 1.10885773604264107 \cdot 10^{54}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;y \le 1.36256779205199092 \cdot 10^{79}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

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