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

Percentage Accurate: 99.8% → 99.8%
Time: 7.3s
Alternatives: 15
Speedup: 1.4×

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}

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 15 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, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\left(x \cdot x\right) \cdot x\right|\\ t_1 := {\left(\left|x\right|\right)}^{\left(\frac{7}{2}\right)}\\ \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(t\_1 \cdot t\_1, 0.047619047619047616, \mathsf{fma}\left(2, \left|x\right|, \mathsf{fma}\left(0.6666666666666666, t\_0, \left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot 0.2\right)\right)\right)\right| \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (fabs (* (* x x) x))) (t_1 (pow (fabs x) (/ 7.0 2.0))))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (fma
      (* t_1 t_1)
      0.047619047619047616
      (fma
       2.0
       (fabs x)
       (fma 0.6666666666666666 t_0 (* (* t_0 (* x x)) 0.2))))))))
double code(double x) {
	double t_0 = fabs(((x * x) * x));
	double t_1 = pow(fabs(x), (7.0 / 2.0));
	return fabs(((1.0 / sqrt(((double) M_PI))) * fma((t_1 * t_1), 0.047619047619047616, fma(2.0, fabs(x), fma(0.6666666666666666, t_0, ((t_0 * (x * x)) * 0.2))))));
}
function code(x)
	t_0 = abs(Float64(Float64(x * x) * x))
	t_1 = abs(x) ^ Float64(7.0 / 2.0)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma(Float64(t_1 * t_1), 0.047619047619047616, fma(2.0, abs(x), fma(0.6666666666666666, t_0, Float64(Float64(t_0 * Float64(x * x)) * 0.2))))))
end
code[x_] := Block[{t$95$0 = N[Abs[N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Abs[x], $MachinePrecision], N[(7.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.047619047619047616 + N[(2.0 * N[Abs[x], $MachinePrecision] + N[(0.6666666666666666 * t$95$0 + N[(N[(t$95$0 * N[(x * x), $MachinePrecision]), $MachinePrecision] * 0.2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|\left(x \cdot x\right) \cdot x\right|\\
t_1 := {\left(\left|x\right|\right)}^{\left(\frac{7}{2}\right)}\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(t\_1 \cdot t\_1, 0.047619047619047616, \mathsf{fma}\left(2, \left|x\right|, \mathsf{fma}\left(0.6666666666666666, t\_0, \left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot 0.2\right)\right)\right)\right|
\end{array}
\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. Taylor expanded in x around 0

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + \left(\frac{1}{5} \cdot {\left(\left|x\right|\right)}^{5} + \left(\frac{2}{3} \cdot {\left(\left|x\right|\right)}^{3} + 2 \cdot \left|x\right|\right)\right)\right)}\right| \]
  3. Applied rewrites99.8%

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

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

Alternative 2: 99.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\left(x \cdot x\right) \cdot x\right|\\ \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(2, \left|x\right|, \mathsf{fma}\left(0.6666666666666666, t\_0, \left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot 0.2\right)\right)\right)\right| \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (fabs (* (* x x) x))))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (fma
      (pow (fabs x) 7.0)
      0.047619047619047616
      (fma
       2.0
       (fabs x)
       (fma 0.6666666666666666 t_0 (* (* t_0 (* x x)) 0.2))))))))
double code(double x) {
	double t_0 = fabs(((x * x) * x));
	return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, fma(2.0, fabs(x), fma(0.6666666666666666, t_0, ((t_0 * (x * x)) * 0.2))))));
}
function code(x)
	t_0 = abs(Float64(Float64(x * x) * x))
	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, fma(2.0, abs(x), fma(0.6666666666666666, t_0, Float64(Float64(t_0 * Float64(x * x)) * 0.2))))))
