?

Average Error: 31.5 → 13.1
Time: 9.0s
Precision: binary64
Cost: 14024

?

\[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
\[\begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + t_0}\\ t_2 := \mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, -1\right)\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+113}:\\ \;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{-161}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, t_0\right)}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{+87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{+146}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]
(FPCore (x y)
 :precision binary64
 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0)))
        (t_1 (/ (+ (* x x) (* y (* y -4.0))) (+ (* x x) t_0)))
        (t_2 (fma (* (/ x y) (/ x y)) 0.5 -1.0)))
   (if (<= x -8.5e+113)
     (+ (* y (* (/ -4.0 x) (/ y x))) 1.0)
     (if (<= x -1.15e-161)
       (/ (fma y (* y -4.0) (* x x)) (fma x x t_0))
       (if (<= x 6.2e-38)
         t_2
         (if (<= x 1.75e+42)
           t_1
           (if (<= x 1.66e+87)
             t_2
             (if (<= x 2.15e+146)
               t_1
               (fma -8.0 (* (/ y x) (/ y x)) 1.0)))))))))
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 t_0 = y * (y * 4.0);
	double t_1 = ((x * x) + (y * (y * -4.0))) / ((x * x) + t_0);
	double t_2 = fma(((x / y) * (x / y)), 0.5, -1.0);
	double tmp;
	if (x <= -8.5e+113) {
		tmp = (y * ((-4.0 / x) * (y / x))) + 1.0;
	} else if (x <= -1.15e-161) {
		tmp = fma(y, (y * -4.0), (x * x)) / fma(x, x, t_0);
	} else if (x <= 6.2e-38) {
		tmp = t_2;
	} else if (x <= 1.75e+42) {
		tmp = t_1;
	} else if (x <= 1.66e+87) {
		tmp = t_2;
	} else if (x <= 2.15e+146) {
		tmp = t_1;
	} else {
		tmp = fma(-8.0, ((y / x) * (y / x)), 1.0);
	}
	return tmp;
}
function code(x, y)
	return Float64(Float64(Float64(x * x) - Float64(Float64(y * 4.0) * y)) / Float64(Float64(x * x) + Float64(Float64(y * 4.0) * y)))
end
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(Float64(x * x) + Float64(y * Float64(y * -4.0))) / Float64(Float64(x * x) + t_0))
	t_2 = fma(Float64(Float64(x / y) * Float64(x / y)), 0.5, -1.0)
	tmp = 0.0
	if (x <= -8.5e+113)
		tmp = Float64(Float64(y * Float64(Float64(-4.0 / x) * Float64(y / x))) + 1.0);
	elseif (x <= -1.15e-161)
		tmp = Float64(fma(y, Float64(y * -4.0), Float64(x * x)) / fma(x, x, t_0));
	elseif (x <= 6.2e-38)
		tmp = t_2;
	elseif (x <= 1.75e+42)
		tmp = t_1;
	elseif (x <= 1.66e+87)
		tmp = t_2;
	elseif (x <= 2.15e+146)
		tmp = t_1;
	else
		tmp = fma(-8.0, Float64(Float64(y / x) * Float64(y / x)), 1.0);
	end
	return tmp
