?

Average Accuracy: 50.0% → 79.8%
Time: 10.0s
Precision: binary64
Cost: 8016

?

\[\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 - t_0}{x \cdot x + t_0}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-307}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{\frac{x}{y}}{\frac{y}{x}}, -0.5, -1\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 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) t_0) (+ (* x x) t_0))))
   (if (<= (* x x) 5e-307)
     (fma 0.5 (* (/ x y) (/ x y)) -1.0)
     (if (<= (* x x) 5e-217)
       t_1
       (if (<= (* x x) 2e-161)
         (/ 1.0 (fma (/ (/ x y) (/ y x)) -0.5 -1.0))
         (if (<= (* x x) 1e+162) t_1 (fma (* (/ y x) (/ y x)) -8.0 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) - t_0) / ((x * x) + t_0);
	double tmp;
	if ((x * x) <= 5e-307) {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	} else if ((x * x) <= 5e-217) {
		tmp = t_1;
	} else if ((x * x) <= 2e-161) {
		tmp = 1.0 / fma(((x / y) / (y / x)), -0.5, -1.0);
	} else if ((x * x) <= 1e+162) {
		tmp = t_1;
	} else {
		tmp = fma(((y / x) * (y / x)), -8.0, 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) - t_0) / Float64(Float64(x * x) + t_0))
	tmp = 0.0
	if (Float64(x * x) <= 5e-307)
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	elseif (Float64(x * x) <= 5e-217)
		tmp = t_1;
	elseif (Float64(x * x) <= 2e-161)
		tmp = Float64(1.0 / fma(Float64(Float64(x / y) / Float64(y / x)), -0.5, -1.0));
	elseif (Float64(x * x) <= 1e+162)
		tmp = t_1;
	else
		tmp = fma(Float64(Float64(y / x) * Float64(y / x)), -8.0, 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] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-307], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e-217], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 2e-161], N[(1.0 / N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] * -0.5 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+162], t$95$1, N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0 + 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 - t_0}{x \cdot x + t_0}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-307}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-217}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-161}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{\frac{x}{y}}{\frac{y}{x}}, -0.5, -1\right)}\\

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

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


\end{array}

Error?

Target

