?

Average Accuracy: 51.0% → 93.5%
Time: 11.7s
Precision: binary64
Cost: 8656

?

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

\mathbf{elif}\;y \leq -1.85 \cdot 10^{-141}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 6.6 \cdot 10^{+153}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Target

Original51.0%
Target51.4%
Herbie93.5%
\[\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 y < -6.9999999999999998e153

    1. Initial program 0.0%

      \[\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 0.0%

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

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

      [Start]0.0

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

      *-commutative [=>]0.0

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

      unpow2 [=>]0.0

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

      associate-*r* [<=]0.0

      \[ \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{y \cdot \left(y \cdot 4\right)}} \]
    4. Applied egg-rr88.0%

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

      [Start]0.0

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

      *-commutative [<=]0.0

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

      div-sub [=>]0.0

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

      *-commutative [=>]0.0

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

      times-frac [=>]0.0

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

      *-inverses [=>]88.0

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

    if -6.9999999999999998e153 < y < -1.85e-141 or 4.00000000000000027e-189 < y < 6.59999999999999989e153

    1. Initial program 74.1%

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

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

      [Start]74.1

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

      div-sub [=>]74.1

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

      sub-neg [=>]74.1

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

      fma-def [=>]74.1

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

      *-commutative [=>]74.1

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

      associate-/l* [=>]73.9

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

      associate-/r/ [=>]73.7

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

      fma-def [=>]73.7

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

      *-commutative [=>]73.7

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

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

      [Start]73.7

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

      sub-neg [<=]73.7

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

      associate-/l* [=>]74.5

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

      associate-*l/ [=>]74.8

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

      *-commutative [<=]74.8

      \[ \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    4. Applied egg-rr74.6%

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

      [Start]74.8

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

      div-inv [=>]74.7

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

      *-commutative [=>]74.7

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

      fma-udef [=>]74.7

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

      distribute-lft-in [=>]74.6

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

      associate-*r* [=>]74.6

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

      *-commutative [=>]74.6

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

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

    if -1.85e-141 < y < 4.00000000000000027e-189

    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. Simplified54.3%

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

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

      fma-neg [=>]54.5

      \[ \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 [=>]54.5

      \[ \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* [=>]54.3

      \[ \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 [=>]54.3

      \[ \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 [=>]54.3

      \[ \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 [=>]54.3

      \[ \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 [=>]54.3

      \[ \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 75.7%

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

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

      [Start]75.7

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

      associate--l+ [=>]75.7

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

      +-commutative [=>]75.7

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

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

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

      metadata-eval [=>]75.7

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

      fma-def [=>]75.7

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

      unpow2 [=>]75.7

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

      unpow2 [=>]75.7

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

      times-frac [=>]88.4

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

    if 6.59999999999999989e153 < y

    1. Initial program 0.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Simplified0.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]0.0

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

      fma-neg [=>]0.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 [=>]0.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* [=>]0.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 [=>]0.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 [=>]0.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 [=>]0.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 [=>]0.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 0 73.5%

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

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

      [Start]73.5

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

      fma-neg [=>]73.5

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

      unpow2 [=>]73.5

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

      unpow2 [=>]73.5

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

      times-frac [=>]86.3

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

      metadata-eval [=>]86.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+153}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y \cdot 4} + -1\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{-141}:\\ \;\;\;\;\frac{x}{x + \frac{1}{x} \cdot \left(4 \cdot \left(y \cdot y\right)\right)} + \frac{y \cdot \left(y \cdot -4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-189}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+153}:\\ \;\;\;\;\frac{x}{x + \frac{1}{x} \cdot \left(4 \cdot \left(y \cdot y\right)\right)} + \frac{y \cdot \left(y \cdot -4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy78.9%
Cost7372
\[\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 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{if}\;x \leq -8 \cdot 10^{+149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-155}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-186}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y \cdot 4} + -1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy79.0%
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 := 1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ t_2 := \frac{x}{y} \cdot \frac{x}{y \cdot 4} + -1\\ \mathbf{if}\;x \leq -1.05 \cdot 10^{+150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.22 \cdot 10^{-154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-186}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy73.5%
Cost1232
\[\begin{array}{l} t_0 := 1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-186}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-39}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy73.7%
Cost1232
\[\begin{array}{l} t_0 := \frac{x}{y} \cdot \frac{x}{y \cdot 4} + -1\\ t_1 := 1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-186}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-40}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy73.6%
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+40}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-186}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-47}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Accuracy50.2%
Cost64
\[-1 \]

Error

Reproduce?

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