Jmat.Real.erfi, branch x less than or equal to 0.5

Percentage Accurate: 99.8% → 99.8%
Time: 17.9s
Alternatives: 8
Speedup: 3.0×

Specification

?
\[x \leq 0.5\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\ t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\ \left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
        (t_1 (* (* t_0 (fabs x)) (fabs x))))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (+
      (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
      (* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
	double t_0 = (fabs(x) * fabs(x)) * fabs(x);
	double t_1 = (t_0 * fabs(x)) * fabs(x);
	return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
	double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
	double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
	return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x):
	t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x)
	t_1 = (t_0 * math.fabs(x)) * math.fabs(x)
	return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x)
	t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x))
	t_1 = Float64(Float64(t_0 * abs(x)) * abs(x))
	return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x))))))
end
function tmp = code(x)
	t_0 = (abs(x) * abs(x)) * abs(x);
	t_1 = (t_0 * abs(x)) * abs(x);
	tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x))))));
end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\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 8 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: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\ t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\ \left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
        (t_1 (* (* t_0 (fabs x)) (fabs x))))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (+
      (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
      (* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
	double t_0 = (fabs(x) * fabs(x)) * fabs(x);
	double t_1 = (t_0 * fabs(x)) * fabs(x);
	return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
	double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
	double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
	return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x):
	t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x)
	t_1 = (t_0 * math.fabs(x)) * math.fabs(x)
	return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x)
	t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x))
	t_1 = Float64(Float64(t_0 * abs(x)) * abs(x))
	return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x))))))
end
function tmp = code(x)
	t_0 = (abs(x) * abs(x)) * abs(x);
	t_1 = (t_0 * abs(x)) * abs(x);
	tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x))))));
end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}

Alternative 1: 99.8% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}} \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (fabs x)
  (/
   (fma
    (* x (* x (* x x)))
    (fma 0.047619047619047616 (* x x) 0.2)
    (fma (* x x) 0.6666666666666666 2.0))
   (sqrt PI))))
double code(double x) {
	return fabs(x) * (fma((x * (x * (x * x))), fma(0.047619047619047616, (x * x), 0.2), fma((x * x), 0.6666666666666666, 2.0)) / sqrt(((double) M_PI)));
}
function code(x)
	return Float64(abs(x) * Float64(fma(Float64(x * Float64(x * Float64(x * x))), fma(0.047619047619047616, Float64(x * x), 0.2), fma(Float64(x * x), 0.6666666666666666, 2.0)) / sqrt(pi)))
end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.047619047619047616 * N[(x * x), $MachinePrecision] + 0.2), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
  2. Add Preprocessing
  3. Applied rewrites99.9%

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
  5. Add Preprocessing

Alternative 2: 99.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \mathbf{if}\;\left|x\right| \leq 0.2:\\ \;\;\;\;\left|x\right| \cdot \frac{\mathsf{fma}\left(t\_0, 0.2, \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot t\_0\right)\right)\right)}{\sqrt{\pi}}\right|\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* x (* x (* x x)))))
   (if (<= (fabs x) 0.2)
     (*
      (fabs x)
      (/ (fma t_0 0.2 (fma (* x x) 0.6666666666666666 2.0)) (sqrt PI)))
     (fabs
      (/ (* (fabs x) (* 0.047619047619047616 (* x (* x t_0)))) (sqrt PI))))))