end
code[x_] := Block[{t$95$0 = N[Abs[N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616 + N[(2.0 * N[Abs[x], $MachinePrecision] + N[(0.6666666666666666 * t$95$0 + N[(N[(t$95$0 * N[(x * x), $MachinePrecision]), $MachinePrecision] * 0.2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|\left(x \cdot x\right) \cdot x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(2, \left|x\right|, \mathsf{fma}\left(0.6666666666666666, t\_0, \left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot 0.2\right)\right)\right)\right|
\end{array}
\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. Taylor expanded in x around 0

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + \left(\frac{1}{5} \cdot {\left(\left|x\right|\right)}^{5} + \left(\frac{2}{3} \cdot {\left(\left|x\right|\right)}^{3} + 2 \cdot \left|x\right|\right)\right)\right)}\right| \]
  3. Applied rewrites99.8%

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

Alternative 3: 99.4% accurate, 1.6× speedup?

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

\\
\left|\frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{4} \cdot \left|x\right|, 0.047619047619047616, \mathsf{fma}\left(0.2, \left|\left(x \cdot x\right) \cdot x\right|, 0.6666666666666666 \cdot \left|x\right|\right)\right) \cdot x, x, \left|x\right| \cdot 2\right)}{\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. Applied rewrites99.3%

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

    \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
  4. Applied rewrites67.5%

    \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot 2}}{\sqrt{\pi}}\right| \]
  5. Taylor expanded in x around 0

    \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right| + {x}^{2} \cdot \left(\frac{1}{21} \cdot \left({x}^{4} \cdot \left|x\right|\right) + \left(\frac{1}{5} \cdot \left|{x}^{3}\right| + \frac{2}{3} \cdot \left|x\right|\right)\right)}}{\sqrt{\pi}}\right| \]
  6. Applied rewrites99.4%

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

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

Alternative 4: 99.0% accurate, 1.7× speedup?

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

\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(2, \left|x\right|, \left(\left(x \cdot x\right) \cdot \left|\left(x \cdot x\right) \cdot x\right|\right) \cdot 0.2\right)\right)\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. Taylor expanded in x around 0

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + \left(\frac{1}{5} \cdot {\left(\left|x\right|\right)}^{5} + \left(\frac{2}{3} \cdot {\left(\left|x\right|\right)}^{3} + 2 \cdot \left|x\right|\right)\right)\right)}\right| \]
  3. Applied rewrites99.8%

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

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, \frac{1}{21}, \mathsf{fma}\left(2, \left|x\right|, \frac{1}{5} \cdot \left({x}^{2} \cdot \left|{x}^{3}\right|\right)\right)\right)\right| \]
  5. Applied rewrites99.0%

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(2, \left|x\right|, \left(\left(x \cdot x\right) \cdot \left|\left(x \cdot x\right) \cdot x\right|\right) \cdot 0.2\right)\right)\right| \]
  6. Add Preprocessing

Alternative 5: 98.8% accurate, 2.5× speedup?

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

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

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


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

    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. Applied rewrites99.3%

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

      \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
    4. Applied rewrites67.5%

      \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot 2}}{\sqrt{\pi}}\right| \]
    5. Taylor expanded in x around 0

      \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right| + {x}^{2} \cdot \left(\frac{1}{21} \cdot \left({x}^{4} \cdot \left|x\right|\right) + \left(\frac{1}{5} \cdot \left|{x}^{3}\right| + \frac{2}{3} \cdot \left|x\right|\right)\right)}}{\sqrt{\pi}}\right| \]
    6. Applied rewrites99.4%

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

      \[\leadsto \left|\color{blue}{\frac{2}{3} \cdot \left(\left({x}^{2} \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right) + 2 \cdot \left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \left|x\right|\right)}\right| \]
    8. Applied rewrites89.1%

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

    if 2.2000000000000002 < 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. Applied rewrites99.3%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(\frac{2}{3}, x \cdot x, 2\right), \frac{\left|\left(x \cdot x\right) \cdot x\right| \cdot \left(x \cdot x\right)}{5}\right) + \frac{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \left|x\right|}{21}}{\sqrt{\pi}}}\right| \]
    3. Taylor expanded in x around inf

      \[\leadsto \left|\frac{\color{blue}{\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)}}{\sqrt{\pi}}\right| \]
    4. Applied rewrites36.6%

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

      \[\leadsto \left|\frac{\color{blue}{\left(0.047619047619047616 \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
    6. Taylor expanded in x around 0

      \[\leadsto \left|\frac{\left(\frac{1}{21} \cdot {x}^{6}\right) \cdot \left|x\right|}{\sqrt{\pi}}\right| \]
    7. Applied rewrites36.6%

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

Alternative 6: 98.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.86:\\ \;\;\;\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot 2\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(0.047619047619047616 \cdot {x}^{6}\right) \cdot \left|x\right|}{\sqrt{\pi}}\right|\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.86)
   (fabs (* (/ 1.0 (sqrt PI)) (* (fabs x) 2.0)))
   (fabs (/ (* (* 0.047619047619047616 (pow x 6.0)) (fabs x)) (sqrt PI)))))
