Average Error: 31.1 → 13.8
Time: 12.4s
Precision: binary64
Cost: 14800
\[\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 := -1 + \mathsf{log1p}\left(0.5 \cdot {\left(\frac{x}{y}\right)}^{2}\right)\\ t_1 := \mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-157}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{-66}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x, \left(y \cdot y\right) \cdot -4\right)}{t_1}\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{+268}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{t_1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\ \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 (+ -1.0 (log1p (* 0.5 (pow (/ x y) 2.0)))))
        (t_1 (fma x x (* y (* y 4.0)))))
   (if (<= (* x x) 5e-157)
     t_0
     (if (<= (* x x) 1e-66)
       (/ (fma x x (* (* y y) -4.0)) t_1)
       (if (<= (* x x) 4e+91)
         t_0
         (if (<= (* x x) 1e+268)
           (/ (fma y (* y -4.0) (* x x)) t_1)
           (+ (* (pow (/ y x) 2.0) -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 = -1.0 + log1p((0.5 * pow((x / y), 2.0)));
	double t_1 = fma(x, x, (y * (y * 4.0)));
	double tmp;
	if ((x * x) <= 5e-157) {
		tmp = t_0;
	} else if ((x * x) <= 1e-66) {
		tmp = fma(x, x, ((y * y) * -4.0)) / t_1;
	} else if ((x * x) <= 4e+91) {
		tmp = t_0;
	} else if ((x * x) <= 1e+268) {
		tmp = fma(y, (y * -4.0), (x * x)) / t_1;
	} else {
		tmp = (pow((y / x), 2.0) * -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(-1.0 + log1p(Float64(0.5 * (Float64(x / y) ^ 2.0))))
	t_1 = fma(x, x, Float64(y * Float64(y * 4.0)))
	tmp = 0.0
	if (Float64(x * x) <= 5e-157)
		tmp = t_0;
	elseif (Float64(x * x) <= 1e-66)
		tmp = Float64(fma(x, x, Float64(Float64(y * y) * -4.0)) / t_1);
	elseif (Float64(x * x) <= 4e+91)
		tmp = t_0;
	elseif (Float64(x * x) <= 1e+268)
		tmp = Float64(fma(y, Float64(y * -4.0), Float64(x * x)) / t_1);
	else
		tmp = Float64(Float64((Float64(y / x) ^ 2.0) * -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[(-1.0 + N[Log[1 + N[(0.5 * N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * x + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-157], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 1e-66], N[(N[(x * x + N[(N[(y * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 4e+91], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+268], N[(N[(y * N[(y * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $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 := -1 + \mathsf{log1p}\left(0.5 \cdot {\left(\frac{x}{y}\right)}^{2}\right)\\
t_1 := \mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-157}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot x \leq 10^{+268}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{t_1}\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\


\end{array}

Error

Target

Original31.1
Target30.8
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} < 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.0000000000000002e-157 or 9.9999999999999998e-67 < (*.f64 x x) < 4.00000000000000032e91

    1. Initial program 23.1

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Simplified23.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]23.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 [=>]23.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 [=>]23.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 [=>]23.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 [=>]23.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 [=>]23.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 [=>]23.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 [=>]23.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 [=>]23.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 inf 21.2

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

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

      [Start]21.2

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

      associate--r+ [=>]21.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-- [=>]21.2

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

      metadata-eval [=>]21.2

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

      fma-neg [=>]21.2

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

      unpow2 [=>]21.2

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

      unpow2 [=>]21.2

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

      times-frac [=>]17.1

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

      metadata-eval [=>]17.1

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

      \[\leadsto \color{blue}{\log \left(e^{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, 0.5, -1\right)}\right)} \]
    6. Taylor expanded in x around 0 20.7

      \[\leadsto \log \color{blue}{\left(0.5 \cdot \frac{e^{-1} \cdot {x}^{2}}{{y}^{2}} + e^{-1}\right)} \]
    7. Simplified16.0

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

      [Start]20.7

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

      fma-def [=>]20.7

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

      *-commutative [=>]20.7

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

      associate-/l* [=>]20.7

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

      associate-/r/ [=>]20.7

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

      unpow2 [=>]20.7

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

      unpow2 [=>]20.7

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

      times-frac [=>]16.0

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

      unpow2 [<=]16.0

      \[ \log \left(\mathsf{fma}\left(0.5, \color{blue}{{\left(\frac{x}{y}\right)}^{2}} \cdot e^{-1}, e^{-1}\right)\right) \]
    8. Applied egg-rr16.0

      \[\leadsto \color{blue}{\log \left(e^{-1} \cdot \left(1 + 0.5 \cdot {\left(\frac{x}{y}\right)}^{2}\right)\right) + 0} \]
    9. Simplified16.0

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

      [Start]16.0

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

      +-rgt-identity [=>]16.0

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

      +-commutative [=>]16.0

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

      log-prod [=>]16.0

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

      rem-log-exp [=>]16.0

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

      +-commutative [<=]16.0

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

      log1p-def [=>]16.0

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

    if 5.0000000000000002e-157 < (*.f64 x x) < 9.9999999999999998e-67

    1. Initial program 15.6

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

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

      [Start]15.6

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

      fma-neg [=>]15.6

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

      *-commutative [=>]15.6

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

      associate-*r* [=>]15.6

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

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

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

      metadata-eval [=>]15.6

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

      fma-def [=>]15.6

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

      *-commutative [=>]15.6

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

    if 4.00000000000000032e91 < (*.f64 x x) < 9.9999999999999997e267

    1. Initial program 15.3

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

      \[\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.3

      \[ \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.3

      \[ \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.3

      \[ \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.3

      \[ \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.3

      \[ \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.3

      \[ \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.3

      \[ \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.3

      \[ \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.3

      \[ \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 9.9999999999999997e267 < (*.f64 x x)

    1. Initial program 58.0

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

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

      [Start]58.0

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

      fma-neg [=>]58.0

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

      *-commutative [=>]58.0

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

      associate-*r* [=>]58.0

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

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

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

      metadata-eval [=>]58.0

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

      fma-def [=>]58.0

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

      *-commutative [=>]58.0

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

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

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

      [Start]15.9

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

      associate--l+ [=>]15.9

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

      +-commutative [=>]15.9

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

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

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

      metadata-eval [=>]15.9

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

      fma-def [=>]15.9

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

      unpow2 [=>]15.9

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

      unpow2 [=>]15.9

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

      times-frac [=>]8.4

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

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

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

Alternatives

Alternative 1
Error13.8
Cost14280
\[\begin{array}{l} t_0 := -1 + \mathsf{log1p}\left(0.5 \cdot {\left(\frac{x}{y}\right)}^{2}\right)\\ t_1 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-157}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{-66}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x, \left(y \cdot y\right) \cdot -4\right)}{\mathsf{fma}\left(x, x, t_1\right)}\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{+268}:\\ \;\;\;\;\frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + t_1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\ \end{array} \]
Alternative 2
Error13.8
Cost14092
\[\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 := -1 + \mathsf{log1p}\left(0.5 \cdot {\left(\frac{x}{y}\right)}^{2}\right)\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-157}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 10^{+268}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\ \end{array} \]
Alternative 3
Error14.6
Cost7952
\[\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 \cdot x \leq 5 \cdot 10^{-157}:\\ \;\;\;\;-1 + \frac{0.5 \cdot \frac{x}{\frac{y}{x}}}{y}\\ \mathbf{elif}\;x \cdot x \leq 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+100}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+268}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\ \end{array} \]
Alternative 4
Error14.6
Cost2256
\[\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 \cdot x \leq 5 \cdot 10^{-157}:\\ \;\;\;\;-1 + \frac{0.5 \cdot \frac{x}{\frac{y}{x}}}{y}\\ \mathbf{elif}\;x \cdot x \leq 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+100}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 10^{+268}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y}{x} \cdot \frac{y \cdot 4}{x}\\ \end{array} \]
Alternative 5
Error16.8
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{+58} \lor \neg \left(x \leq 2.2 \cdot 10^{+62}\right):\\ \;\;\;\;1 - \frac{y}{x} \cdot \frac{y \cdot 4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 6
Error16.5
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{+58} \lor \neg \left(x \leq 1.55 \cdot 10^{+62}\right):\\ \;\;\;\;1 - \frac{y}{x} \cdot \frac{y \cdot 4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{\left(x \cdot \frac{x}{y}\right) \cdot 0.25}{y}\\ \end{array} \]
Alternative 7
Error16.4
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -1.42 \cdot 10^{+57} \lor \neg \left(x \leq 3.6 \cdot 10^{+61}\right):\\ \;\;\;\;1 - \frac{y}{x} \cdot \frac{y \cdot 4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{0.5 \cdot \frac{x}{\frac{y}{x}}}{y}\\ \end{array} \]
Alternative 8
Error18.5
Cost856
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+147}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -2 \cdot 10^{+123}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-65}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-102}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -7.6 \cdot 10^{-152}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+48}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 9
Error32.1
Cost64
\[-1 \]

Error

Reproduce

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