double code(double x) {
	double t_0 = x * (x * (x * x));
	double tmp;
	if (fabs(x) <= 0.2) {
		tmp = fabs(x) * (fma(t_0, 0.2, fma((x * x), 0.6666666666666666, 2.0)) / sqrt(((double) M_PI)));
	} else {
		tmp = fabs(((fabs(x) * (0.047619047619047616 * (x * (x * t_0)))) / sqrt(((double) M_PI))));
	}
	return tmp;
}
function code(x)
	t_0 = Float64(x * Float64(x * Float64(x * x)))
	tmp = 0.0
	if (abs(x) <= 0.2)
		tmp = Float64(abs(x) * Float64(fma(t_0, 0.2, fma(Float64(x * x), 0.6666666666666666, 2.0)) / sqrt(pi)));
	else
		tmp = abs(Float64(Float64(abs(x) * Float64(0.047619047619047616 * Float64(x * Float64(x * t_0)))) / sqrt(pi)));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 0.2], N[(N[Abs[x], $MachinePrecision] * N[(N[(t$95$0 * 0.2 + N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[(N[Abs[x], $MachinePrecision] * N[(0.047619047619047616 * N[(x * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;\left|x\right| \leq 0.2:\\
\;\;\;\;\left|x\right| \cdot \frac{\mathsf{fma}\left(t\_0, 0.2, \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot t\_0\right)\right)\right)}{\sqrt{\pi}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (fabs.f64 x) < 0.20000000000000001

    1. Initial program 99.9%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites99.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \color{blue}{\frac{1}{5}}, \mathsf{fma}\left(x \cdot x, \frac{2}{3}, 2\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
    6. Step-by-step derivation
      1. Applied rewrites99.2%

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \color{blue}{0.2}, \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}} \]

      if 0.20000000000000001 < (fabs.f64 x)

      1. Initial program 99.8%

        \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
      2. Add Preprocessing
      3. Applied rewrites99.8%

        \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2, x \cdot \left(x \cdot \left(x \cdot x\right)\right), 0.047619047619047616 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)}{\sqrt{\pi}}}\right| \]
      4. Taylor expanded in x around inf

        \[\leadsto \left|\frac{\color{blue}{\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      5. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left|\frac{\color{blue}{\left(\frac{1}{21} \cdot {x}^{6}\right) \cdot \left|x\right|}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        2. *-commutativeN/A

          \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{6}\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        3. lower-*.f64N/A

          \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{6}\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        4. lower-fabs.f64N/A

          \[\leadsto \left|\frac{\color{blue}{\left|x\right|} \cdot \left(\frac{1}{21} \cdot {x}^{6}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        5. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \color{blue}{\left(\frac{1}{21} \cdot {x}^{6}\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        6. metadata-evalN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{\color{blue}{\left(5 + 1\right)}}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        7. metadata-evalN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{\left(\color{blue}{\left(4 + 1\right)} + 1\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        8. pow-plusN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left({x}^{\left(4 + 1\right)} \cdot x\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        9. pow-plusN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(\color{blue}{\left({x}^{4} \cdot x\right)} \cdot x\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        10. associate-*r*N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left({x}^{4} \cdot \left(x \cdot x\right)\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        11. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left({x}^{4} \cdot \color{blue}{{x}^{2}}\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        12. *-commutativeN/A

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

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{4}\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        14. associate-*l*N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left(x \cdot \left(x \cdot {x}^{4}\right)\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        15. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left(x \cdot \left(x \cdot {x}^{4}\right)\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        16. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \color{blue}{\left(x \cdot {x}^{4}\right)}\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        17. metadata-evalN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        18. pow-sqrN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        19. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        20. associate-*l*N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot {x}^{2}\right)\right)}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        21. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        22. cube-multN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{{x}^{3}}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        23. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot {x}^{3}\right)}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        24. cube-multN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        25. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{{x}^{2}}\right)\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        26. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot {x}^{2}\right)}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        27. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        28. lower-*.f6499.9

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right)}{\sqrt{\pi}}\right| \]
      6. Applied rewrites99.9%

        \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right)}}{\sqrt{\pi}}\right| \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 3: 99.3% accurate, 2.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.2:\\ \;\;\;\;\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right)}{\sqrt{\pi}}\right|\\ \end{array} \end{array} \]
    (FPCore (x)
     :precision binary64
     (if (<= (fabs x) 0.2)
       (*
        (fabs x)
        (/ (fma (* x x) (fma (* x x) 0.2 0.6666666666666666) 2.0) (sqrt PI)))
       (fabs
        (/
         (* (fabs x) (* 0.047619047619047616 (* x (* x (* x (* x (* x x)))))))
         (sqrt PI)))))
    double code(double x) {
    	double tmp;
    	if (fabs(x) <= 0.2) {
    		tmp = fabs(x) * (fma((x * x), fma((x * x), 0.2, 0.6666666666666666), 2.0) / sqrt(((double) M_PI)));
    	} else {
    		tmp = fabs(((fabs(x) * (0.047619047619047616 * (x * (x * (x * (x * (x * x))))))) / sqrt(((double) M_PI))));
    	}
    	return tmp;
    }
    
    function code(x)
    	tmp = 0.0
    	if (abs(x) <= 0.2)
    		tmp = Float64(abs(x) * Float64(fma(Float64(x * x), fma(Float64(x * x), 0.2, 0.6666666666666666), 2.0) / sqrt(pi)));
    	else
    		tmp = abs(Float64(Float64(abs(x) * Float64(0.047619047619047616 * Float64(x * Float64(x * Float64(x * Float64(x * Float64(x * x))))))) / sqrt(pi)));
    	end
    	return tmp
    end
    
    code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.2], N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.2 + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[(N[Abs[x], $MachinePrecision] * N[(0.047619047619047616 * N[(x * N[(x * N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 0.2:\\
    \;\;\;\;\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\pi}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left|\frac{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right)}{\sqrt{\pi}}\right|\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (fabs.f64 x) < 0.20000000000000001

      1. Initial program 99.9%

        \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
      2. Add Preprocessing
      3. Applied rewrites99.9%

        \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
      4. Applied rewrites99.9%

        \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
      5. Taylor expanded in x around 0

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

          \[\leadsto \left|x\right| \cdot \frac{\color{blue}{{x}^{2} \cdot \left(\frac{2}{3} + \frac{1}{5} \cdot {x}^{2}\right) + 2}}{\sqrt{\mathsf{PI}\left(\right)}} \]
        2. lower-fma.f64N/A

          \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{2}{3} + \frac{1}{5} \cdot {x}^{2}, 2\right)}}{\sqrt{\mathsf{PI}\left(\right)}} \]
        3. unpow2N/A

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

          \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{2}{3} + \frac{1}{5} \cdot {x}^{2}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
        5. +-commutativeN/A

          \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{5} \cdot {x}^{2} + \frac{2}{3}}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
        6. *-commutativeN/A

          \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \frac{1}{5}} + \frac{2}{3}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
        7. lower-fma.f64N/A

          \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{5}, \frac{2}{3}\right)}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
        8. unpow2N/A

          \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{5}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
        9. lower-*.f6499.2

          \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\pi}} \]
      7. Applied rewrites99.2%

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)}}{\sqrt{\pi}} \]

      if 0.20000000000000001 < (fabs.f64 x)

      1. Initial program 99.8%

        \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
      2. Add Preprocessing
      3. Applied rewrites99.8%

        \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2, x \cdot \left(x \cdot \left(x \cdot x\right)\right), 0.047619047619047616 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)}{\sqrt{\pi}}}\right| \]
      4. Taylor expanded in x around inf

        \[\leadsto \left|\frac{\color{blue}{\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      5. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left|\frac{\color{blue}{\left(\frac{1}{21} \cdot {x}^{6}\right) \cdot \left|x\right|}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        2. *-commutativeN/A

          \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{6}\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        3. lower-*.f64N/A

          \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{6}\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        4. lower-fabs.f64N/A

          \[\leadsto \left|\frac{\color{blue}{\left|x\right|} \cdot \left(\frac{1}{21} \cdot {x}^{6}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        5. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \color{blue}{\left(\frac{1}{21} \cdot {x}^{6}\right)}}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        6. metadata-evalN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{\color{blue}{\left(5 + 1\right)}}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        7. metadata-evalN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot {x}^{\left(\color{blue}{\left(4 + 1\right)} + 1\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        8. pow-plusN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left({x}^{\left(4 + 1\right)} \cdot x\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        9. pow-plusN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(\color{blue}{\left({x}^{4} \cdot x\right)} \cdot x\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        10. associate-*r*N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left({x}^{4} \cdot \left(x \cdot x\right)\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        11. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left({x}^{4} \cdot \color{blue}{{x}^{2}}\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        12. *-commutativeN/A

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

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{4}\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        14. associate-*l*N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left(x \cdot \left(x \cdot {x}^{4}\right)\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        15. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \color{blue}{\left(x \cdot \left(x \cdot {x}^{4}\right)\right)}\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        16. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \color{blue}{\left(x \cdot {x}^{4}\right)}\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        17. metadata-evalN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        18. pow-sqrN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        19. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        20. associate-*l*N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot {x}^{2}\right)\right)}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        21. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        22. cube-multN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{{x}^{3}}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        23. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot {x}^{3}\right)}\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        24. cube-multN/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        25. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{{x}^{2}}\right)\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        26. lower-*.f64N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot {x}^{2}\right)}\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        27. unpow2N/A

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(\frac{1}{21} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
        28. lower-*.f6499.9

          \[\leadsto \left|\frac{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right)\right)}{\sqrt{\pi}}\right| \]
      6. Applied rewrites99.9%

        \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot \left(0.047619047619047616 \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right)}}{\sqrt{\pi}}\right| \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 4: 99.8% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right)}{\sqrt{\pi}} \end{array} \]
    (FPCore (x)
     :precision binary64
     (*
      (fabs x)
      (/
       (fma
        (* x x)
        (fma (* x x) (fma x (* x 0.047619047619047616) 0.2) 0.6666666666666666)
        2.0)
       (sqrt PI))))
    double code(double x) {
    	return fabs(x) * (fma((x * x), fma((x * x), fma(x, (x * 0.047619047619047616), 0.2), 0.6666666666666666), 2.0) / sqrt(((double) M_PI)));
    }
    
    function code(x)
    	return Float64(abs(x) * Float64(fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(x * 0.047619047619047616), 0.2), 0.6666666666666666), 2.0) / sqrt(pi)))
    end
    
    code[x_] := N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.047619047619047616), $MachinePrecision] + 0.2), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right)}{\sqrt{\pi}}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites99.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left|x\right| \cdot \frac{\color{blue}{2 + {x}^{2} \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{21} \cdot {x}^{2}\right)\right)}}{\sqrt{\mathsf{PI}\left(\right)}} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{{x}^{2} \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{21} \cdot {x}^{2}\right)\right) + 2}}{\sqrt{\mathsf{PI}\left(\right)}} \]
      2. lower-fma.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{21} \cdot {x}^{2}\right), 2\right)}}{\sqrt{\mathsf{PI}\left(\right)}} \]
      3. unpow2N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{21} \cdot {x}^{2}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      4. lower-*.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{21} \cdot {x}^{2}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      5. +-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{1}{5} + \frac{1}{21} \cdot {x}^{2}\right) + \frac{2}{3}}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      6. lower-fma.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{5} + \frac{1}{21} \cdot {x}^{2}, \frac{2}{3}\right)}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      7. unpow2N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{5} + \frac{1}{21} \cdot {x}^{2}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{5} + \frac{1}{21} \cdot {x}^{2}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      9. +-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{21} \cdot {x}^{2} + \frac{1}{5}}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      10. unpow2N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{21} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{5}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      11. associate-*r*N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{1}{21} \cdot x\right) \cdot x} + \frac{1}{5}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{1}{21} \cdot x\right)} + \frac{1}{5}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      13. lower-fma.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{1}{21} \cdot x, \frac{1}{5}\right)}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      14. *-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{21}}, \frac{1}{5}\right), \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      15. lower-*.f6499.9

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.047619047619047616}, 0.2\right), 0.6666666666666666\right), 2\right)}{\sqrt{\pi}} \]
    7. Applied rewrites99.9%

      \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right)}}{\sqrt{\pi}} \]
    8. Add Preprocessing

    Alternative 5: 93.4% accurate, 3.6× speedup?

    \[\begin{array}{l} \\ \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\pi}} \end{array} \]
    (FPCore (x)
     :precision binary64
     (*
      (fabs x)
      (/ (fma (* x x) (fma (* x x) 0.2 0.6666666666666666) 2.0) (sqrt PI))))
    double code(double x) {
    	return fabs(x) * (fma((x * x), fma((x * x), 0.2, 0.6666666666666666), 2.0) / sqrt(((double) M_PI)));
    }
    
    function code(x)
    	return Float64(abs(x) * Float64(fma(Float64(x * x), fma(Float64(x * x), 0.2, 0.6666666666666666), 2.0) / sqrt(pi)))
    end
    
    code[x_] := N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.2 + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\pi}}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites99.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
    5. Taylor expanded in x around 0

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

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{{x}^{2} \cdot \left(\frac{2}{3} + \frac{1}{5} \cdot {x}^{2}\right) + 2}}{\sqrt{\mathsf{PI}\left(\right)}} \]
      2. lower-fma.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{2}{3} + \frac{1}{5} \cdot {x}^{2}, 2\right)}}{\sqrt{\mathsf{PI}\left(\right)}} \]
      3. unpow2N/A

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

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{2}{3} + \frac{1}{5} \cdot {x}^{2}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      5. +-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{5} \cdot {x}^{2} + \frac{2}{3}}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      6. *-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \frac{1}{5}} + \frac{2}{3}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      7. lower-fma.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{5}, \frac{2}{3}\right)}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      8. unpow2N/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{5}, \frac{2}{3}\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      9. lower-*.f6493.3

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\pi}} \]
    7. Applied rewrites93.3%

      \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)}}{\sqrt{\pi}} \]
    8. Add Preprocessing

    Alternative 6: 89.0% accurate, 4.6× speedup?

    \[\begin{array}{l} \\ \left|x\right| \cdot \frac{\mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)}{\sqrt{\pi}} \end{array} \]
    (FPCore (x)
     :precision binary64
     (* (fabs x) (/ (fma x (* x 0.6666666666666666) 2.0) (sqrt PI))))
    double code(double x) {
    	return fabs(x) * (fma(x, (x * 0.6666666666666666), 2.0) / sqrt(((double) M_PI)));
    }
    
    function code(x)
    	return Float64(abs(x) * Float64(fma(x, Float64(x * 0.6666666666666666), 2.0) / sqrt(pi)))
    end
    
    code[x_] := N[(N[Abs[x], $MachinePrecision] * N[(N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \left|x\right| \cdot \frac{\mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)}{\sqrt{\pi}}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites99.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left|x\right| \cdot \frac{\color{blue}{2 + \frac{2}{3} \cdot {x}^{2}}}{\sqrt{\mathsf{PI}\left(\right)}} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\frac{2}{3} \cdot {x}^{2} + 2}}{\sqrt{\mathsf{PI}\left(\right)}} \]
      2. unpow2N/A

        \[\leadsto \left|x\right| \cdot \frac{\frac{2}{3} \cdot \color{blue}{\left(x \cdot x\right)} + 2}{\sqrt{\mathsf{PI}\left(\right)}} \]
      3. associate-*r*N/A

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

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{x \cdot \left(\frac{2}{3} \cdot x\right)} + 2}{\sqrt{\mathsf{PI}\left(\right)}} \]
      5. lower-fma.f64N/A

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left(x, \frac{2}{3} \cdot x, 2\right)}}{\sqrt{\mathsf{PI}\left(\right)}} \]
      6. *-commutativeN/A

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x, \color{blue}{x \cdot \frac{2}{3}}, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \]
      7. lower-*.f6487.9

        \[\leadsto \left|x\right| \cdot \frac{\mathsf{fma}\left(x, \color{blue}{x \cdot 0.6666666666666666}, 2\right)}{\sqrt{\pi}} \]
    7. Applied rewrites87.9%

      \[\leadsto \left|x\right| \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)}}{\sqrt{\pi}} \]
    8. Add Preprocessing

    Alternative 7: 88.6% accurate, 4.6× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|\frac{x}{\sqrt{\pi}}\right| \end{array} \]
    (FPCore (x)
     :precision binary64
     (* (fma (* x x) 0.6666666666666666 2.0) (fabs (/ x (sqrt PI)))))
    double code(double x) {
    	return fma((x * x), 0.6666666666666666, 2.0) * fabs((x / sqrt(((double) M_PI))));
    }
    
    function code(x)
    	return Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * abs(Float64(x / sqrt(pi))))
    end
    
    code[x_] := N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * N[Abs[N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|\frac{x}{\sqrt{\pi}}\right|
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites99.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
    5. Applied rewrites87.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|\frac{x}{\sqrt{\pi}}\right|} \]
    6. Add Preprocessing

    Alternative 8: 67.9% accurate, 6.3× speedup?

    \[\begin{array}{l} \\ \left|x\right| \cdot \frac{2}{\sqrt{\pi}} \end{array} \]
    (FPCore (x) :precision binary64 (* (fabs x) (/ 2.0 (sqrt PI))))
    double code(double x) {
    	return fabs(x) * (2.0 / sqrt(((double) M_PI)));
    }
    
    public static double code(double x) {
    	return Math.abs(x) * (2.0 / Math.sqrt(Math.PI));
    }
    
    def code(x):
    	return math.fabs(x) * (2.0 / math.sqrt(math.pi))
    
    function code(x)
    	return Float64(abs(x) * Float64(2.0 / sqrt(pi)))
    end
    
    function tmp = code(x)
    	tmp = abs(x) * (2.0 / sqrt(pi));
    end
    
    code[x_] := N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \left|x\right| \cdot \frac{2}{\sqrt{\pi}}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites99.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, \mathsf{fma}\left(\left|x\right|, 0.2 \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right), \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right| \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left|x\right| \cdot \frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}{\sqrt{\pi}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left|x\right| \cdot \frac{\color{blue}{2}}{\sqrt{\mathsf{PI}\left(\right)}} \]
    6. Step-by-step derivation
      1. Applied rewrites68.1%

        \[\leadsto \left|x\right| \cdot \frac{\color{blue}{2}}{\sqrt{\pi}} \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024212 
      (FPCore (x)
        :name "Jmat.Real.erfi, branch x less than or equal to 0.5"
        :precision binary64
        :pre (<= x 0.5)
        (fabs (* (/ 1.0 (sqrt PI)) (+ (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* (fabs x) (fabs x)) (fabs x)))) (* (/ 1.0 5.0) (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)))) (* (/ 1.0 21.0) (* (* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)))))))