double code(double x) {
	double tmp;
	if (x <= 1.86) {
		tmp = fabs(((1.0 / sqrt(((double) M_PI))) * (fabs(x) * 2.0)));
	} else {
		tmp = fabs((((0.047619047619047616 * pow(x, 6.0)) * fabs(x)) / sqrt(((double) M_PI))));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 1.86) {
		tmp = Math.abs(((1.0 / Math.sqrt(Math.PI)) * (Math.abs(x) * 2.0)));
	} else {
		tmp = Math.abs((((0.047619047619047616 * Math.pow(x, 6.0)) * Math.abs(x)) / Math.sqrt(Math.PI)));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.86:
		tmp = math.fabs(((1.0 / math.sqrt(math.pi)) * (math.fabs(x) * 2.0)))
	else:
		tmp = math.fabs((((0.047619047619047616 * math.pow(x, 6.0)) * math.fabs(x)) / math.sqrt(math.pi)))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.86)
		tmp = abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(abs(x) * 2.0)));
	else
		tmp = abs(Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) * abs(x)) / sqrt(pi)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.86)
		tmp = abs(((1.0 / sqrt(pi)) * (abs(x) * 2.0)));
	else
		tmp = abs((((0.047619047619047616 * (x ^ 6.0)) * abs(x)) / sqrt(pi)));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.86], N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot 2\right)\right|\\

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


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

    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. Applied rewrites99.8%

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

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(2 \cdot \left|x\right|\right)}\right| \]
    4. Applied rewrites67.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\left|x\right| \cdot 2\right)}\right| \]

    if 1.8600000000000001 < 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. Applied rewrites99.3%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(\frac{2}{3}, x \cdot x, 2\right), \frac{\left|\left(x \cdot x\right) \cdot x\right| \cdot \left(x \cdot x\right)}{5}\right) + \frac{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \left|x\right|}{21}}{\sqrt{\pi}}}\right| \]
    3. Taylor expanded in x around inf

      \[\leadsto \left|\frac{\color{blue}{\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)}}{\sqrt{\pi}}\right| \]
    4. Applied rewrites36.6%

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

      \[\leadsto \left|\frac{\color{blue}{\left(0.047619047619047616 \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
    6. Taylor expanded in x around 0

      \[\leadsto \left|\frac{\left(\frac{1}{21} \cdot {x}^{6}\right) \cdot \left|x\right|}{\sqrt{\pi}}\right| \]
    7. Applied rewrites36.6%

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

Alternative 7: 89.1% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.86:\\ \;\;\;\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot 2\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(0.047619047619047616 \cdot \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right)\right) \cdot \left|x\right|}{\sqrt{\pi}}\right|\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.86)
   (fabs (* (/ 1.0 (sqrt PI)) (* (fabs x) 2.0)))
   (fabs
    (/
     (* (* 0.047619047619047616 (* (* (* x x) (* x x)) (* x x))) (fabs x))
     (sqrt PI)))))
