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

Percentage Accurate: 99.8% → 99.8%
Time: 7.7s
Alternatives: 18
Speedup: 2.3×

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 18 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.8× speedup?

\[\begin{array}{l} \\ \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666 + \left(0.2 \cdot x\right) \cdot x, 2\right)\right)\right| \end{array} \]
(FPCore (x)
 :precision binary64
 (fabs
  (*
   (/ 1.0 (sqrt PI))
   (fma
    (pow (fabs x) 7.0)
    0.047619047619047616
    (* (fabs x) (fma (* x x) (+ 0.6666666666666666 (* (* 0.2 x) x)) 2.0))))))
double code(double x) {
	return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, (fabs(x) * fma((x * x), (0.6666666666666666 + ((0.2 * x) * x)), 2.0)))));
}
function code(x)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, Float64(abs(x) * fma(Float64(x * x), Float64(0.6666666666666666 + Float64(Float64(0.2 * x) * x)), 2.0)))))
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[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(0.6666666666666666 + N[(N[(0.2 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + 2.0), $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, \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666 + \left(0.2 \cdot x\right) \cdot x, 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. Applied rewrites99.8%

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

Alternative 2: 99.8% accurate, 2.3× speedup?

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

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

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

Alternative 3: 99.4% accurate, 2.6× speedup?

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

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

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


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

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

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

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

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

    if 2.64999999999999991 < 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.8%

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

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

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

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

Alternative 4: 99.4% accurate, 2.7× speedup?

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

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

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

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

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

Alternative 5: 98.6% accurate, 2.8× speedup?

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

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

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

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

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

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

Alternative 6: 98.5% accurate, 2.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\left(0.047619047619047616 \cdot \frac{{x}^{6}}{\sqrt{\pi}}\right) \cdot \left|x\right|\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.8%

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

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

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{\frac{2}{3} \cdot x}, 2\right)\right) \cdot \left|x\right|\right| \]
    5. Applied rewrites89.5%

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{0.6666666666666666 \cdot x}, 2\right)\right) \cdot \left|x\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.8%

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

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

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

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

Alternative 7: 93.5% accurate, 2.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\left(0.047619047619047616 \cdot {x}^{6}\right) \cdot \frac{\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.8%

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

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

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{\frac{2}{3} \cdot x}, 2\right)\right) \cdot \left|x\right|\right| \]
    5. Applied rewrites89.5%

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{0.6666666666666666 \cdot x}, 2\right)\right) \cdot \left|x\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.8%

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

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

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

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

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

Alternative 8: 93.1% accurate, 2.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\left|x\right| \cdot \left(\frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}{\sqrt{\pi}} \cdot 0.047619047619047616\right)\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.8%

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

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

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{\frac{2}{3} \cdot x}, 2\right)\right) \cdot \left|x\right|\right| \]
    5. Applied rewrites89.5%

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{0.6666666666666666 \cdot x}, 2\right)\right) \cdot \left|x\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.8%

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

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

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

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

Alternative 9: 91.4% accurate, 2.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\left(\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \cdot 0.047619047619047616\right) \cdot \frac{\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.8%

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

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

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{\frac{2}{3} \cdot x}, 2\right)\right) \cdot \left|x\right|\right| \]
    5. Applied rewrites89.5%

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{0.6666666666666666 \cdot x}, 2\right)\right) \cdot \left|x\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.8%

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

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

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

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

Alternative 10: 89.5% accurate, 2.8× speedup?

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

\\
\left|\frac{\mathsf{fma}\left(42, \left|x\right|, {\left(\left|x\right|\right)}^{7}\right)}{\sqrt{\pi} \cdot 21}\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.7%

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

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

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

Alternative 11: 89.5% accurate, 2.8× speedup?

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

\\
\left|0.047619047619047616 \cdot \frac{\mathsf{fma}\left(42, \left|x\right|, {\left(\left|x\right|\right)}^{7}\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.7%

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

    \[\leadsto \left|\color{blue}{\frac{1}{21} \cdot \frac{42 \cdot \left|x\right| + {\left(\left|x\right|\right)}^{7}}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
  4. Applied rewrites98.5%

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

Alternative 12: 89.5% accurate, 3.5× speedup?

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

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

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

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

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

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

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

Alternative 13: 89.5% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, 0.6666666666666666 \cdot x, 2\right)\right) \cdot \left|x\right|\right|\\ \mathbf{else}:\\ \;\;\;\;\left|2 \cdot \sqrt{\frac{\sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{\pi}}\right|\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.15e+77)
   (fabs
    (* (* (/ 1.0 (sqrt PI)) (fma x (* 0.6666666666666666 x) 2.0)) (fabs x)))
   (fabs (* 2.0 (sqrt (/ (sqrt (* (* x x) (* x x))) PI))))))