end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * 0.5 + -1.0), $MachinePrecision]}, If[LessEqual[x, -8.5e+113], N[(N[(y * N[(N[(-4.0 / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, -1.15e-161], N[(N[(y * N[(y * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.2e-38], t$95$2, If[LessEqual[x, 1.75e+42], t$95$1, If[LessEqual[x, 1.66e+87], t$95$2, If[LessEqual[x, 2.15e+146], t$95$1, N[(-8.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]]]]]]]]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + t_0}\\
t_2 := \mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, -1\right)\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{+113}:\\
\;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\

\mathbf{elif}\;x \leq -1.15 \cdot 10^{-161}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, t_0\right)}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-38}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{+42}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.66 \cdot 10^{+87}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 2.15 \cdot 10^{+146}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\


\end{array}

Error?

Target

Original31.5
Target31.3
Herbie13.1
\[\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} < 0.9743233849626781:\\ \;\;\;\;\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 5 regimes
  2. if x < -8.5000000000000001e113

    1. Initial program 54.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 in x around inf 55.0

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    3. Simplified55.0

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

      [Start]55.0

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

      unpow2 [=>]55.0

      \[ \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    4. Taylor expanded in x around inf 16.6

      \[\leadsto \color{blue}{1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    5. Simplified16.6

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

      [Start]16.6

      \[ 1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}} \]

      associate-*r/ [=>]16.6

      \[ 1 + \color{blue}{\frac{-4 \cdot {y}^{2}}{{x}^{2}}} \]

      unpow2 [=>]16.6

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

      unpow2 [=>]16.6

      \[ 1 + \frac{-4 \cdot \left(y \cdot y\right)}{\color{blue}{x \cdot x}} \]
    6. Taylor expanded in y around 0 16.6

      \[\leadsto \color{blue}{1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    7. Simplified10.4

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

      [Start]16.6

      \[ 1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}} \]

      +-commutative [=>]16.6

      \[ \color{blue}{-4 \cdot \frac{{y}^{2}}{{x}^{2}} + 1} \]

      associate-*r/ [=>]16.6

      \[ \color{blue}{\frac{-4 \cdot {y}^{2}}{{x}^{2}}} + 1 \]

      unpow2 [=>]16.6

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

      associate-*r* [=>]16.6

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

      unpow2 [=>]16.6

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

      associate-*l/ [<=]10.8

      \[ \color{blue}{\frac{-4 \cdot y}{x \cdot x} \cdot y} + 1 \]

      *-commutative [=>]10.8

      \[ \color{blue}{y \cdot \frac{-4 \cdot y}{x \cdot x}} + 1 \]

      times-frac [=>]10.4

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

    if -8.5000000000000001e113 < x < -1.15e-161

    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} \]
    2. Simplified15.5

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      Proof

      [Start]15.5

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

      cancel-sign-sub-inv [=>]15.5

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

      +-commutative [=>]15.5

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

      *-commutative [=>]15.5

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

      fma-def [=>]15.5

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

      distribute-rgt-neg-in [=>]15.5

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

      metadata-eval [=>]15.5

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

      fma-def [=>]15.5

      \[ \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]

      *-commutative [=>]15.5

      \[ \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]

    if -1.15e-161 < x < 6.19999999999999966e-38 or 1.75000000000000012e42 < x < 1.65999999999999994e87

    1. Initial program 26.6

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      Proof

      [Start]26.6

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

      cancel-sign-sub-inv [=>]26.6

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

      +-commutative [=>]26.6

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

      *-commutative [=>]26.6

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

      fma-def [=>]26.6

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

      distribute-rgt-neg-in [=>]26.6

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

      metadata-eval [=>]26.6

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

      fma-def [=>]26.6

      \[ \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]

      *-commutative [=>]26.6

      \[ \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Taylor expanded in y around inf 19.2

      \[\leadsto \color{blue}{0.25 \cdot \frac{{x}^{2}}{{y}^{2}} - \left(-0.25 \cdot \frac{{x}^{2}}{{y}^{2}} + 1\right)} \]
    4. Simplified13.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, -1\right)} \]
      Proof

      [Start]19.2

      \[ 0.25 \cdot \frac{{x}^{2}}{{y}^{2}} - \left(-0.25 \cdot \frac{{x}^{2}}{{y}^{2}} + 1\right) \]

      associate--r+ [=>]19.2

      \[ \color{blue}{\left(0.25 \cdot \frac{{x}^{2}}{{y}^{2}} - -0.25 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1} \]

      distribute-rgt-out-- [=>]19.2

      \[ \color{blue}{\frac{{x}^{2}}{{y}^{2}} \cdot \left(0.25 - -0.25\right)} - 1 \]

      metadata-eval [=>]19.2

      \[ \frac{{x}^{2}}{{y}^{2}} \cdot \color{blue}{0.5} - 1 \]

      fma-neg [=>]19.2

      \[ \color{blue}{\mathsf{fma}\left(\frac{{x}^{2}}{{y}^{2}}, 0.5, -1\right)} \]

      unpow2 [=>]19.2

      \[ \mathsf{fma}\left(\frac{\color{blue}{x \cdot x}}{{y}^{2}}, 0.5, -1\right) \]

      unpow2 [=>]19.2

      \[ \mathsf{fma}\left(\frac{x \cdot x}{\color{blue}{y \cdot y}}, 0.5, -1\right) \]

      times-frac [=>]13.9

      \[ \mathsf{fma}\left(\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}, 0.5, -1\right) \]

      metadata-eval [=>]13.9

      \[ \mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, \color{blue}{-1}\right) \]

    if 6.19999999999999966e-38 < x < 1.75000000000000012e42 or 1.65999999999999994e87 < x < 2.1499999999999999e146

    1. Initial program 14.3

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

    if 2.1499999999999999e146 < x

    1. Initial program 62.1

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      Proof

      [Start]62.1

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

      cancel-sign-sub-inv [=>]62.1

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

      +-commutative [=>]62.1

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

      *-commutative [=>]62.1

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

      fma-def [=>]62.1

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

      distribute-rgt-neg-in [=>]62.1

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

      metadata-eval [=>]62.1

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

      fma-def [=>]62.1

      \[ \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} \]

      *-commutative [=>]62.1

      \[ \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} \]
    3. Taylor expanded in y around 0 16.9

      \[\leadsto \color{blue}{-8 \cdot \frac{{y}^{2}}{{x}^{2}} + 1} \]
    4. Simplified8.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)} \]
      Proof

      [Start]16.9

      \[ -8 \cdot \frac{{y}^{2}}{{x}^{2}} + 1 \]

      fma-def [=>]16.9

      \[ \color{blue}{\mathsf{fma}\left(-8, \frac{{y}^{2}}{{x}^{2}}, 1\right)} \]

      unpow2 [=>]16.9

      \[ \mathsf{fma}\left(-8, \frac{\color{blue}{y \cdot y}}{{x}^{2}}, 1\right) \]

      unpow2 [=>]16.9

      \[ \mathsf{fma}\left(-8, \frac{y \cdot y}{\color{blue}{x \cdot x}}, 1\right) \]

      times-frac [=>]8.8

      \[ \mathsf{fma}\left(-8, \color{blue}{\frac{y}{x} \cdot \frac{y}{x}}, 1\right) \]
  3. Recombined 5 regimes into one program.
  4. Final simplification13.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+113}:\\ \;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{-161}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-38}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, -1\right)\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+42}:\\ \;\;\;\;\frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{+87}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, -1\right)\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{+146}:\\ \;\;\;\;\frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]

