Given's Rotation SVD example, simplified

Percentage Accurate: 76.6% → 99.4%
Time: 8.3s
Alternatives: 9
Speedup: 6.7×

Specification

?
\[\begin{array}{l} \\ 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
double code(double x) {
	return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
public static double code(double x) {
	return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
def code(x):
	return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
function code(x)
	return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x))))))
end
function tmp = code(x)
	tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 76.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
double code(double x) {
	return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
public static double code(double x) {
	return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
def code(x):
	return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
function code(x)
	return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x))))))
end
function tmp = code(x)
	tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\end{array}

Alternative 1: 99.4% accurate, 0.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{0.5}{x\_m} + 0.5\\ t_1 := \sqrt{t\_0}\\ t_2 := t\_1 + 1\\ t_3 := \mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\\ t_4 := {t\_3}^{2} \cdot \sqrt{2}\\ t_5 := \frac{\sqrt{0.5}}{t\_4}\\ t_6 := \frac{0.1875}{t\_3}\\ \mathbf{if}\;x\_m \leq 1.2:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{0.15625}{t\_3} - \mathsf{fma}\left(\frac{0.25}{\sqrt{2}}, \frac{\mathsf{fma}\left(t\_5, -0.0625, t\_6\right) \cdot \sqrt{0.5}}{t\_3}, \frac{0.125 \cdot \left(0.34375 \cdot \sqrt{0.5}\right)}{t\_4}\right), x\_m \cdot x\_m, 0.0625 \cdot t\_5\right) - t\_6, x\_m \cdot x\_m, \frac{0.25}{t\_3}\right) \cdot \left(x\_m \cdot x\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_2 - \mathsf{fma}\left(t\_1, t\_0, t\_0\right)}{t\_2 \cdot t\_2}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m)
 :precision binary64
 (let* ((t_0 (+ (/ 0.5 x_m) 0.5))
        (t_1 (sqrt t_0))
        (t_2 (+ t_1 1.0))
        (t_3 (fma (sqrt 2.0) (sqrt 0.5) 1.0))
        (t_4 (* (pow t_3 2.0) (sqrt 2.0)))
        (t_5 (/ (sqrt 0.5) t_4))
        (t_6 (/ 0.1875 t_3)))
   (if (<= x_m 1.2)
     (*
      (fma
       (-
        (fma
         (-
          (/ 0.15625 t_3)
          (fma
           (/ 0.25 (sqrt 2.0))
           (/ (* (fma t_5 -0.0625 t_6) (sqrt 0.5)) t_3)
           (/ (* 0.125 (* 0.34375 (sqrt 0.5))) t_4)))
         (* x_m x_m)
         (* 0.0625 t_5))
        t_6)
       (* x_m x_m)
       (/ 0.25 t_3))
      (* x_m x_m))
     (/ (- t_2 (fma t_1 t_0 t_0)) (* t_2 t_2)))))