double code(double x) {
	double tmp;
	if (x <= 1.86) {
		tmp = fabs(((1.0 / sqrt(((double) M_PI))) * (fabs(x) * 2.0)));
	} else {
		tmp = fabs((((0.047619047619047616 * (((x * x) * (x * x)) * (x * x))) * fabs(x)) / sqrt(((double) M_PI))));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 1.86) {
		tmp = Math.abs(((1.0 / Math.sqrt(Math.PI)) * (Math.abs(x) * 2.0)));
	} else {
		tmp = Math.abs((((0.047619047619047616 * (((x * x) * (x * x)) * (x * x))) * Math.abs(x)) / Math.sqrt(Math.PI)));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.86:
		tmp = math.fabs(((1.0 / math.sqrt(math.pi)) * (math.fabs(x) * 2.0)))
	else:
		tmp = math.fabs((((0.047619047619047616 * (((x * x) * (x * x)) * (x * x))) * math.fabs(x)) / math.sqrt(math.pi)))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.86)
		tmp = abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(abs(x) * 2.0)));
	else
		tmp = abs(Float64(Float64(Float64(0.047619047619047616 * Float64(Float64(Float64(x * x) * Float64(x * x)) * Float64(x * x))) * abs(x)) / sqrt(pi)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.86)
		tmp = abs(((1.0 / sqrt(pi)) * (abs(x) * 2.0)));
	else
		tmp = abs((((0.047619047619047616 * (((x * x) * (x * x)) * (x * x))) * abs(x)) / sqrt(pi)));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.86], N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(0.047619047619047616 * N[(N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot 2\right)\right|\\

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


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

    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. Applied rewrites99.8%

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

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(2 \cdot \left|x\right|\right)}\right| \]
    4. Applied rewrites67.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\left|x\right| \cdot 2\right)}\right| \]

    if 1.8600000000000001 < 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. Applied rewrites99.3%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(\frac{2}{3}, x \cdot x, 2\right), \frac{\left|\left(x \cdot x\right) \cdot x\right| \cdot \left(x \cdot x\right)}{5}\right) + \frac{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \left|x\right|}{21}}{\sqrt{\pi}}}\right| \]
    3. Taylor expanded in x around inf

      \[\leadsto \left|\frac{\color{blue}{\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)}}{\sqrt{\pi}}\right| \]
    4. Applied rewrites36.6%

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

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

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

Alternative 8: 88.6% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x \cdot x\right) \cdot x\\ \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(\frac{1}{21} \cdot \left|x\right|, t\_0 \cdot t\_0, \left|x\right| \cdot 2\right)\right| \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (* x x) x)))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (fma (* (/ 1.0 21.0) (fabs x)) (* t_0 t_0) (* (fabs x) 2.0))))))
double code(double x) {
	double t_0 = (x * x) * x;
	return fabs(((1.0 / sqrt(((double) M_PI))) * fma(((1.0 / 21.0) * fabs(x)), (t_0 * t_0), (fabs(x) * 2.0))));
}
function code(x)
	t_0 = Float64(Float64(x * x) * x)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma(Float64(Float64(1.0 / 21.0) * abs(x)), Float64(t_0 * t_0), Float64(abs(x) * 2.0))))
end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / 21.0), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(\frac{1}{21} \cdot \left|x\right|, t\_0 \cdot t\_0, \left|x\right| \cdot 2\right)\right|
\end{array}
\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. Applied rewrites99.8%

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

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(\frac{1}{21} \cdot \left|x\right|, \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), \color{blue}{2 \cdot \left|x\right|}\right)\right| \]
  4. Applied rewrites98.8%

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

Alternative 9: 83.3% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot 2\right)\right|\\

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


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

    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. Applied rewrites99.8%

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

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(2 \cdot \left|x\right|\right)}\right| \]
    4. Applied rewrites67.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\left|x\right| \cdot 2\right)}\right| \]

    if 1.8600000000000001 < 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. Applied rewrites99.3%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(\frac{2}{3}, x \cdot x, 2\right), \frac{\left|\left(x \cdot x\right) \cdot x\right| \cdot \left(x \cdot x\right)}{5}\right) + \frac{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \left|x\right|}{21}}{\sqrt{\pi}}}\right| \]
    3. Taylor expanded in x around inf

      \[\leadsto \left|\frac{\color{blue}{\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)}}{\sqrt{\pi}}\right| \]
    4. Applied rewrites36.6%

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

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