double code(double x) {
	double tmp;
	if (x <= 1.15e+77) {
		tmp = fabs((((1.0 / sqrt(((double) M_PI))) * fma(x, (0.6666666666666666 * x), 2.0)) * fabs(x)));
	} else {
		tmp = fabs((2.0 * sqrt((sqrt(((x * x) * (x * x))) / ((double) M_PI)))));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 1.15e+77)
		tmp = abs(Float64(Float64(Float64(1.0 / sqrt(pi)) * fma(x, Float64(0.6666666666666666 * x), 2.0)) * abs(x)));
	else
		tmp = abs(Float64(2.0 * sqrt(Float64(sqrt(Float64(Float64(x * x) * Float64(x * x))) / pi))));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 1.15e+77], N[Abs[N[(N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(x * N[(0.6666666666666666 * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(2.0 * N[Sqrt[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, 0.6666666666666666 \cdot x, 2\right)\right) \cdot \left|x\right|\right|\\

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


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

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

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

      \[\leadsto \left|\left(\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(x, \color{blue}{\frac{2}{3} \cdot x}, 2\right)\right) \cdot \left|x\right|\right| \]
    5. Applied rewrites89.5%

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

    if 1.14999999999999997e77 < 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.8%

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

      \[\leadsto \left|\color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
    4. Applied rewrites67.3%

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

      \[\leadsto \left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right| \]
    6. Applied rewrites44.3%

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

Alternative 14: 89.5% 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 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\ \mathbf{if}\;\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| \leq 4 \cdot 10^{-9}:\\ \;\;\;\;\left|\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\right|\\ \mathbf{else}:\\ \;\;\;\;\left|2 \cdot \sqrt{\frac{\sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{\pi}}\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))))
   (if (<=
        (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))))))
        4e-9)
     (fabs (* (/ 2.0 (sqrt PI)) (fabs x)))
     (fabs (* 2.0 (sqrt (/ (sqrt (* (* x x) (* x x))) PI)))))))
double code(double x) {
	double t_0 = (fabs(x) * fabs(x)) * fabs(x);
	double t_1 = (t_0 * fabs(x)) * fabs(x);
	double tmp;
	if (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)))))) <= 4e-9) {
		tmp = fabs(((2.0 / sqrt(((double) M_PI))) * fabs(x)));
	} else {
		tmp = fabs((2.0 * sqrt((sqrt(((x * x) * (x * x))) / ((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 = (t_0 * Math.abs(x)) * Math.abs(x);
	double tmp;
	if (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)))))) <= 4e-9) {
		tmp = Math.abs(((2.0 / Math.sqrt(Math.PI)) * Math.abs(x)));
	} else {
		tmp = Math.abs((2.0 * Math.sqrt((Math.sqrt(((x * x) * (x * x))) / Math.PI))));
	}
	return tmp;
}
def code(x):
	t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x)
	t_1 = (t_0 * math.fabs(x)) * math.fabs(x)
	tmp = 0
	if 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)))))) <= 4e-9:
		tmp = math.fabs(((2.0 / math.sqrt(math.pi)) * math.fabs(x)))
	else:
		tmp = math.fabs((2.0 * math.sqrt((math.sqrt(((x * x) * (x * x))) / math.pi))))
	return tmp
function code(x)
	t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x))
	t_1 = Float64(Float64(t_0 * abs(x)) * abs(x))
	tmp = 0.0
	if (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)))))) <= 4e-9)
		tmp = abs(Float64(Float64(2.0 / sqrt(pi)) * abs(x)));
	else
		tmp = abs(Float64(2.0 * sqrt(Float64(sqrt(Float64(Float64(x * x) * Float64(x * x))) / pi))));
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = (abs(x) * abs(x)) * abs(x);
	t_1 = (t_0 * abs(x)) * abs(x);
	tmp = 0.0;
	if (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)))))) <= 4e-9)
		tmp = abs(((2.0 / sqrt(pi)) * abs(x)));
	else
		tmp = abs((2.0 * sqrt((sqrt(((x * x) * (x * x))) / 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[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], 4e-9], N[Abs[N[(N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(2.0 * N[Sqrt[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $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|\\
\mathbf{if}\;\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| \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\left|\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\right|\\

\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \sqrt{\frac{\sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{\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)))))) < 4.00000000000000025e-9

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

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

      \[\leadsto \left|\color{blue}{\frac{2}{\sqrt{\mathsf{PI}\left(\right)}}} \cdot \left|x\right|\right| \]
    5. Applied rewrites67.8%

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

    if 4.00000000000000025e-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.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}{\left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot 0.047619047619047616\right), \mathsf{fma}\left(x \cdot 0.6666666666666666, x, 2\right)\right)\right)}\right| \]
    3. Taylor expanded in x around 0

      \[\leadsto \left|\color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
    4. Applied rewrites67.3%

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

      \[\leadsto \left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right| \]
    6. Applied rewrites44.3%

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

Alternative 15: 89.0% accurate, 4.9× speedup?

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

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

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

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

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

    \[\leadsto \left|\mathsf{fma}\left(x, x \cdot \color{blue}{\frac{2}{3}}, 2\right) \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right| \]
  6. Applied rewrites89.0%

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

Alternative 16: 67.8% accurate, 5.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\left|\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.00000000000000025e-9

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

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

      \[\leadsto \left|\color{blue}{\frac{2}{\sqrt{\mathsf{PI}\left(\right)}}} \cdot \left|x\right|\right| \]
    5. Applied rewrites67.8%

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

    if 4.00000000000000025e-9 < 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.8%

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

      \[\leadsto \left|\color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
    4. Applied rewrites67.3%

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

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

Alternative 17: 67.8% accurate, 8.3× speedup?

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

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

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

    \[\leadsto \left|\color{blue}{\frac{2}{\sqrt{\mathsf{PI}\left(\right)}}} \cdot \left|x\right|\right| \]
  5. Applied rewrites67.8%

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

Alternative 18: 67.3% accurate, 8.3× speedup?

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

\\
\left|2 \cdot \frac{\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.8%

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

    \[\leadsto \left|\color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
  4. Applied rewrites67.3%

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

Reproduce

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