x_m = fabs(x);
double code(double x_m) {
	double t_0 = (0.5 / x_m) + 0.5;
	double t_1 = sqrt(t_0);
	double t_2 = t_1 + 1.0;
	double t_3 = fma(sqrt(2.0), sqrt(0.5), 1.0);
	double t_4 = pow(t_3, 2.0) * sqrt(2.0);
	double t_5 = sqrt(0.5) / t_4;
	double t_6 = 0.1875 / t_3;
	double tmp;
	if (x_m <= 1.2) {
		tmp = fma((fma(((0.15625 / t_3) - fma((0.25 / sqrt(2.0)), ((fma(t_5, -0.0625, t_6) * sqrt(0.5)) / t_3), ((0.125 * (0.34375 * sqrt(0.5))) / t_4))), (x_m * x_m), (0.0625 * t_5)) - t_6), (x_m * x_m), (0.25 / t_3)) * (x_m * x_m);
	} else {
		tmp = (t_2 - fma(t_1, t_0, t_0)) / (t_2 * t_2);
	}
	return tmp;
}
x_m = abs(x)
function code(x_m)
	t_0 = Float64(Float64(0.5 / x_m) + 0.5)
	t_1 = sqrt(t_0)
	t_2 = Float64(t_1 + 1.0)
	t_3 = fma(sqrt(2.0), sqrt(0.5), 1.0)
	t_4 = Float64((t_3 ^ 2.0) * sqrt(2.0))
	t_5 = Float64(sqrt(0.5) / t_4)
	t_6 = Float64(0.1875 / t_3)
	tmp = 0.0
	if (x_m <= 1.2)
		tmp = Float64(fma(Float64(fma(Float64(Float64(0.15625 / t_3) - fma(Float64(0.25 / sqrt(2.0)), Float64(Float64(fma(t_5, -0.0625, t_6) * sqrt(0.5)) / t_3), Float64(Float64(0.125 * Float64(0.34375 * sqrt(0.5))) / t_4))), Float64(x_m * x_m), Float64(0.0625 * t_5)) - t_6), Float64(x_m * x_m), Float64(0.25 / t_3)) * Float64(x_m * x_m));
	else
		tmp = Float64(Float64(t_2 - fma(t_1, t_0, t_0)) / Float64(t_2 * t_2));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_] := Block[{t$95$0 = N[(N[(0.5 / x$95$m), $MachinePrecision] + 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[t$95$3, 2.0], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Sqrt[0.5], $MachinePrecision] / t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[(0.1875 / t$95$3), $MachinePrecision]}, If[LessEqual[x$95$m, 1.2], N[(N[(N[(N[(N[(N[(0.15625 / t$95$3), $MachinePrecision] - N[(N[(0.25 / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(t$95$5 * -0.0625 + t$95$6), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision] + N[(N[(0.125 * N[(0.34375 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision] + N[(0.0625 * t$95$5), $MachinePrecision]), $MachinePrecision] - t$95$6), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision] + N[(0.25 / t$95$3), $MachinePrecision]), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 - N[(t$95$1 * t$95$0 + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := \frac{0.5}{x\_m} + 0.5\\
t_1 := \sqrt{t\_0}\\
t_2 := t\_1 + 1\\
t_3 := \mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\\
t_4 := {t\_3}^{2} \cdot \sqrt{2}\\
t_5 := \frac{\sqrt{0.5}}{t\_4}\\
t_6 := \frac{0.1875}{t\_3}\\
\mathbf{if}\;x\_m \leq 1.2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{0.15625}{t\_3} - \mathsf{fma}\left(\frac{0.25}{\sqrt{2}}, \frac{\mathsf{fma}\left(t\_5, -0.0625, t\_6\right) \cdot \sqrt{0.5}}{t\_3}, \frac{0.125 \cdot \left(0.34375 \cdot \sqrt{0.5}\right)}{t\_4}\right), x\_m \cdot x\_m, 0.0625 \cdot t\_5\right) - t\_6, x\_m \cdot x\_m, \frac{0.25}{t\_3}\right) \cdot \left(x\_m \cdot x\_m\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_2 - \mathsf{fma}\left(t\_1, t\_0, t\_0\right)}{t\_2 \cdot t\_2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.19999999999999996

    1. Initial program 63.5%

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
    4. Step-by-step derivation
      1. Applied rewrites32.3%

        \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
      2. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
        2. flip--N/A

          \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
        3. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
      3. Applied rewrites32.7%

        \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
      4. Taylor expanded in x around 0

        \[\leadsto \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{5}{32} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} - \left(\frac{1}{8} \cdot \frac{\sqrt{\frac{1}{2}} \cdot \left(\frac{3}{8} - \frac{1}{16} \cdot \frac{1}{{\left(\sqrt{2}\right)}^{2}}\right)}{\sqrt{2} \cdot {\left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}^{2}} + \frac{1}{4} \cdot \frac{\sqrt{\frac{1}{2}} \cdot \left(\frac{-1}{16} \cdot \frac{\sqrt{\frac{1}{2}}}{\sqrt{2} \cdot {\left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}^{2}} + \frac{3}{16} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)}{\sqrt{2} \cdot \left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}\right)\right) - \left(\frac{-1}{16} \cdot \frac{\sqrt{\frac{1}{2}}}{\sqrt{2} \cdot {\left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}^{2}} + \frac{3}{16} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)\right) + \frac{1}{4} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)} \]
      5. Applied rewrites71.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{0.15625}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)} - \mathsf{fma}\left(\frac{0.25}{\sqrt{2}}, \frac{\mathsf{fma}\left(\frac{\sqrt{0.5}}{{\left(\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\right)}^{2} \cdot \sqrt{2}}, -0.0625, \frac{0.1875}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}\right) \cdot \sqrt{0.5}}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}, \frac{0.125 \cdot \left(0.34375 \cdot \sqrt{0.5}\right)}{{\left(\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\right)}^{2} \cdot \sqrt{2}}\right), x \cdot x, 0.0625 \cdot \frac{\sqrt{0.5}}{{\left(\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\right)}^{2} \cdot \sqrt{2}}\right) - \frac{0.1875}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}, x \cdot x, \frac{0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}\right) \cdot \left(x \cdot x\right)} \]

      if 1.19999999999999996 < x

      1. Initial program 98.5%

        \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}}} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
        2. lower-+.f64N/A

          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
        3. associate-*r/N/A

          \[\leadsto 1 - \sqrt{\color{blue}{\frac{\frac{1}{2} \cdot 1}{x}} + \frac{1}{2}} \]
        4. metadata-evalN/A

          \[\leadsto 1 - \sqrt{\frac{\color{blue}{\frac{1}{2}}}{x} + \frac{1}{2}} \]
        5. lower-/.f6498.5

          \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x}} + 0.5} \]
      5. Applied rewrites98.5%

        \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x} + 0.5}} \]
      6. Applied rewrites100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)}} \]
      7. Step-by-step derivation
        1. Applied rewrites100.0%

          \[\leadsto \frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \color{blue}{\mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}, \frac{\frac{1}{2}}{x} + \frac{1}{2}, \frac{\frac{1}{2}}{x} + \frac{1}{2}\right)}{\left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right) \cdot \left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right)} \]
          2. *-lft-identity100.0

            \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
        3. Applied rewrites100.0%

          \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
      8. Recombined 2 regimes into one program.
      9. Add Preprocessing

      Alternative 2: 99.3% accurate, 0.5× speedup?

      \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{0.5}{x\_m} + 0.5\\ t_1 := \sqrt{t\_0}\\ t_2 := t\_1 + 1\\ t_3 := \mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\\ \mathbf{if}\;x\_m \leq 1.12:\\ \;\;\;\;\mathsf{fma}\left(\left(-x\_m\right) \cdot x\_m, \mathsf{fma}\left(\frac{\sqrt{0.5}}{{t\_3}^{2} \cdot \sqrt{2}}, -0.0625, \frac{0.1875}{t\_3}\right), \frac{0.25}{t\_3}\right) \cdot \left(x\_m \cdot x\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_2 - \mathsf{fma}\left(t\_1, t\_0, t\_0\right)}{t\_2 \cdot t\_2}\\ \end{array} \end{array} \]
      x_m = (fabs.f64 x)
      (FPCore (x_m)
       :precision binary64
       (let* ((t_0 (+ (/ 0.5 x_m) 0.5))
              (t_1 (sqrt t_0))
              (t_2 (+ t_1 1.0))
              (t_3 (fma (sqrt 2.0) (sqrt 0.5) 1.0)))
         (if (<= x_m 1.12)
           (*
            (fma
             (* (- x_m) x_m)
             (fma (/ (sqrt 0.5) (* (pow t_3 2.0) (sqrt 2.0))) -0.0625 (/ 0.1875 t_3))
             (/ 0.25 t_3))
            (* x_m x_m))
           (/ (- t_2 (fma t_1 t_0 t_0)) (* t_2 t_2)))))
      x_m = fabs(x);
      double code(double x_m) {
      	double t_0 = (0.5 / x_m) + 0.5;
      	double t_1 = sqrt(t_0);
      	double t_2 = t_1 + 1.0;
      	double t_3 = fma(sqrt(2.0), sqrt(0.5), 1.0);
      	double tmp;
      	if (x_m <= 1.12) {
      		tmp = fma((-x_m * x_m), fma((sqrt(0.5) / (pow(t_3, 2.0) * sqrt(2.0))), -0.0625, (0.1875 / t_3)), (0.25 / t_3)) * (x_m * x_m);
      	} else {
      		tmp = (t_2 - fma(t_1, t_0, t_0)) / (t_2 * t_2);
      	}
      	return tmp;
      }
      
      x_m = abs(x)
      function code(x_m)
      	t_0 = Float64(Float64(0.5 / x_m) + 0.5)
      	t_1 = sqrt(t_0)
      	t_2 = Float64(t_1 + 1.0)
      	t_3 = fma(sqrt(2.0), sqrt(0.5), 1.0)
      	tmp = 0.0
      	if (x_m <= 1.12)
      		tmp = Float64(fma(Float64(Float64(-x_m) * x_m), fma(Float64(sqrt(0.5) / Float64((t_3 ^ 2.0) * sqrt(2.0))), -0.0625, Float64(0.1875 / t_3)), Float64(0.25 / t_3)) * Float64(x_m * x_m));
      	else
      		tmp = Float64(Float64(t_2 - fma(t_1, t_0, t_0)) / Float64(t_2 * t_2));
      	end
      	return tmp
      end
      
      x_m = N[Abs[x], $MachinePrecision]
      code[x$95$m_] := Block[{t$95$0 = N[(N[(0.5 / x$95$m), $MachinePrecision] + 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x$95$m, 1.12], N[(N[(N[((-x$95$m) * x$95$m), $MachinePrecision] * N[(N[(N[Sqrt[0.5], $MachinePrecision] / N[(N[Power[t$95$3, 2.0], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.0625 + N[(0.1875 / t$95$3), $MachinePrecision]), $MachinePrecision] + N[(0.25 / t$95$3), $MachinePrecision]), $MachinePrecision] * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 - N[(t$95$1 * t$95$0 + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      x_m = \left|x\right|
      
      \\
      \begin{array}{l}
      t_0 := \frac{0.5}{x\_m} + 0.5\\
      t_1 := \sqrt{t\_0}\\
      t_2 := t\_1 + 1\\
      t_3 := \mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\\
      \mathbf{if}\;x\_m \leq 1.12:\\
      \;\;\;\;\mathsf{fma}\left(\left(-x\_m\right) \cdot x\_m, \mathsf{fma}\left(\frac{\sqrt{0.5}}{{t\_3}^{2} \cdot \sqrt{2}}, -0.0625, \frac{0.1875}{t\_3}\right), \frac{0.25}{t\_3}\right) \cdot \left(x\_m \cdot x\_m\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{t\_2 - \mathsf{fma}\left(t\_1, t\_0, t\_0\right)}{t\_2 \cdot t\_2}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 1.1200000000000001

        1. Initial program 63.5%

          \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
        2. Add Preprocessing
        3. Taylor expanded in x around inf

          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
        4. Step-by-step derivation
          1. Applied rewrites32.3%

            \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
          2. Step-by-step derivation
            1. lift--.f64N/A

              \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
            2. flip--N/A

              \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
            3. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
          3. Applied rewrites32.7%

            \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
          4. Taylor expanded in x around 0

            \[\leadsto \color{blue}{{x}^{2} \cdot \left(-1 \cdot \left({x}^{2} \cdot \left(\frac{-1}{16} \cdot \frac{\sqrt{\frac{1}{2}}}{\sqrt{2} \cdot {\left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}^{2}} + \frac{3}{16} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)\right) + \frac{1}{4} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)} \]
          5. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{\left(-1 \cdot \left({x}^{2} \cdot \left(\frac{-1}{16} \cdot \frac{\sqrt{\frac{1}{2}}}{\sqrt{2} \cdot {\left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}^{2}} + \frac{3}{16} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)\right) + \frac{1}{4} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right) \cdot {x}^{2}} \]
            2. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(-1 \cdot \left({x}^{2} \cdot \left(\frac{-1}{16} \cdot \frac{\sqrt{\frac{1}{2}}}{\sqrt{2} \cdot {\left(1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}^{2}} + \frac{3}{16} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right)\right) + \frac{1}{4} \cdot \frac{1}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}\right) \cdot {x}^{2}} \]
          6. Applied rewrites70.1%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(-x\right) \cdot x, \mathsf{fma}\left(\frac{\sqrt{0.5}}{{\left(\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)\right)}^{2} \cdot \sqrt{2}}, -0.0625, \frac{0.1875}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}\right), \frac{0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}\right) \cdot \left(x \cdot x\right)} \]

          if 1.1200000000000001 < x

          1. Initial program 98.5%

            \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
          2. Add Preprocessing
          3. Taylor expanded in x around inf

            \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}}} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
            2. lower-+.f64N/A

              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
            3. associate-*r/N/A

              \[\leadsto 1 - \sqrt{\color{blue}{\frac{\frac{1}{2} \cdot 1}{x}} + \frac{1}{2}} \]
            4. metadata-evalN/A

              \[\leadsto 1 - \sqrt{\frac{\color{blue}{\frac{1}{2}}}{x} + \frac{1}{2}} \]
            5. lower-/.f6498.5

              \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x}} + 0.5} \]
          5. Applied rewrites98.5%

            \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x} + 0.5}} \]
          6. Applied rewrites100.0%

            \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)}} \]
          7. Step-by-step derivation
            1. Applied rewrites100.0%

              \[\leadsto \frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \color{blue}{\mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
            2. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}, \frac{\frac{1}{2}}{x} + \frac{1}{2}, \frac{\frac{1}{2}}{x} + \frac{1}{2}\right)}{\left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right) \cdot \left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right)} \]
              2. *-lft-identity100.0

                \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
            3. Applied rewrites100.0%

              \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 3: 99.1% accurate, 0.8× speedup?

          \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{0.5}{x\_m} + 0.5\\ t_1 := \sqrt{t\_0}\\ t_2 := t\_1 + 1\\ \mathbf{if}\;x\_m \leq 1.25:\\ \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_2 - \mathsf{fma}\left(t\_1, t\_0, t\_0\right)}{t\_2 \cdot t\_2}\\ \end{array} \end{array} \]
          x_m = (fabs.f64 x)
          (FPCore (x_m)
           :precision binary64
           (let* ((t_0 (+ (/ 0.5 x_m) 0.5)) (t_1 (sqrt t_0)) (t_2 (+ t_1 1.0)))
             (if (<= x_m 1.25)
               (* (* x_m x_m) 0.125)
               (/ (- t_2 (fma t_1 t_0 t_0)) (* t_2 t_2)))))
          x_m = fabs(x);
          double code(double x_m) {
          	double t_0 = (0.5 / x_m) + 0.5;
          	double t_1 = sqrt(t_0);
          	double t_2 = t_1 + 1.0;
          	double tmp;
          	if (x_m <= 1.25) {
          		tmp = (x_m * x_m) * 0.125;
          	} else {
          		tmp = (t_2 - fma(t_1, t_0, t_0)) / (t_2 * t_2);
          	}
          	return tmp;
          }
          
          x_m = abs(x)
          function code(x_m)
          	t_0 = Float64(Float64(0.5 / x_m) + 0.5)
          	t_1 = sqrt(t_0)
          	t_2 = Float64(t_1 + 1.0)
          	tmp = 0.0
          	if (x_m <= 1.25)
          		tmp = Float64(Float64(x_m * x_m) * 0.125);
          	else
          		tmp = Float64(Float64(t_2 - fma(t_1, t_0, t_0)) / Float64(t_2 * t_2));
          	end
          	return tmp
          end
          
          x_m = N[Abs[x], $MachinePrecision]
          code[x$95$m_] := Block[{t$95$0 = N[(N[(0.5 / x$95$m), $MachinePrecision] + 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + 1.0), $MachinePrecision]}, If[LessEqual[x$95$m, 1.25], N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision], N[(N[(t$95$2 - N[(t$95$1 * t$95$0 + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
          
          \begin{array}{l}
          x_m = \left|x\right|
          
          \\
          \begin{array}{l}
          t_0 := \frac{0.5}{x\_m} + 0.5\\
          t_1 := \sqrt{t\_0}\\
          t_2 := t\_1 + 1\\
          \mathbf{if}\;x\_m \leq 1.25:\\
          \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{t\_2 - \mathsf{fma}\left(t\_1, t\_0, t\_0\right)}{t\_2 \cdot t\_2}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < 1.25

            1. Initial program 63.5%

              \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in x around inf

              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
            4. Step-by-step derivation
              1. Applied rewrites32.3%

                \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
              2. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                2. flip--N/A

                  \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                3. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
              3. Applied rewrites32.7%

                \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
              4. Taylor expanded in x around 0

                \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
              5. Step-by-step derivation
                1. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                2. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                3. *-commutativeN/A

                  \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                4. lower-*.f64N/A

                  \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                5. unpow2N/A

                  \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                6. lower-*.f64N/A

                  \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                7. +-commutativeN/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                8. *-commutativeN/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                9. lower-fma.f64N/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                10. rem-square-sqrtN/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                11. unpow2N/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                12. lower-sqrt.f64N/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                13. unpow2N/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                14. rem-square-sqrtN/A

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                15. lower-sqrt.f6470.9

                  \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
              6. Applied rewrites70.9%

                \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
              7. Step-by-step derivation
                1. Applied rewrites70.9%

                  \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]

                if 1.25 < x

                1. Initial program 98.5%

                  \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                2. Add Preprocessing
                3. Taylor expanded in x around inf

                  \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}}} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                  2. lower-+.f64N/A

                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                  3. associate-*r/N/A

                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{\frac{1}{2} \cdot 1}{x}} + \frac{1}{2}} \]
                  4. metadata-evalN/A

                    \[\leadsto 1 - \sqrt{\frac{\color{blue}{\frac{1}{2}}}{x} + \frac{1}{2}} \]
                  5. lower-/.f6498.5

                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x}} + 0.5} \]
                5. Applied rewrites98.5%

                  \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x} + 0.5}} \]
                6. Applied rewrites100.0%

                  \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)}} \]
                7. Step-by-step derivation
                  1. Applied rewrites100.0%

                    \[\leadsto \frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \color{blue}{\mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
                  2. Step-by-step derivation
                    1. lift-*.f64N/A

                      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}, \frac{\frac{1}{2}}{x} + \frac{1}{2}, \frac{\frac{1}{2}}{x} + \frac{1}{2}\right)}{\left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right) \cdot \left(\sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} + 1\right)} \]
                    2. *-lft-identity100.0

                      \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
                  3. Applied rewrites100.0%

                    \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} - \mathsf{fma}\left(\sqrt{\frac{0.5}{x} + 0.5}, \frac{0.5}{x} + 0.5, \frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
                8. Recombined 2 regimes into one program.
                9. Add Preprocessing

                Alternative 4: 99.1% accurate, 1.1× speedup?

                \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{0.5}{x\_m} + 0.5\\ t_1 := \sqrt{t\_0} + 1\\ \mathbf{if}\;x\_m \leq 1.25:\\ \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1 \cdot \left(1 - t\_0\right)}{t\_1 \cdot t\_1}\\ \end{array} \end{array} \]
                x_m = (fabs.f64 x)
                (FPCore (x_m)
                 :precision binary64
                 (let* ((t_0 (+ (/ 0.5 x_m) 0.5)) (t_1 (+ (sqrt t_0) 1.0)))
                   (if (<= x_m 1.25)
                     (* (* x_m x_m) 0.125)
                     (/ (* t_1 (- 1.0 t_0)) (* t_1 t_1)))))
                x_m = fabs(x);
                double code(double x_m) {
                	double t_0 = (0.5 / x_m) + 0.5;
                	double t_1 = sqrt(t_0) + 1.0;
                	double tmp;
                	if (x_m <= 1.25) {
                		tmp = (x_m * x_m) * 0.125;
                	} else {
                		tmp = (t_1 * (1.0 - t_0)) / (t_1 * t_1);
                	}
                	return tmp;
                }
                
                x_m = abs(x)
                real(8) function code(x_m)
                    real(8), intent (in) :: x_m
                    real(8) :: t_0
                    real(8) :: t_1
                    real(8) :: tmp
                    t_0 = (0.5d0 / x_m) + 0.5d0
                    t_1 = sqrt(t_0) + 1.0d0
                    if (x_m <= 1.25d0) then
                        tmp = (x_m * x_m) * 0.125d0
                    else
                        tmp = (t_1 * (1.0d0 - t_0)) / (t_1 * t_1)
                    end if
                    code = tmp
                end function
                
                x_m = Math.abs(x);
                public static double code(double x_m) {
                	double t_0 = (0.5 / x_m) + 0.5;
                	double t_1 = Math.sqrt(t_0) + 1.0;
                	double tmp;
                	if (x_m <= 1.25) {
                		tmp = (x_m * x_m) * 0.125;
                	} else {
                		tmp = (t_1 * (1.0 - t_0)) / (t_1 * t_1);
                	}
                	return tmp;
                }
                
                x_m = math.fabs(x)
                def code(x_m):
                	t_0 = (0.5 / x_m) + 0.5
                	t_1 = math.sqrt(t_0) + 1.0
                	tmp = 0
                	if x_m <= 1.25:
                		tmp = (x_m * x_m) * 0.125
                	else:
                		tmp = (t_1 * (1.0 - t_0)) / (t_1 * t_1)
                	return tmp
                
                x_m = abs(x)
                function code(x_m)
                	t_0 = Float64(Float64(0.5 / x_m) + 0.5)
                	t_1 = Float64(sqrt(t_0) + 1.0)
                	tmp = 0.0
                	if (x_m <= 1.25)
                		tmp = Float64(Float64(x_m * x_m) * 0.125);
                	else
                		tmp = Float64(Float64(t_1 * Float64(1.0 - t_0)) / Float64(t_1 * t_1));
                	end
                	return tmp
                end
                
                x_m = abs(x);
                function tmp_2 = code(x_m)
                	t_0 = (0.5 / x_m) + 0.5;
                	t_1 = sqrt(t_0) + 1.0;
                	tmp = 0.0;
                	if (x_m <= 1.25)
                		tmp = (x_m * x_m) * 0.125;
                	else
                		tmp = (t_1 * (1.0 - t_0)) / (t_1 * t_1);
                	end
                	tmp_2 = tmp;
                end
                
                x_m = N[Abs[x], $MachinePrecision]
                code[x$95$m_] := Block[{t$95$0 = N[(N[(0.5 / x$95$m), $MachinePrecision] + 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[t$95$0], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x$95$m, 1.25], N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision], N[(N[(t$95$1 * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
                
                \begin{array}{l}
                x_m = \left|x\right|
                
                \\
                \begin{array}{l}
                t_0 := \frac{0.5}{x\_m} + 0.5\\
                t_1 := \sqrt{t\_0} + 1\\
                \mathbf{if}\;x\_m \leq 1.25:\\
                \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{t\_1 \cdot \left(1 - t\_0\right)}{t\_1 \cdot t\_1}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < 1.25

                  1. Initial program 63.5%

                    \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                  2. Add Preprocessing
                  3. Taylor expanded in x around inf

                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                  4. Step-by-step derivation
                    1. Applied rewrites32.3%

                      \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                    2. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                      2. flip--N/A

                        \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                      3. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                    3. Applied rewrites32.7%

                      \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                    4. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                    5. Step-by-step derivation
                      1. associate-*r/N/A

                        \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                      2. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                      3. *-commutativeN/A

                        \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                      5. unpow2N/A

                        \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                      6. lower-*.f64N/A

                        \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                      7. +-commutativeN/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                      8. *-commutativeN/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                      9. lower-fma.f64N/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                      10. rem-square-sqrtN/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                      11. unpow2N/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                      12. lower-sqrt.f64N/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                      13. unpow2N/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                      14. rem-square-sqrtN/A

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                      15. lower-sqrt.f6470.9

                        \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
                    6. Applied rewrites70.9%

                      \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
                    7. Step-by-step derivation
                      1. Applied rewrites70.9%

                        \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]

                      if 1.25 < x

                      1. Initial program 98.5%

                        \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around inf

                        \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}}} \]
                      4. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                        2. lower-+.f64N/A

                          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                        3. associate-*r/N/A

                          \[\leadsto 1 - \sqrt{\color{blue}{\frac{\frac{1}{2} \cdot 1}{x}} + \frac{1}{2}} \]
                        4. metadata-evalN/A

                          \[\leadsto 1 - \sqrt{\frac{\color{blue}{\frac{1}{2}}}{x} + \frac{1}{2}} \]
                        5. lower-/.f6498.5

                          \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x}} + 0.5} \]
                      5. Applied rewrites98.5%

                        \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x} + 0.5}} \]
                      6. Applied rewrites100.0%

                        \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) - \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\frac{0.5}{x} + 0.5\right)}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)}} \]
                      7. Step-by-step derivation
                        1. Applied rewrites100.0%

                          \[\leadsto \frac{\color{blue}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(1 - \left(\frac{0.5}{x} + 0.5\right)\right)}}{\left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right) \cdot \left(\sqrt{\frac{0.5}{x} + 0.5} + 1\right)} \]
                      8. Recombined 2 regimes into one program.
                      9. Add Preprocessing

                      Alternative 5: 99.1% accurate, 2.2× speedup?

                      \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{0.5}{x\_m} + 0.5\\ \mathbf{if}\;x\_m \leq 1.25:\\ \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t\_0}{\sqrt{t\_0} + 1}\\ \end{array} \end{array} \]
                      x_m = (fabs.f64 x)
                      (FPCore (x_m)
                       :precision binary64
                       (let* ((t_0 (+ (/ 0.5 x_m) 0.5)))
                         (if (<= x_m 1.25)
                           (* (* x_m x_m) 0.125)
                           (/ (- 1.0 t_0) (+ (sqrt t_0) 1.0)))))
                      x_m = fabs(x);
                      double code(double x_m) {
                      	double t_0 = (0.5 / x_m) + 0.5;
                      	double tmp;
                      	if (x_m <= 1.25) {
                      		tmp = (x_m * x_m) * 0.125;
                      	} else {
                      		tmp = (1.0 - t_0) / (sqrt(t_0) + 1.0);
                      	}
                      	return tmp;
                      }
                      
                      x_m = abs(x)
                      real(8) function code(x_m)
                          real(8), intent (in) :: x_m
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = (0.5d0 / x_m) + 0.5d0
                          if (x_m <= 1.25d0) then
                              tmp = (x_m * x_m) * 0.125d0
                          else
                              tmp = (1.0d0 - t_0) / (sqrt(t_0) + 1.0d0)
                          end if
                          code = tmp
                      end function
                      
                      x_m = Math.abs(x);
                      public static double code(double x_m) {
                      	double t_0 = (0.5 / x_m) + 0.5;
                      	double tmp;
                      	if (x_m <= 1.25) {
                      		tmp = (x_m * x_m) * 0.125;
                      	} else {
                      		tmp = (1.0 - t_0) / (Math.sqrt(t_0) + 1.0);
                      	}
                      	return tmp;
                      }
                      
                      x_m = math.fabs(x)
                      def code(x_m):
                      	t_0 = (0.5 / x_m) + 0.5
                      	tmp = 0
                      	if x_m <= 1.25:
                      		tmp = (x_m * x_m) * 0.125
                      	else:
                      		tmp = (1.0 - t_0) / (math.sqrt(t_0) + 1.0)
                      	return tmp
                      
                      x_m = abs(x)
                      function code(x_m)
                      	t_0 = Float64(Float64(0.5 / x_m) + 0.5)
                      	tmp = 0.0
                      	if (x_m <= 1.25)
                      		tmp = Float64(Float64(x_m * x_m) * 0.125);
                      	else
                      		tmp = Float64(Float64(1.0 - t_0) / Float64(sqrt(t_0) + 1.0));
                      	end
                      	return tmp
                      end
                      
                      x_m = abs(x);
                      function tmp_2 = code(x_m)
                      	t_0 = (0.5 / x_m) + 0.5;
                      	tmp = 0.0;
                      	if (x_m <= 1.25)
                      		tmp = (x_m * x_m) * 0.125;
                      	else
                      		tmp = (1.0 - t_0) / (sqrt(t_0) + 1.0);
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      x_m = N[Abs[x], $MachinePrecision]
                      code[x$95$m_] := Block[{t$95$0 = N[(N[(0.5 / x$95$m), $MachinePrecision] + 0.5), $MachinePrecision]}, If[LessEqual[x$95$m, 1.25], N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(N[Sqrt[t$95$0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      x_m = \left|x\right|
                      
                      \\
                      \begin{array}{l}
                      t_0 := \frac{0.5}{x\_m} + 0.5\\
                      \mathbf{if}\;x\_m \leq 1.25:\\
                      \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{1 - t\_0}{\sqrt{t\_0} + 1}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 1.25

                        1. Initial program 63.5%

                          \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around inf

                          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                        4. Step-by-step derivation
                          1. Applied rewrites32.3%

                            \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                          2. Step-by-step derivation
                            1. lift--.f64N/A

                              \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                            2. flip--N/A

                              \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                            3. lower-/.f64N/A

                              \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                          3. Applied rewrites32.7%

                            \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                          4. Taylor expanded in x around 0

                            \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                          5. Step-by-step derivation
                            1. associate-*r/N/A

                              \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                            2. lower-/.f64N/A

                              \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                            3. *-commutativeN/A

                              \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                            4. lower-*.f64N/A

                              \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                            5. unpow2N/A

                              \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                            6. lower-*.f64N/A

                              \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                            7. +-commutativeN/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                            8. *-commutativeN/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                            9. lower-fma.f64N/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                            10. rem-square-sqrtN/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                            11. unpow2N/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                            12. lower-sqrt.f64N/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                            13. unpow2N/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                            14. rem-square-sqrtN/A

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                            15. lower-sqrt.f6470.9

                              \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
                          6. Applied rewrites70.9%

                            \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
                          7. Step-by-step derivation
                            1. Applied rewrites70.9%

                              \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]

                            if 1.25 < x

                            1. Initial program 98.5%

                              \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                            2. Add Preprocessing
                            3. Taylor expanded in x around inf

                              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}}} \]
                            4. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                              2. lower-+.f64N/A

                                \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                              3. associate-*r/N/A

                                \[\leadsto 1 - \sqrt{\color{blue}{\frac{\frac{1}{2} \cdot 1}{x}} + \frac{1}{2}} \]
                              4. metadata-evalN/A

                                \[\leadsto 1 - \sqrt{\frac{\color{blue}{\frac{1}{2}}}{x} + \frac{1}{2}} \]
                              5. lower-/.f6498.5

                                \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x}} + 0.5} \]
                            5. Applied rewrites98.5%

                              \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x} + 0.5}} \]
                            6. Step-by-step derivation
                              1. lift--.f64N/A

                                \[\leadsto \color{blue}{1 - \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}} \]
                              2. flip--N/A

                                \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} \cdot \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}}{1 + \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}}} \]
                              3. lower-/.f64N/A

                                \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}} \cdot \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}}{1 + \sqrt{\frac{\frac{1}{2}}{x} + \frac{1}{2}}}} \]
                            7. Applied rewrites99.9%

                              \[\leadsto \color{blue}{\frac{1 - \left(\frac{0.5}{x} + 0.5\right)}{\sqrt{\frac{0.5}{x} + 0.5} + 1}} \]
                          8. Recombined 2 regimes into one program.
                          9. Add Preprocessing

                          Alternative 6: 98.3% accurate, 3.9× speedup?

                          \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.25:\\ \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\ \mathbf{else}:\\ \;\;\;\;1 - \sqrt{\frac{0.5}{x\_m} + 0.5}\\ \end{array} \end{array} \]
                          x_m = (fabs.f64 x)
                          (FPCore (x_m)
                           :precision binary64
                           (if (<= x_m 1.25) (* (* x_m x_m) 0.125) (- 1.0 (sqrt (+ (/ 0.5 x_m) 0.5)))))
                          x_m = fabs(x);
                          double code(double x_m) {
                          	double tmp;
                          	if (x_m <= 1.25) {
                          		tmp = (x_m * x_m) * 0.125;
                          	} else {
                          		tmp = 1.0 - sqrt(((0.5 / x_m) + 0.5));
                          	}
                          	return tmp;
                          }
                          
                          x_m = abs(x)
                          real(8) function code(x_m)
                              real(8), intent (in) :: x_m
                              real(8) :: tmp
                              if (x_m <= 1.25d0) then
                                  tmp = (x_m * x_m) * 0.125d0
                              else
                                  tmp = 1.0d0 - sqrt(((0.5d0 / x_m) + 0.5d0))
                              end if
                              code = tmp
                          end function
                          
                          x_m = Math.abs(x);
                          public static double code(double x_m) {
                          	double tmp;
                          	if (x_m <= 1.25) {
                          		tmp = (x_m * x_m) * 0.125;
                          	} else {
                          		tmp = 1.0 - Math.sqrt(((0.5 / x_m) + 0.5));
                          	}
                          	return tmp;
                          }
                          
                          x_m = math.fabs(x)
                          def code(x_m):
                          	tmp = 0
                          	if x_m <= 1.25:
                          		tmp = (x_m * x_m) * 0.125
                          	else:
                          		tmp = 1.0 - math.sqrt(((0.5 / x_m) + 0.5))
                          	return tmp
                          
                          x_m = abs(x)
                          function code(x_m)
                          	tmp = 0.0
                          	if (x_m <= 1.25)
                          		tmp = Float64(Float64(x_m * x_m) * 0.125);
                          	else
                          		tmp = Float64(1.0 - sqrt(Float64(Float64(0.5 / x_m) + 0.5)));
                          	end
                          	return tmp
                          end
                          
                          x_m = abs(x);
                          function tmp_2 = code(x_m)
                          	tmp = 0.0;
                          	if (x_m <= 1.25)
                          		tmp = (x_m * x_m) * 0.125;
                          	else
                          		tmp = 1.0 - sqrt(((0.5 / x_m) + 0.5));
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          x_m = N[Abs[x], $MachinePrecision]
                          code[x$95$m_] := If[LessEqual[x$95$m, 1.25], N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision], N[(1.0 - N[Sqrt[N[(N[(0.5 / x$95$m), $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                          
                          \begin{array}{l}
                          x_m = \left|x\right|
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;x\_m \leq 1.25:\\
                          \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;1 - \sqrt{\frac{0.5}{x\_m} + 0.5}\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if x < 1.25

                            1. Initial program 63.5%

                              \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                            2. Add Preprocessing
                            3. Taylor expanded in x around inf

                              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                            4. Step-by-step derivation
                              1. Applied rewrites32.3%

                                \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                              2. Step-by-step derivation
                                1. lift--.f64N/A

                                  \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                                2. flip--N/A

                                  \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                3. lower-/.f64N/A

                                  \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                              3. Applied rewrites32.7%

                                \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                              4. Taylor expanded in x around 0

                                \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                              5. Step-by-step derivation
                                1. associate-*r/N/A

                                  \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                2. lower-/.f64N/A

                                  \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                3. *-commutativeN/A

                                  \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                4. lower-*.f64N/A

                                  \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                5. unpow2N/A

                                  \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                7. +-commutativeN/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                                8. *-commutativeN/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                                9. lower-fma.f64N/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                                10. rem-square-sqrtN/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                11. unpow2N/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                12. lower-sqrt.f64N/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                13. unpow2N/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                14. rem-square-sqrtN/A

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                15. lower-sqrt.f6470.9

                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
                              6. Applied rewrites70.9%

                                \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
                              7. Step-by-step derivation
                                1. Applied rewrites70.9%

                                  \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]

                                if 1.25 < x

                                1. Initial program 98.5%

                                  \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                                2. Add Preprocessing
                                3. Taylor expanded in x around inf

                                  \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}}} \]
                                4. Step-by-step derivation
                                  1. +-commutativeN/A

                                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                                  2. lower-+.f64N/A

                                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2} \cdot \frac{1}{x} + \frac{1}{2}}} \]
                                  3. associate-*r/N/A

                                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{\frac{1}{2} \cdot 1}{x}} + \frac{1}{2}} \]
                                  4. metadata-evalN/A

                                    \[\leadsto 1 - \sqrt{\frac{\color{blue}{\frac{1}{2}}}{x} + \frac{1}{2}} \]
                                  5. lower-/.f6498.5

                                    \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x}} + 0.5} \]
                                5. Applied rewrites98.5%

                                  \[\leadsto 1 - \sqrt{\color{blue}{\frac{0.5}{x} + 0.5}} \]
                              8. Recombined 2 regimes into one program.
                              9. Add Preprocessing

                              Alternative 7: 98.4% accurate, 4.3× speedup?

                              \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.55:\\ \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{\sqrt{0.5} + 1}\\ \end{array} \end{array} \]
                              x_m = (fabs.f64 x)
                              (FPCore (x_m)
                               :precision binary64
                               (if (<= x_m 1.55) (* (* x_m x_m) 0.125) (/ 0.5 (+ (sqrt 0.5) 1.0))))
                              x_m = fabs(x);
                              double code(double x_m) {
                              	double tmp;
                              	if (x_m <= 1.55) {
                              		tmp = (x_m * x_m) * 0.125;
                              	} else {
                              		tmp = 0.5 / (sqrt(0.5) + 1.0);
                              	}
                              	return tmp;
                              }
                              
                              x_m = abs(x)
                              real(8) function code(x_m)
                                  real(8), intent (in) :: x_m
                                  real(8) :: tmp
                                  if (x_m <= 1.55d0) then
                                      tmp = (x_m * x_m) * 0.125d0
                                  else
                                      tmp = 0.5d0 / (sqrt(0.5d0) + 1.0d0)
                                  end if
                                  code = tmp
                              end function
                              
                              x_m = Math.abs(x);
                              public static double code(double x_m) {
                              	double tmp;
                              	if (x_m <= 1.55) {
                              		tmp = (x_m * x_m) * 0.125;
                              	} else {
                              		tmp = 0.5 / (Math.sqrt(0.5) + 1.0);
                              	}
                              	return tmp;
                              }
                              
                              x_m = math.fabs(x)
                              def code(x_m):
                              	tmp = 0
                              	if x_m <= 1.55:
                              		tmp = (x_m * x_m) * 0.125
                              	else:
                              		tmp = 0.5 / (math.sqrt(0.5) + 1.0)
                              	return tmp
                              
                              x_m = abs(x)
                              function code(x_m)
                              	tmp = 0.0
                              	if (x_m <= 1.55)
                              		tmp = Float64(Float64(x_m * x_m) * 0.125);
                              	else
                              		tmp = Float64(0.5 / Float64(sqrt(0.5) + 1.0));
                              	end
                              	return tmp
                              end
                              
                              x_m = abs(x);
                              function tmp_2 = code(x_m)
                              	tmp = 0.0;
                              	if (x_m <= 1.55)
                              		tmp = (x_m * x_m) * 0.125;
                              	else
                              		tmp = 0.5 / (sqrt(0.5) + 1.0);
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              x_m = N[Abs[x], $MachinePrecision]
                              code[x$95$m_] := If[LessEqual[x$95$m, 1.55], N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision], N[(0.5 / N[(N[Sqrt[0.5], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                              
                              \begin{array}{l}
                              x_m = \left|x\right|
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;x\_m \leq 1.55:\\
                              \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\frac{0.5}{\sqrt{0.5} + 1}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if x < 1.55000000000000004

                                1. Initial program 63.5%

                                  \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                                2. Add Preprocessing
                                3. Taylor expanded in x around inf

                                  \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites32.3%

                                    \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                                  2. Step-by-step derivation
                                    1. lift--.f64N/A

                                      \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                                    2. flip--N/A

                                      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                    3. lower-/.f64N/A

                                      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                  3. Applied rewrites32.7%

                                    \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                                  4. Taylor expanded in x around 0

                                    \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                  5. Step-by-step derivation
                                    1. associate-*r/N/A

                                      \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                    2. lower-/.f64N/A

                                      \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                    3. *-commutativeN/A

                                      \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                    4. lower-*.f64N/A

                                      \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                    5. unpow2N/A

                                      \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                    6. lower-*.f64N/A

                                      \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                    7. +-commutativeN/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                                    8. *-commutativeN/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                                    9. lower-fma.f64N/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                                    10. rem-square-sqrtN/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                    11. unpow2N/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                    12. lower-sqrt.f64N/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                    13. unpow2N/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                    14. rem-square-sqrtN/A

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                    15. lower-sqrt.f6470.9

                                      \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
                                  6. Applied rewrites70.9%

                                    \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites70.9%

                                      \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]

                                    if 1.55000000000000004 < x

                                    1. Initial program 98.5%

                                      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in x around inf

                                      \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites96.6%

                                        \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                                      2. Step-by-step derivation
                                        1. lift--.f64N/A

                                          \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                                        2. flip--N/A

                                          \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                        3. lower-/.f64N/A

                                          \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                      3. Applied rewrites98.0%

                                        \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                                      4. Taylor expanded in x around inf

                                        \[\leadsto \frac{\color{blue}{\frac{1}{2}}}{\sqrt{\frac{1}{2}} + 1} \]
                                      5. Step-by-step derivation
                                        1. Applied rewrites98.0%

                                          \[\leadsto \frac{\color{blue}{0.5}}{\sqrt{0.5} + 1} \]
                                      6. Recombined 2 regimes into one program.
                                      7. Add Preprocessing

                                      Alternative 8: 97.6% accurate, 6.7× speedup?

                                      \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.55:\\ \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\ \mathbf{else}:\\ \;\;\;\;1 - \sqrt{0.5}\\ \end{array} \end{array} \]
                                      x_m = (fabs.f64 x)
                                      (FPCore (x_m)
                                       :precision binary64
                                       (if (<= x_m 1.55) (* (* x_m x_m) 0.125) (- 1.0 (sqrt 0.5))))
                                      x_m = fabs(x);
                                      double code(double x_m) {
                                      	double tmp;
                                      	if (x_m <= 1.55) {
                                      		tmp = (x_m * x_m) * 0.125;
                                      	} else {
                                      		tmp = 1.0 - sqrt(0.5);
                                      	}
                                      	return tmp;
                                      }
                                      
                                      x_m = abs(x)
                                      real(8) function code(x_m)
                                          real(8), intent (in) :: x_m
                                          real(8) :: tmp
                                          if (x_m <= 1.55d0) then
                                              tmp = (x_m * x_m) * 0.125d0
                                          else
                                              tmp = 1.0d0 - sqrt(0.5d0)
                                          end if
                                          code = tmp
                                      end function
                                      
                                      x_m = Math.abs(x);
                                      public static double code(double x_m) {
                                      	double tmp;
                                      	if (x_m <= 1.55) {
                                      		tmp = (x_m * x_m) * 0.125;
                                      	} else {
                                      		tmp = 1.0 - Math.sqrt(0.5);
                                      	}
                                      	return tmp;
                                      }
                                      
                                      x_m = math.fabs(x)
                                      def code(x_m):
                                      	tmp = 0
                                      	if x_m <= 1.55:
                                      		tmp = (x_m * x_m) * 0.125
                                      	else:
                                      		tmp = 1.0 - math.sqrt(0.5)
                                      	return tmp
                                      
                                      x_m = abs(x)
                                      function code(x_m)
                                      	tmp = 0.0
                                      	if (x_m <= 1.55)
                                      		tmp = Float64(Float64(x_m * x_m) * 0.125);
                                      	else
                                      		tmp = Float64(1.0 - sqrt(0.5));
                                      	end
                                      	return tmp
                                      end
                                      
                                      x_m = abs(x);
                                      function tmp_2 = code(x_m)
                                      	tmp = 0.0;
                                      	if (x_m <= 1.55)
                                      		tmp = (x_m * x_m) * 0.125;
                                      	else
                                      		tmp = 1.0 - sqrt(0.5);
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      x_m = N[Abs[x], $MachinePrecision]
                                      code[x$95$m_] := If[LessEqual[x$95$m, 1.55], N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision], N[(1.0 - N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]]
                                      
                                      \begin{array}{l}
                                      x_m = \left|x\right|
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;x\_m \leq 1.55:\\
                                      \;\;\;\;\left(x\_m \cdot x\_m\right) \cdot 0.125\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;1 - \sqrt{0.5}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if x < 1.55000000000000004

                                        1. Initial program 63.5%

                                          \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in x around inf

                                          \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                                        4. Step-by-step derivation
                                          1. Applied rewrites32.3%

                                            \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                                          2. Step-by-step derivation
                                            1. lift--.f64N/A

                                              \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                                            2. flip--N/A

                                              \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                            3. lower-/.f64N/A

                                              \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                          3. Applied rewrites32.7%

                                            \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                                          4. Taylor expanded in x around 0

                                            \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                          5. Step-by-step derivation
                                            1. associate-*r/N/A

                                              \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                            2. lower-/.f64N/A

                                              \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                            3. *-commutativeN/A

                                              \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                            4. lower-*.f64N/A

                                              \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                            5. unpow2N/A

                                              \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                            6. lower-*.f64N/A

                                              \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                            7. +-commutativeN/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                                            8. *-commutativeN/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                                            9. lower-fma.f64N/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                                            10. rem-square-sqrtN/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                            11. unpow2N/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                            12. lower-sqrt.f64N/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                            13. unpow2N/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                            14. rem-square-sqrtN/A

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                            15. lower-sqrt.f6470.9

                                              \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
                                          6. Applied rewrites70.9%

                                            \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
                                          7. Step-by-step derivation
                                            1. Applied rewrites70.9%

                                              \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]

                                            if 1.55000000000000004 < x

                                            1. Initial program 98.5%

                                              \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in x around inf

                                              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites96.6%

                                                \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                                            5. Recombined 2 regimes into one program.
                                            6. Add Preprocessing

                                            Alternative 9: 50.9% accurate, 12.2× speedup?

                                            \[\begin{array}{l} x_m = \left|x\right| \\ \left(x\_m \cdot x\_m\right) \cdot 0.125 \end{array} \]
                                            x_m = (fabs.f64 x)
                                            (FPCore (x_m) :precision binary64 (* (* x_m x_m) 0.125))
                                            x_m = fabs(x);
                                            double code(double x_m) {
                                            	return (x_m * x_m) * 0.125;
                                            }
                                            
                                            x_m = abs(x)
                                            real(8) function code(x_m)
                                                real(8), intent (in) :: x_m
                                                code = (x_m * x_m) * 0.125d0
                                            end function
                                            
                                            x_m = Math.abs(x);
                                            public static double code(double x_m) {
                                            	return (x_m * x_m) * 0.125;
                                            }
                                            
                                            x_m = math.fabs(x)
                                            def code(x_m):
                                            	return (x_m * x_m) * 0.125
                                            
                                            x_m = abs(x)
                                            function code(x_m)
                                            	return Float64(Float64(x_m * x_m) * 0.125)
                                            end
                                            
                                            x_m = abs(x);
                                            function tmp = code(x_m)
                                            	tmp = (x_m * x_m) * 0.125;
                                            end
                                            
                                            x_m = N[Abs[x], $MachinePrecision]
                                            code[x$95$m_] := N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.125), $MachinePrecision]
                                            
                                            \begin{array}{l}
                                            x_m = \left|x\right|
                                            
                                            \\
                                            \left(x\_m \cdot x\_m\right) \cdot 0.125
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 72.1%

                                              \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in x around inf

                                              \[\leadsto 1 - \sqrt{\color{blue}{\frac{1}{2}}} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites48.1%

                                                \[\leadsto 1 - \sqrt{\color{blue}{0.5}} \]
                                              2. Step-by-step derivation
                                                1. lift--.f64N/A

                                                  \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2}}} \]
                                                2. flip--N/A

                                                  \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                                3. lower-/.f64N/A

                                                  \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}{1 + \sqrt{\frac{1}{2}}}} \]
                                              3. Applied rewrites48.8%

                                                \[\leadsto \color{blue}{\frac{1 - 0.5}{\sqrt{0.5} + 1}} \]
                                              4. Taylor expanded in x around 0

                                                \[\leadsto \color{blue}{\frac{1}{4} \cdot \frac{{x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                              5. Step-by-step derivation
                                                1. associate-*r/N/A

                                                  \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                                2. lower-/.f64N/A

                                                  \[\leadsto \color{blue}{\frac{\frac{1}{4} \cdot {x}^{2}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}}} \]
                                                3. *-commutativeN/A

                                                  \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                                4. lower-*.f64N/A

                                                  \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \frac{1}{4}}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                                5. unpow2N/A

                                                  \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                                6. lower-*.f64N/A

                                                  \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{4}}{1 + \sqrt{\frac{1}{2}} \cdot \sqrt{2}} \]
                                                7. +-commutativeN/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{2} + 1}} \]
                                                8. *-commutativeN/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\sqrt{2} \cdot \sqrt{\frac{1}{2}}} + 1} \]
                                                9. lower-fma.f64N/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\color{blue}{\mathsf{fma}\left(\sqrt{2}, \sqrt{\frac{1}{2}}, 1\right)}} \]
                                                10. rem-square-sqrtN/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                                11. unpow2N/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                                12. lower-sqrt.f64N/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\color{blue}{\sqrt{{\left(\sqrt{2}\right)}^{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                                13. unpow2N/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                                14. rem-square-sqrtN/A

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot \frac{1}{4}}{\mathsf{fma}\left(\sqrt{\color{blue}{2}}, \sqrt{\frac{1}{2}}, 1\right)} \]
                                                15. lower-sqrt.f6454.6

                                                  \[\leadsto \frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \color{blue}{\sqrt{0.5}}, 1\right)} \]
                                              6. Applied rewrites54.6%

                                                \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.25}{\mathsf{fma}\left(\sqrt{2}, \sqrt{0.5}, 1\right)}} \]
                                              7. Step-by-step derivation
                                                1. Applied rewrites54.6%

                                                  \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{0.125} \]
                                                2. Add Preprocessing

                                                Reproduce

                                                ?
                                                herbie shell --seed 2024337 
                                                (FPCore (x)
                                                  :name "Given's Rotation SVD example, simplified"
                                                  :precision binary64
                                                  (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))