Average Error: 31.3 → 5.6
Time: 5.8s
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.40649112388281499 \cdot 10^{151}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le 2.28590995318824201 \cdot 10^{150}:\\ \;\;\;\;\frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \left|\sqrt[3]{y \cdot 4}\right| \cdot \sqrt{\sqrt[3]{y \cdot 4} \cdot y}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\\ \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.40649112388281499 \cdot 10^{151}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \le 2.28590995318824201 \cdot 10^{150}:\\
\;\;\;\;\frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \left|\sqrt[3]{y \cdot 4}\right| \cdot \sqrt{\sqrt[3]{y \cdot 4} \cdot y}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\\

\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 ((y <= -3.406491123882815e+151)) {
		VAR = -1.0;
	} else {
		double VAR_1;
		if ((y <= 2.285909953188242e+150)) {
			VAR_1 = ((double) (((double) (((double) (((double) (((double) sqrt(((double) (((double) (y * 4.0)) * y)))) + x)) / ((double) pow(((double) cbrt(((double) hypot(x, ((double) sqrt(((double) (((double) (y * 4.0)) * y)))))))), 3.0)))) / ((double) cbrt(((double) hypot(x, ((double) (((double) fabs(((double) cbrt(((double) (y * 4.0)))))) * ((double) sqrt(((double) (((double) cbrt(((double) (y * 4.0)))) * y)))))))))))) * ((double) (((double) (x - ((double) sqrt(((double) (((double) (y * 4.0)) * y)))))) / ((double) (((double) cbrt(((double) hypot(x, ((double) sqrt(((double) (((double) (y * 4.0)) * y)))))))) * ((double) cbrt(((double) hypot(x, ((double) sqrt(((double) (((double) (y * 4.0)) * y))))))))))))));
		} else {
			VAR_1 = -1.0;
		}
		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.3
Target31.1
Herbie5.6
\[\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 2 regimes
  2. if y < -3.406491123882815e+151 or 2.285909953188242e+150 < y

    1. Initial program 63.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 8.4

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

    if -3.406491123882815e+151 < y < 2.285909953188242e+150

    1. Initial program 20.5

      \[\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-sqr-sqrt20.5

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

      \[\leadsto \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    5. Simplified20.5

      \[\leadsto \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right) \cdot \color{blue}{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt21.4

      \[\leadsto \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}}\]
    8. Applied add-cube-cbrt21.8

      \[\leadsto \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)} \cdot \left(\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}\]
    9. Applied swap-sqr21.8

      \[\leadsto \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}}\]
    10. Applied add-sqr-sqrt21.8

      \[\leadsto \frac{x \cdot x - \color{blue}{\sqrt{\left(y \cdot 4\right) \cdot y} \cdot \sqrt{\left(y \cdot 4\right) \cdot y}}}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}\]
    11. Applied difference-of-squares21.8

      \[\leadsto \frac{\color{blue}{\left(x + \sqrt{\left(y \cdot 4\right) \cdot y}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}\]
    12. Applied times-frac11.8

      \[\leadsto \color{blue}{\frac{x + \sqrt{\left(y \cdot 4\right) \cdot y}}{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right) \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}}\]
    13. Simplified4.5

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\]
    14. Using strategy rm
    15. Applied add-cube-cbrt4.5

      \[\leadsto \frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\color{blue}{\left(\left(\sqrt[3]{y \cdot 4} \cdot \sqrt[3]{y \cdot 4}\right) \cdot \sqrt[3]{y \cdot 4}\right)} \cdot y}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\]
    16. Applied associate-*l*4.5

      \[\leadsto \frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\color{blue}{\left(\sqrt[3]{y \cdot 4} \cdot \sqrt[3]{y \cdot 4}\right) \cdot \left(\sqrt[3]{y \cdot 4} \cdot y\right)}}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\]
    17. Applied sqrt-prod4.6

      \[\leadsto \frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \color{blue}{\sqrt{\sqrt[3]{y \cdot 4} \cdot \sqrt[3]{y \cdot 4}} \cdot \sqrt{\sqrt[3]{y \cdot 4} \cdot y}}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\]
    18. Simplified4.6

      \[\leadsto \frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \color{blue}{\left|\sqrt[3]{y \cdot 4}\right|} \cdot \sqrt{\sqrt[3]{y \cdot 4} \cdot y}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.40649112388281499 \cdot 10^{151}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le 2.28590995318824201 \cdot 10^{150}:\\ \;\;\;\;\frac{\frac{\sqrt{\left(y \cdot 4\right) \cdot y} + x}{{\left(\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}\right)}^{3}}}{\sqrt[3]{\mathsf{hypot}\left(x, \left|\sqrt[3]{y \cdot 4}\right| \cdot \sqrt{\sqrt[3]{y \cdot 4} \cdot y}\right)}} \cdot \frac{x - \sqrt{\left(y \cdot 4\right) \cdot y}}{\sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +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))))