Alternative 10: 67.9% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\left|\frac{\left|x\right| \cdot 2 + \frac{\left(t\_0 \cdot t\_0\right) \cdot \left|x\right|}{21}}{\sqrt{\pi}}\right|
\end{array}
\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. Applied rewrites99.3%

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

    \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right|} + \frac{\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \left|x\right|}{21}}{\sqrt{\pi}}\right| \]
  4. Applied rewrites98.3%

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

Alternative 11: 67.9% accurate, 3.2× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\pi}}\\
\mathbf{if}\;x \leq 1.75:\\
\;\;\;\;\left|t\_0 \cdot \left(\left|x\right| \cdot 2\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t\_0 \cdot \left(\left(\left(x \cdot x\right) \cdot \left|\left(x \cdot x\right) \cdot x\right|\right) \cdot 0.2\right)\right|\\


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

    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. Applied rewrites99.8%

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

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(2 \cdot \left|x\right|\right)}\right| \]
    4. Applied rewrites67.9%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\left|x\right| \cdot 2\right)}\right| \]

    if 1.75 < 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. Taylor expanded in x around 0

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + \left(\frac{1}{5} \cdot {\left(\left|x\right|\right)}^{5} + \left(\frac{2}{3} \cdot {\left(\left|x\right|\right)}^{3} + 2 \cdot \left|x\right|\right)\right)\right)}\right| \]
    3. Applied rewrites99.8%

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

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \left(\frac{1}{5} \cdot \color{blue}{\left({x}^{2} \cdot \left|{x}^{3}\right|\right)}\right)\right| \]
    5. Applied rewrites31.0%

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

Alternative 12: 67.9% accurate, 4.9× speedup?

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

\\
\left|\frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot \left|x\right|}{\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. Applied rewrites99.3%

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

    \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
  4. Applied rewrites67.5%

    \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot 2}}{\sqrt{\pi}}\right| \]
  5. Taylor expanded in x around 0

    \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right| + {x}^{2} \cdot \left(\frac{1}{21} \cdot \left({x}^{4} \cdot \left|x\right|\right) + \left(\frac{1}{5} \cdot \left|{x}^{3}\right| + \frac{2}{3} \cdot \left|x\right|\right)\right)}}{\sqrt{\pi}}\right| \]
  6. Applied rewrites99.4%

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

    \[\leadsto \left|\frac{\color{blue}{\frac{2}{3} \cdot \left({x}^{2} \cdot \left|x\right|\right) + 2 \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
  8. Applied rewrites88.6%

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

Alternative 13: 67.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\ t_1 := \frac{1}{\sqrt{\pi}}\\ t_2 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\ \mathbf{if}\;\left|t\_1 \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_2\right) + \frac{1}{21} \cdot \left(\left(t\_2 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\left|t\_1 \cdot \left(\left|x\right| \cdot 2\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\sqrt{x \cdot x} \cdot 2}{\sqrt{\pi}}\right|\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
        (t_1 (/ 1.0 (sqrt PI)))
        (t_2 (* (* t_0 (fabs x)) (fabs x))))
   (if (<=
        (fabs
         (*
          t_1
          (+
           (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_2))
           (* (/ 1.0 21.0) (* (* t_2 (fabs x)) (fabs x))))))
        5e-9)
     (fabs (* t_1 (* (fabs x) 2.0)))
     (fabs (/ (* (sqrt (* x x)) 2.0) (sqrt PI))))))