Original50.0%
Target50.4%
Herbie79.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} < 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 4 regimes
  2. if (*.f64 x x) < 5.00000000000000014e-307

    1. Initial program 51.6%

      \[\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 0 76.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    3. Simplified88.2%

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

      [Start]76.7

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

      fma-neg [=>]76.7

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

      unpow2 [=>]76.7

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

      unpow2 [=>]76.7

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

      times-frac [=>]88.2

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

      metadata-eval [=>]88.2

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

    if 5.00000000000000014e-307 < (*.f64 x x) < 5.0000000000000002e-217 or 2.00000000000000006e-161 < (*.f64 x x) < 9.9999999999999994e161

    1. Initial program 74.4%

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

    if 5.0000000000000002e-217 < (*.f64 x x) < 2.00000000000000006e-161

    1. Initial program 75.2%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Applied egg-rr75.2%

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

      [Start]75.2

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

      clear-num [=>]75.2

      \[ \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}}} \]

      inv-pow [=>]75.2

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

      fma-def [=>]75.2

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

      *-commutative [=>]75.2

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

      sub-neg [=>]75.2

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

      +-commutative [=>]75.2

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

      *-commutative [=>]75.2

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

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

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

      fma-def [=>]75.2

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

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

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

      metadata-eval [=>]75.2

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

      \[\leadsto {\color{blue}{\left(-0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1\right)}}^{-1} \]
    4. Simplified65.4%

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

      [Start]65.5

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

      fma-neg [=>]65.5

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

      unpow2 [=>]65.5

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

      unpow2 [=>]65.5

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

      times-frac [=>]65.4

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

      metadata-eval [=>]65.4

      \[ {\left(\mathsf{fma}\left(-0.5, \frac{x}{y} \cdot \frac{x}{y}, \color{blue}{-1}\right)\right)}^{-1} \]
    5. Applied egg-rr65.4%

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

      [Start]65.4

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

      add-log-exp [=>]65.6

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

      *-un-lft-identity [=>]65.6

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

      log-prod [=>]65.6

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

      metadata-eval [=>]65.6

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

      add-log-exp [<=]65.4

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

      unpow-1 [=>]65.4

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

      pow2 [=>]65.4

      \[ 0 + \frac{1}{\mathsf{fma}\left(-0.5, \color{blue}{{\left(\frac{x}{y}\right)}^{2}}, -1\right)} \]
    6. Simplified65.4%

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

      [Start]65.4

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

      +-lft-identity [=>]65.4

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

      fma-udef [=>]65.4

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

      unpow2 [=>]65.4

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

      times-frac [<=]65.5

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

      unpow2 [<=]65.5

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

      unpow2 [<=]65.5

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

      *-commutative [=>]65.5

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

      fma-def [=>]65.5

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

      unpow2 [=>]65.5

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

      unpow2 [=>]65.5

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

      times-frac [=>]65.4

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

      unpow2 [<=]65.4

      \[ \frac{1}{\mathsf{fma}\left(\color{blue}{{\left(\frac{x}{y}\right)}^{2}}, -0.5, -1\right)} \]
    7. Applied egg-rr65.4%

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

      [Start]65.4

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

      unpow2 [=>]65.4

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

      clear-num [=>]65.4

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

      un-div-inv [=>]65.4

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

    if 9.9999999999999994e161 < (*.f64 x x)

    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 in x around inf 72.2%

      \[\leadsto \color{blue}{\left(1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}\right) - 4 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    3. Simplified80.7%

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

      [Start]72.2

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

      associate--l+ [=>]72.2

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

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

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

      metadata-eval [=>]72.2

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

      *-commutative [<=]72.2

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

      +-commutative [<=]72.2

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

      *-commutative [=>]72.2

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

      fma-def [=>]72.2

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

      unpow2 [=>]72.2

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

      unpow2 [=>]72.2

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

      times-frac [=>]80.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-307}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-217}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{\frac{x}{y}}{\frac{y}{x}}, -0.5, -1\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+162}:\\ \;\;\;\;\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(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy79.8%
Cost8016
\[\begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-307}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\ \end{array} \]
Alternative 2
Accuracy79.6%
Cost7236
\[\begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-307}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{y}{\frac{x}{y}} \cdot \frac{-4}{x}\\ \end{array} \]
Alternative 3
Accuracy79.4%
Cost2256
\[\begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\ t_2 := \frac{y}{\frac{x}{y}}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-307}:\\ \;\;\;\;-1 + \frac{x}{4 \cdot t_2}\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1 + t_2 \cdot \frac{-4}{x}\\ \end{array} \]
Alternative 4
Accuracy74.4%
Cost1484
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-145}:\\ \;\;\;\;1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\ \mathbf{elif}\;x \cdot x \leq 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{y}{\frac{x}{y}} \cdot \frac{-4}{x}\\ \end{array} \]
Alternative 5
Accuracy74.7%
Cost1484
\[\begin{array}{l} t_0 := \frac{y}{\frac{x}{y}}\\ t_1 := -1 + \frac{x}{4 \cdot t_0}\\ \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-161}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-145}:\\ \;\;\;\;1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\ \mathbf{elif}\;x \cdot x \leq 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1 + t_0 \cdot \frac{-4}{x}\\ \end{array} \]
Alternative 6
Accuracy74.2%
Cost1224
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 5.8 \cdot 10^{-158}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 1.8 \cdot 10^{-145}:\\ \;\;\;\;1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+20}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Accuracy74.1%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{+36}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8200000000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Accuracy50.6%
Cost64
\[-1 \]

Error

Reproduce?

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