Alternatives

Alternative 1
Error13.3
Cost7768
\[\begin{array}{l} t_0 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+113}:\\ \;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-161}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-38}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+87}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{+147}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]
Alternative 2
Error13.1
Cost7768
\[\begin{array}{l} t_0 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ t_1 := \mathsf{fma}\left(\frac{x}{y} \cdot \frac{x}{y}, 0.5, -1\right)\\ \mathbf{if}\;x \leq -8.2 \cdot 10^{+113}:\\ \;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-162}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 10^{+87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+147}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]
Alternative 3
Error17.2
Cost2524
\[\begin{array}{l} t_0 := 1 + \frac{-4 \cdot \left(y \cdot y\right)}{x \cdot x}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-76}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+17}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{+30}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+129}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+147}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \cdot x \leq 10^{+177}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \end{array} \]
Alternative 4
Error17.2
Cost2524
\[\begin{array}{l} t_0 := \frac{x \cdot x}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-76}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+17}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 3 \cdot 10^{+27}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+129}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{+177}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \end{array} \]
Alternative 5
Error13.3
Cost2008
\[\begin{array}{l} t_0 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ t_1 := y \cdot \left(\frac{-4}{x} \cdot \frac{y}{x}\right) + 1\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-162}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-33}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{+87}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{+146}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error17.4
Cost1884
\[\begin{array}{l} t_0 := 1 + \frac{-4 \cdot \left(y \cdot y\right)}{x \cdot x}\\ \mathbf{if}\;x \cdot x \leq 4.2 \cdot 10^{-75}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2.8 \cdot 10^{+17}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 1.05 \cdot 10^{+32}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 1.4 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{+130}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 1.7 \cdot 10^{+151}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+178}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error16.6
Cost592
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-18}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-62}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-29}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 8
Error31.9
Cost64
\[-1 \]

Error

Reproduce?

herbie shell --seed 2023027 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

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

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