double code(double x) {
	double t_0 = (fabs(x) * fabs(x)) * fabs(x);
	double t_1 = 1.0 / sqrt(((double) M_PI));
	double t_2 = (t_0 * fabs(x)) * fabs(x);
	double tmp;
	if (fabs((t_1 * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * fabs(x)) * fabs(x)))))) <= 5e-9) {
		tmp = fabs((t_1 * (fabs(x) * 2.0)));
	} else {
		tmp = fabs(((sqrt((x * x)) * 2.0) / sqrt(((double) M_PI))));
	}
	return tmp;
}
public static double code(double x) {
	double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
	double t_1 = 1.0 / Math.sqrt(Math.PI);
	double t_2 = (t_0 * Math.abs(x)) * Math.abs(x);
	double tmp;
	if (Math.abs((t_1 * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * Math.abs(x)) * Math.abs(x)))))) <= 5e-9) {
		tmp = Math.abs((t_1 * (Math.abs(x) * 2.0)));
	} else {
		tmp = Math.abs(((Math.sqrt((x * x)) * 2.0) / Math.sqrt(Math.PI)));
	}
	return tmp;
}
def code(x):
	t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x)
	t_1 = 1.0 / math.sqrt(math.pi)
	t_2 = (t_0 * math.fabs(x)) * math.fabs(x)
	tmp = 0
	if math.fabs((t_1 * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * math.fabs(x)) * math.fabs(x)))))) <= 5e-9:
		tmp = math.fabs((t_1 * (math.fabs(x) * 2.0)))
	else:
		tmp = math.fabs(((math.sqrt((x * x)) * 2.0) / math.sqrt(math.pi)))
	return tmp
function code(x)
	t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x))
	t_1 = Float64(1.0 / sqrt(pi))
	t_2 = Float64(Float64(t_0 * abs(x)) * abs(x))
	tmp = 0.0
	if (abs(Float64(t_1 * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_2)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_2 * abs(x)) * abs(x)))))) <= 5e-9)
		tmp = abs(Float64(t_1 * Float64(abs(x) * 2.0)));
	else
		tmp = abs(Float64(Float64(sqrt(Float64(x * x)) * 2.0) / sqrt(pi)));
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = (abs(x) * abs(x)) * abs(x);
	t_1 = 1.0 / sqrt(pi);
	t_2 = (t_0 * abs(x)) * abs(x);
	tmp = 0.0;
	if (abs((t_1 * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * abs(x)) * abs(x)))))) <= 5e-9)
		tmp = abs((t_1 * (abs(x) * 2.0)));
	else
		tmp = abs(((sqrt((x * x)) * 2.0) / sqrt(pi)));
	end
	tmp_2 = tmp;
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[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[N[(t$95$1 * 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$2), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 5e-9], N[Abs[N[(t$95$1 * N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] / N[Sqrt[Pi], $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 := \frac{1}{\sqrt{\pi}}\\
t_2 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\mathbf{if}\;\left|t\_1 \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_2\right) + \frac{1}{21} \cdot \left(\left(t\_2 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\left|t\_1 \cdot \left(\left|x\right| \cdot 2\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{\sqrt{x \cdot x} \cdot 2}{\sqrt{\pi}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (fabs.f64 (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 (PI.f64))) (+.f64 (+.f64 (+.f64 (*.f64 #s(literal 2 binary64) (fabs.f64 x)) (*.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 5 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 21 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))))) < 5.0000000000000001e-9

    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. Applied rewrites99.9%

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

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

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(\left|x\right| \cdot 2\right)}\right| \]

    if 5.0000000000000001e-9 < (fabs.f64 (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 (PI.f64))) (+.f64 (+.f64 (+.f64 (*.f64 #s(literal 2 binary64) (fabs.f64 x)) (*.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 5 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 21 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x))))))

    1. Initial program 99.7%

      \[\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. Applied rewrites99.7%

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

      \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
    4. Applied rewrites8.9%

      \[\leadsto \left|\frac{\color{blue}{\left|x\right| \cdot 2}}{\sqrt{\pi}}\right| \]
    5. Applied rewrites52.8%

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

Alternative 14: 67.9% accurate, 6.6× speedup?

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

\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot 2\right)\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. Applied rewrites99.8%

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

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(2 \cdot \left|x\right|\right)}\right| \]
  4. Applied rewrites67.9%

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

Alternative 15: 67.5% accurate, 8.3× speedup?

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

\\
\left|\frac{\left|x\right| \cdot 2}{\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. Applied rewrites99.3%

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

    \[\leadsto \left|\frac{\color{blue}{2 \cdot \left|x\right|}}{\sqrt{\pi}}\right| \]
  4. Applied rewrites67.5%

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

Reproduce

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