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

Percentage Accurate: 99.8% → 99.9%
Time: 13.6s
Alternatives: 11
Speedup: 3.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.9% accurate, 3.6× speedup?

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

\\
\left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \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. Simplified99.4%

    \[\leadsto \color{blue}{\left|\frac{\left|x\right|}{\sqrt{\pi}} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. div-inv99.9%

      \[\leadsto \left|\color{blue}{\left(\left|x\right| \cdot \frac{1}{\sqrt{\pi}}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    2. inv-pow99.9%

      \[\leadsto \left|\left(\left|x\right| \cdot \color{blue}{{\left(\sqrt{\pi}\right)}^{-1}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    3. sqrt-pow299.9%

      \[\leadsto \left|\left(\left|x\right| \cdot \color{blue}{{\pi}^{\left(\frac{-1}{2}\right)}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    4. metadata-eval99.9%

      \[\leadsto \left|\left(\left|x\right| \cdot {\pi}^{\color{blue}{-0.5}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  5. Applied egg-rr99.9%

    \[\leadsto \left|\color{blue}{\left(\left|x\right| \cdot {\pi}^{-0.5}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  6. Step-by-step derivation
    1. unpow199.9%

      \[\leadsto \left|\left(\left|\color{blue}{{x}^{1}}\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    2. sqr-pow32.2%

      \[\leadsto \left|\left(\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    3. fabs-sqr32.2%

      \[\leadsto \left|\left(\color{blue}{\left({x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}\right)} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    4. sqr-pow99.9%

      \[\leadsto \left|\left(\color{blue}{{x}^{1}} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    5. unpow199.9%

      \[\leadsto \left|\left(\color{blue}{x} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  7. Simplified99.9%

    \[\leadsto \left|\color{blue}{\left(x \cdot {\pi}^{-0.5}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  8. Step-by-step derivation
    1. fma-udef99.9%

      \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  9. Applied egg-rr99.9%

    \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  10. Final simplification99.9%

    \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  11. Add Preprocessing

Alternative 2: 67.5% accurate, 3.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + t\_0\right)\right|\\


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

    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. Simplified99.2%

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

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

      \[\leadsto \color{blue}{\frac{\left|x\right|}{\left|\sqrt{\pi} \cdot \frac{1}{0.2 \cdot {x}^{4} + \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)}\right|}} \]
    6. Step-by-step derivation
      1. fabs-neg99.1%

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

        \[\leadsto \frac{\left|-x\right|}{\left|\sqrt{\pi} \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      3. associate-*r/99.1%

        \[\leadsto \frac{\left|-x\right|}{\left|\color{blue}{\frac{\sqrt{\pi} \cdot 1}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      4. *-rgt-identity99.1%

        \[\leadsto \frac{\left|-x\right|}{\left|\frac{\color{blue}{\sqrt{\pi}}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}\right|} \]
      5. fabs-div99.1%

        \[\leadsto \color{blue}{\left|\frac{-x}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      6. distribute-frac-neg99.1%

        \[\leadsto \left|\color{blue}{-\frac{x}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}}\right| \]
      7. fabs-neg99.1%

        \[\leadsto \color{blue}{\left|\frac{x}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      8. associate-/l*99.1%

        \[\leadsto \left|\color{blue}{\frac{x \cdot \mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}{\sqrt{\pi}}}\right| \]
      9. associate-*r/99.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}{\sqrt{\pi}}}\right| \]
      10. rem-square-sqrt48.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}{\sqrt{\pi}}} \]
    8. Step-by-step derivation
      1. fma-udef50.7%

        \[\leadsto x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, \color{blue}{0.6666666666666666 \cdot {x}^{2} + 2}\right)}{\sqrt{\pi}} \]
    9. Applied egg-rr50.7%

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

    if 0.0200000000000000004 < (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. Simplified99.9%

      \[\leadsto \color{blue}{\left|\frac{\left|x\right|}{\sqrt{\pi}} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. div-inv99.9%

        \[\leadsto \left|\color{blue}{\left(\left|x\right| \cdot \frac{1}{\sqrt{\pi}}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      2. inv-pow99.9%

        \[\leadsto \left|\left(\left|x\right| \cdot \color{blue}{{\left(\sqrt{\pi}\right)}^{-1}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      3. sqrt-pow299.9%

        \[\leadsto \left|\left(\left|x\right| \cdot \color{blue}{{\pi}^{\left(\frac{-1}{2}\right)}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      4. metadata-eval99.9%

        \[\leadsto \left|\left(\left|x\right| \cdot {\pi}^{\color{blue}{-0.5}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    5. Applied egg-rr99.9%

      \[\leadsto \left|\color{blue}{\left(\left|x\right| \cdot {\pi}^{-0.5}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    6. Step-by-step derivation
      1. unpow199.9%

        \[\leadsto \left|\left(\left|\color{blue}{{x}^{1}}\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      2. sqr-pow0.0%

        \[\leadsto \left|\left(\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      3. fabs-sqr0.0%

        \[\leadsto \left|\left(\color{blue}{\left({x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}\right)} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      4. sqr-pow99.9%

        \[\leadsto \left|\left(\color{blue}{{x}^{1}} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
      5. unpow199.9%

        \[\leadsto \left|\left(\color{blue}{x} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    7. Simplified99.9%

      \[\leadsto \left|\color{blue}{\left(x \cdot {\pi}^{-0.5}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    8. Step-by-step derivation
      1. fma-udef99.9%

        \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    9. Applied egg-rr99.9%

      \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    10. Taylor expanded in x around inf 99.9%

      \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \color{blue}{0.6666666666666666 \cdot {x}^{2}}\right)\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.02:\\ \;\;\;\;x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, 2 + 0.6666666666666666 \cdot {x}^{2}\right)}{\sqrt{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + 0.6666666666666666 \cdot {x}^{2}\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.4% accurate, 3.6× speedup?

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

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

    \[\leadsto \color{blue}{\left|\frac{\left|x\right|}{\sqrt{\pi}} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. div-inv99.9%

      \[\leadsto \left|\color{blue}{\left(\left|x\right| \cdot \frac{1}{\sqrt{\pi}}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    2. inv-pow99.9%

      \[\leadsto \left|\left(\left|x\right| \cdot \color{blue}{{\left(\sqrt{\pi}\right)}^{-1}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    3. sqrt-pow299.9%

      \[\leadsto \left|\left(\left|x\right| \cdot \color{blue}{{\pi}^{\left(\frac{-1}{2}\right)}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    4. metadata-eval99.9%

      \[\leadsto \left|\left(\left|x\right| \cdot {\pi}^{\color{blue}{-0.5}}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  5. Applied egg-rr99.9%

    \[\leadsto \left|\color{blue}{\left(\left|x\right| \cdot {\pi}^{-0.5}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  6. Step-by-step derivation
    1. unpow199.9%

      \[\leadsto \left|\left(\left|\color{blue}{{x}^{1}}\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    2. sqr-pow32.2%

      \[\leadsto \left|\left(\left|\color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    3. fabs-sqr32.2%

      \[\leadsto \left|\left(\color{blue}{\left({x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}\right)} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    4. sqr-pow99.9%

      \[\leadsto \left|\left(\color{blue}{{x}^{1}} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    5. unpow199.9%

      \[\leadsto \left|\left(\color{blue}{x} \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  7. Simplified99.9%

    \[\leadsto \left|\color{blue}{\left(x \cdot {\pi}^{-0.5}\right)} \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  8. Step-by-step derivation
    1. fma-udef99.9%

      \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  9. Applied egg-rr99.9%

    \[\leadsto \left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  10. Step-by-step derivation
    1. metadata-eval99.9%

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

      \[\leadsto \left|\left(x \cdot \color{blue}{\sqrt{{\pi}^{-1}}}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    3. inv-pow99.9%

      \[\leadsto \left|\left(x \cdot \sqrt{\color{blue}{\frac{1}{\pi}}}\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    4. expm1-log1p-u66.3%

      \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \sqrt{\frac{1}{\pi}}\right)\right)} \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    5. expm1-udef5.0%

      \[\leadsto \left|\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \sqrt{\frac{1}{\pi}}\right)} - 1\right)} \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    6. sqrt-div5.0%

      \[\leadsto \left|\left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\pi}}}\right)} - 1\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    7. metadata-eval5.0%

      \[\leadsto \left|\left(e^{\mathsf{log1p}\left(x \cdot \frac{\color{blue}{1}}{\sqrt{\pi}}\right)} - 1\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    8. un-div-inv5.0%

      \[\leadsto \left|\left(e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\sqrt{\pi}}}\right)} - 1\right) \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  11. Applied egg-rr5.0%

    \[\leadsto \left|\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x}{\sqrt{\pi}}\right)} - 1\right)} \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  12. Step-by-step derivation
    1. expm1-def65.9%

      \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{\sqrt{\pi}}\right)\right)} \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
    2. expm1-log1p99.4%

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

    \[\leadsto \left|\color{blue}{\frac{x}{\sqrt{\pi}}} \cdot \left(\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right| \]
  14. Final simplification99.4%

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

Alternative 4: 67.4% accurate, 3.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\frac{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|\\


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

    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. Simplified99.2%

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

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

      \[\leadsto \color{blue}{\frac{\left|x\right|}{\left|\sqrt{\pi} \cdot \frac{1}{0.2 \cdot {x}^{4} + \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)}\right|}} \]
    6. Step-by-step derivation
      1. fabs-neg99.1%

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

        \[\leadsto \frac{\left|-x\right|}{\left|\sqrt{\pi} \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      3. associate-*r/99.1%

        \[\leadsto \frac{\left|-x\right|}{\left|\color{blue}{\frac{\sqrt{\pi} \cdot 1}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      4. *-rgt-identity99.1%

        \[\leadsto \frac{\left|-x\right|}{\left|\frac{\color{blue}{\sqrt{\pi}}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}\right|} \]
      5. fabs-div99.1%

        \[\leadsto \color{blue}{\left|\frac{-x}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      6. distribute-frac-neg99.1%

        \[\leadsto \left|\color{blue}{-\frac{x}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}}\right| \]
      7. fabs-neg99.1%

        \[\leadsto \color{blue}{\left|\frac{x}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}}\right|} \]
      8. associate-/l*99.1%

        \[\leadsto \left|\color{blue}{\frac{x \cdot \mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}{\sqrt{\pi}}}\right| \]
      9. associate-*r/99.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}{\sqrt{\pi}}}\right| \]
      10. rem-square-sqrt48.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)}{\sqrt{\pi}}} \]
    8. Step-by-step derivation
      1. fma-udef50.7%

        \[\leadsto x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, \color{blue}{0.6666666666666666 \cdot {x}^{2} + 2}\right)}{\sqrt{\pi}} \]
    9. Applied egg-rr50.7%

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

    if 0.0200000000000000004 < (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. Simplified99.8%

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

      \[\leadsto \left|\color{blue}{0.047619047619047616 \cdot \left(\left({x}^{6} \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\pi}}\right) + 0.2 \cdot \left(\left({x}^{4} \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\pi}}\right)}\right| \]
    5. Simplified99.7%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right)}\right| \]
    6. Step-by-step derivation
      1. expm1-log1p-u0.0%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{1}{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right)\right)\right)}\right| \]
      2. expm1-udef0.0%

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{1}{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right)\right)} - 1}\right| \]
      3. *-commutative0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right) \cdot \sqrt{\frac{1}{\pi}}}\right)} - 1\right| \]
      4. sqrt-div0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right) \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\pi}}}\right)} - 1\right| \]
      5. metadata-eval0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right) \cdot \frac{\color{blue}{1}}{\sqrt{\pi}}\right)} - 1\right| \]
      6. un-div-inv0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}}{\sqrt{\pi}}}\right)} - 1\right| \]
      7. +-commutative0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}}{\sqrt{\pi}}\right)} - 1\right| \]
      8. fma-def0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}}{\sqrt{\pi}}\right)} - 1\right| \]
    7. Applied egg-rr0.0%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}\right)} - 1}\right| \]
    8. Step-by-step derivation
      1. expm1-def0.0%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}\right)\right)}\right| \]
      2. expm1-log1p99.8%

        \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}}\right| \]
    9. Simplified99.8%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}}\right| \]
    10. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \left|\frac{\color{blue}{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}}{\sqrt{\pi}}\right| \]
    11. Applied egg-rr99.8%

      \[\leadsto \left|\frac{\color{blue}{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}}{\sqrt{\pi}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.02:\\ \;\;\;\;x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, 2 + 0.6666666666666666 \cdot {x}^{2}\right)}{\sqrt{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 67.4% accurate, 3.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.02:\\
\;\;\;\;{\pi}^{-0.5} \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|\\


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

    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. Simplified99.2%

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

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{-0.16666666666666666 \cdot \left({x}^{2} \cdot \sqrt{\pi}\right) + 0.5 \cdot \sqrt{\pi}}\right|} \]
    5. Step-by-step derivation
      1. +-commutative98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{0.5 \cdot \sqrt{\pi} + -0.16666666666666666 \cdot \left({x}^{2} \cdot \sqrt{\pi}\right)}\right|} \]
      2. associate-*r*98.8%

        \[\leadsto \frac{\left|x\right|}{\left|0.5 \cdot \sqrt{\pi} + \color{blue}{\left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot \sqrt{\pi}}\right|} \]
      3. distribute-rgt-out98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{\sqrt{\pi} \cdot \left(0.5 + -0.16666666666666666 \cdot {x}^{2}\right)}\right|} \]
      4. *-commutative98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\sqrt{\pi} \cdot \left(0.5 + \color{blue}{{x}^{2} \cdot -0.16666666666666666}\right)\right|} \]
    6. Simplified98.8%

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}\right|} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt48.3%

        \[\leadsto \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      2. fabs-sqr48.3%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      3. add-sqr-sqrt50.4%

        \[\leadsto \frac{\color{blue}{x}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      4. *-un-lft-identity50.4%

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      5. add-sqr-sqrt50.5%

        \[\leadsto \frac{1 \cdot x}{\left|\color{blue}{\sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)} \cdot \sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}}\right|} \]
      6. fabs-sqr50.5%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)} \cdot \sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}}} \]
      7. add-sqr-sqrt50.4%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}} \]
      8. times-frac50.7%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666}} \]
      9. pow1/250.7%

        \[\leadsto \frac{1}{\color{blue}{{\pi}^{0.5}}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      10. pow-flip50.7%

        \[\leadsto \color{blue}{{\pi}^{\left(-0.5\right)}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      11. metadata-eval50.7%

        \[\leadsto {\pi}^{\color{blue}{-0.5}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      12. +-commutative50.7%

        \[\leadsto {\pi}^{-0.5} \cdot \frac{x}{\color{blue}{{x}^{2} \cdot -0.16666666666666666 + 0.5}} \]
      13. fma-def50.7%

        \[\leadsto {\pi}^{-0.5} \cdot \frac{x}{\color{blue}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}} \]
    8. Applied egg-rr50.7%

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

    if 0.0200000000000000004 < (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. Simplified99.8%

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

      \[\leadsto \left|\color{blue}{0.047619047619047616 \cdot \left(\left({x}^{6} \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\pi}}\right) + 0.2 \cdot \left(\left({x}^{4} \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\pi}}\right)}\right| \]
    5. Simplified99.7%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right)}\right| \]
    6. Step-by-step derivation
      1. expm1-log1p-u0.0%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{1}{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right)\right)\right)}\right| \]
      2. expm1-udef0.0%

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{1}{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right)\right)} - 1}\right| \]
      3. *-commutative0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right) \cdot \sqrt{\frac{1}{\pi}}}\right)} - 1\right| \]
      4. sqrt-div0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right) \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\pi}}}\right)} - 1\right| \]
      5. metadata-eval0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\left(0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}\right) \cdot \frac{\color{blue}{1}}{\sqrt{\pi}}\right)} - 1\right| \]
      6. un-div-inv0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}}{\sqrt{\pi}}}\right)} - 1\right| \]
      7. +-commutative0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}}{\sqrt{\pi}}\right)} - 1\right| \]
      8. fma-def0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}}{\sqrt{\pi}}\right)} - 1\right| \]
    7. Applied egg-rr0.0%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}\right)} - 1}\right| \]
    8. Step-by-step derivation
      1. expm1-def0.0%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}\right)\right)}\right| \]
      2. expm1-log1p99.8%

        \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}}\right| \]
    9. Simplified99.8%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(0.2, {x}^{5}, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}}\right| \]
    10. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \left|\frac{\color{blue}{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}}{\sqrt{\pi}}\right| \]
    11. Applied egg-rr99.8%

      \[\leadsto \left|\frac{\color{blue}{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}}{\sqrt{\pi}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.02:\\ \;\;\;\;{\pi}^{-0.5} \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 34.3% accurate, 4.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.02:\\
\;\;\;\;{\pi}^{-0.5} \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}\right) \cdot \sqrt{\frac{1}{\pi}}\\


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

    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. Simplified99.2%

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

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{-0.16666666666666666 \cdot \left({x}^{2} \cdot \sqrt{\pi}\right) + 0.5 \cdot \sqrt{\pi}}\right|} \]
    5. Step-by-step derivation
      1. +-commutative98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{0.5 \cdot \sqrt{\pi} + -0.16666666666666666 \cdot \left({x}^{2} \cdot \sqrt{\pi}\right)}\right|} \]
      2. associate-*r*98.8%

        \[\leadsto \frac{\left|x\right|}{\left|0.5 \cdot \sqrt{\pi} + \color{blue}{\left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot \sqrt{\pi}}\right|} \]
      3. distribute-rgt-out98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{\sqrt{\pi} \cdot \left(0.5 + -0.16666666666666666 \cdot {x}^{2}\right)}\right|} \]
      4. *-commutative98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\sqrt{\pi} \cdot \left(0.5 + \color{blue}{{x}^{2} \cdot -0.16666666666666666}\right)\right|} \]
    6. Simplified98.8%

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}\right|} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt48.3%

        \[\leadsto \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      2. fabs-sqr48.3%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      3. add-sqr-sqrt50.4%

        \[\leadsto \frac{\color{blue}{x}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      4. *-un-lft-identity50.4%

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      5. add-sqr-sqrt50.5%

        \[\leadsto \frac{1 \cdot x}{\left|\color{blue}{\sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)} \cdot \sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}}\right|} \]
      6. fabs-sqr50.5%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)} \cdot \sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}}} \]
      7. add-sqr-sqrt50.4%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}} \]
      8. times-frac50.7%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666}} \]
      9. pow1/250.7%

        \[\leadsto \frac{1}{\color{blue}{{\pi}^{0.5}}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      10. pow-flip50.7%

        \[\leadsto \color{blue}{{\pi}^{\left(-0.5\right)}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      11. metadata-eval50.7%

        \[\leadsto {\pi}^{\color{blue}{-0.5}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      12. +-commutative50.7%

        \[\leadsto {\pi}^{-0.5} \cdot \frac{x}{\color{blue}{{x}^{2} \cdot -0.16666666666666666 + 0.5}} \]
      13. fma-def50.7%

        \[\leadsto {\pi}^{-0.5} \cdot \frac{x}{\color{blue}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}} \]
    8. Applied egg-rr50.7%

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

    if 0.0200000000000000004 < (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. Simplified99.9%

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

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

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

      \[\leadsto \color{blue}{0.047619047619047616 \cdot \left({x}^{7} \cdot \sqrt{\frac{1}{\pi}}\right) + 0.2 \cdot \left({x}^{5} \cdot \sqrt{\frac{1}{\pi}}\right)} \]
    7. Step-by-step derivation
      1. +-commutative0.1%

        \[\leadsto \color{blue}{0.2 \cdot \left({x}^{5} \cdot \sqrt{\frac{1}{\pi}}\right) + 0.047619047619047616 \cdot \left({x}^{7} \cdot \sqrt{\frac{1}{\pi}}\right)} \]
      2. associate-*r*0.1%

        \[\leadsto \color{blue}{\left(0.2 \cdot {x}^{5}\right) \cdot \sqrt{\frac{1}{\pi}}} + 0.047619047619047616 \cdot \left({x}^{7} \cdot \sqrt{\frac{1}{\pi}}\right) \]
      3. associate-*r*0.1%

        \[\leadsto \left(0.2 \cdot {x}^{5}\right) \cdot \sqrt{\frac{1}{\pi}} + \color{blue}{\left(0.047619047619047616 \cdot {x}^{7}\right) \cdot \sqrt{\frac{1}{\pi}}} \]
      4. *-commutative0.1%

        \[\leadsto \left(0.2 \cdot {x}^{5}\right) \cdot \sqrt{\frac{1}{\pi}} + \color{blue}{\left({x}^{7} \cdot 0.047619047619047616\right)} \cdot \sqrt{\frac{1}{\pi}} \]
      5. distribute-rgt-out0.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(0.2 \cdot {x}^{5} + {x}^{7} \cdot 0.047619047619047616\right)} \]
      6. *-commutative0.1%

        \[\leadsto \sqrt{\frac{1}{\pi}} \cdot \left(0.2 \cdot {x}^{5} + \color{blue}{0.047619047619047616 \cdot {x}^{7}}\right) \]
    8. Simplified0.1%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.02:\\ \;\;\;\;{\pi}^{-0.5} \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}\right) \cdot \sqrt{\frac{1}{\pi}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 34.3% accurate, 4.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.02:\\
\;\;\;\;{\pi}^{-0.5} \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\

\mathbf{else}:\\
\;\;\;\;0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\\


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

    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. Simplified99.2%

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

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{-0.16666666666666666 \cdot \left({x}^{2} \cdot \sqrt{\pi}\right) + 0.5 \cdot \sqrt{\pi}}\right|} \]
    5. Step-by-step derivation
      1. +-commutative98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{0.5 \cdot \sqrt{\pi} + -0.16666666666666666 \cdot \left({x}^{2} \cdot \sqrt{\pi}\right)}\right|} \]
      2. associate-*r*98.8%

        \[\leadsto \frac{\left|x\right|}{\left|0.5 \cdot \sqrt{\pi} + \color{blue}{\left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot \sqrt{\pi}}\right|} \]
      3. distribute-rgt-out98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{\sqrt{\pi} \cdot \left(0.5 + -0.16666666666666666 \cdot {x}^{2}\right)}\right|} \]
      4. *-commutative98.8%

        \[\leadsto \frac{\left|x\right|}{\left|\sqrt{\pi} \cdot \left(0.5 + \color{blue}{{x}^{2} \cdot -0.16666666666666666}\right)\right|} \]
    6. Simplified98.8%

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}\right|} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt48.3%

        \[\leadsto \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      2. fabs-sqr48.3%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      3. add-sqr-sqrt50.4%

        \[\leadsto \frac{\color{blue}{x}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      4. *-un-lft-identity50.4%

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{\left|\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)\right|} \]
      5. add-sqr-sqrt50.5%

        \[\leadsto \frac{1 \cdot x}{\left|\color{blue}{\sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)} \cdot \sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}}\right|} \]
      6. fabs-sqr50.5%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)} \cdot \sqrt{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}}} \]
      7. add-sqr-sqrt50.4%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\sqrt{\pi} \cdot \left(0.5 + {x}^{2} \cdot -0.16666666666666666\right)}} \]
      8. times-frac50.7%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666}} \]
      9. pow1/250.7%

        \[\leadsto \frac{1}{\color{blue}{{\pi}^{0.5}}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      10. pow-flip50.7%

        \[\leadsto \color{blue}{{\pi}^{\left(-0.5\right)}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      11. metadata-eval50.7%

        \[\leadsto {\pi}^{\color{blue}{-0.5}} \cdot \frac{x}{0.5 + {x}^{2} \cdot -0.16666666666666666} \]
      12. +-commutative50.7%

        \[\leadsto {\pi}^{-0.5} \cdot \frac{x}{\color{blue}{{x}^{2} \cdot -0.16666666666666666 + 0.5}} \]
      13. fma-def50.7%

        \[\leadsto {\pi}^{-0.5} \cdot \frac{x}{\color{blue}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}} \]
    8. Applied egg-rr50.7%

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

    if 0.0200000000000000004 < (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. Simplified99.9%

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

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \left(\frac{1}{{x}^{6}} \cdot \sqrt{\pi}\right)}\right|} \]
    5. Step-by-step derivation
      1. associate-*l/98.8%

        \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \color{blue}{\frac{1 \cdot \sqrt{\pi}}{{x}^{6}}}\right|} \]
      2. *-lft-identity98.8%

        \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \frac{\color{blue}{\sqrt{\pi}}}{{x}^{6}}\right|} \]
    6. Simplified98.8%

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}}\right|} \]
    7. Step-by-step derivation
      1. expm1-log1p-u97.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)\right)} \]
      2. expm1-udef97.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)} - 1} \]
    8. Applied egg-rr0.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def0.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
      2. expm1-log1p0.1%

        \[\leadsto \color{blue}{0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
      3. *-commutative0.1%

        \[\leadsto \color{blue}{\frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot 0.047619047619047616} \]
      4. metadata-eval0.1%

        \[\leadsto \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot \color{blue}{\frac{1}{21}} \]
      5. times-frac0.1%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
      6. associate-*r/0.1%

        \[\leadsto \color{blue}{x \cdot \frac{1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
      7. *-commutative0.1%

        \[\leadsto x \cdot \frac{1}{\color{blue}{21 \cdot \sqrt{\frac{\pi}{{x}^{12}}}}} \]
      8. associate-/r*0.1%

        \[\leadsto x \cdot \color{blue}{\frac{\frac{1}{21}}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
      9. metadata-eval0.1%

        \[\leadsto x \cdot \frac{\color{blue}{0.047619047619047616}}{\sqrt{\frac{\pi}{{x}^{12}}}} \]
    10. Simplified0.1%

      \[\leadsto \color{blue}{x \cdot \frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u0.1%

        \[\leadsto x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
      2. expm1-udef0.1%

        \[\leadsto x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1\right)} \]
      3. sqrt-div0.1%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\color{blue}{\frac{\sqrt{\pi}}{\sqrt{{x}^{12}}}}}\right)} - 1\right) \]
      4. sqrt-pow10.1%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{\color{blue}{{x}^{\left(\frac{12}{2}\right)}}}}\right)} - 1\right) \]
      5. metadata-eval0.1%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{\color{blue}{6}}}}\right)} - 1\right) \]
    12. Applied egg-rr0.1%

      \[\leadsto x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)} - 1\right)} \]
    13. Step-by-step derivation
      1. expm1-def0.1%

        \[\leadsto x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)\right)} \]
      2. expm1-log1p0.1%

        \[\leadsto x \cdot \color{blue}{\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}} \]
      3. associate-/r/0.1%

        \[\leadsto x \cdot \color{blue}{\left(\frac{0.047619047619047616}{\sqrt{\pi}} \cdot {x}^{6}\right)} \]
      4. *-commutative0.1%

        \[\leadsto x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \]
    14. Simplified0.1%

      \[\leadsto x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \]
    15. Step-by-step derivation
      1. associate-*r*0.1%

        \[\leadsto \color{blue}{\left(x \cdot {x}^{6}\right) \cdot \frac{0.047619047619047616}{\sqrt{\pi}}} \]
      2. pow10.1%

        \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {x}^{6}\right) \cdot \frac{0.047619047619047616}{\sqrt{\pi}} \]
      3. pow-prod-up0.1%

        \[\leadsto \color{blue}{{x}^{\left(1 + 6\right)}} \cdot \frac{0.047619047619047616}{\sqrt{\pi}} \]
      4. metadata-eval0.1%

        \[\leadsto {x}^{\color{blue}{7}} \cdot \frac{0.047619047619047616}{\sqrt{\pi}} \]
      5. clear-num0.1%

        \[\leadsto {x}^{7} \cdot \color{blue}{\frac{1}{\frac{\sqrt{\pi}}{0.047619047619047616}}} \]
      6. un-div-inv0.1%

        \[\leadsto \color{blue}{\frac{{x}^{7}}{\frac{\sqrt{\pi}}{0.047619047619047616}}} \]
      7. div-inv0.1%

        \[\leadsto \frac{{x}^{7}}{\color{blue}{\sqrt{\pi} \cdot \frac{1}{0.047619047619047616}}} \]
      8. metadata-eval0.1%

        \[\leadsto \frac{{x}^{7}}{\sqrt{\pi} \cdot \color{blue}{21}} \]
    16. Applied egg-rr0.1%

      \[\leadsto \color{blue}{\frac{{x}^{7}}{\sqrt{\pi} \cdot 21}} \]
    17. Step-by-step derivation
      1. *-lft-identity0.1%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{7}}}{\sqrt{\pi} \cdot 21} \]
      2. *-commutative0.1%

        \[\leadsto \frac{1 \cdot {x}^{7}}{\color{blue}{21 \cdot \sqrt{\pi}}} \]
      3. times-frac0.1%

        \[\leadsto \color{blue}{\frac{1}{21} \cdot \frac{{x}^{7}}{\sqrt{\pi}}} \]
      4. metadata-eval0.1%

        \[\leadsto \color{blue}{0.047619047619047616} \cdot \frac{{x}^{7}}{\sqrt{\pi}} \]
    18. Simplified0.1%

      \[\leadsto \color{blue}{0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.02:\\ \;\;\;\;{\pi}^{-0.5} \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 34.2% accurate, 5.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\\


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

    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. Simplified99.2%

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left(x \cdot \sqrt{\frac{1}{\pi}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*50.7%

        \[\leadsto \color{blue}{\left(2 \cdot x\right) \cdot \sqrt{\frac{1}{\pi}}} \]
      2. *-commutative50.7%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot x\right)} \]
    8. Simplified50.7%

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

    if 0.0200000000000000004 < (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. Simplified99.9%

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

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \left(\frac{1}{{x}^{6}} \cdot \sqrt{\pi}\right)}\right|} \]
    5. Step-by-step derivation
      1. associate-*l/98.8%

        \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \color{blue}{\frac{1 \cdot \sqrt{\pi}}{{x}^{6}}}\right|} \]
      2. *-lft-identity98.8%

        \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \frac{\color{blue}{\sqrt{\pi}}}{{x}^{6}}\right|} \]
    6. Simplified98.8%

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}}\right|} \]
    7. Step-by-step derivation
      1. expm1-log1p-u97.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)\right)} \]
      2. expm1-udef97.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)} - 1} \]
    8. Applied egg-rr0.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def0.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
      2. expm1-log1p0.1%

        \[\leadsto \color{blue}{0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
      3. *-commutative0.1%

        \[\leadsto \color{blue}{\frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot 0.047619047619047616} \]
      4. metadata-eval0.1%

        \[\leadsto \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot \color{blue}{\frac{1}{21}} \]
      5. times-frac0.1%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
      6. associate-*r/0.1%

        \[\leadsto \color{blue}{x \cdot \frac{1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
      7. *-commutative0.1%

        \[\leadsto x \cdot \frac{1}{\color{blue}{21 \cdot \sqrt{\frac{\pi}{{x}^{12}}}}} \]
      8. associate-/r*0.1%

        \[\leadsto x \cdot \color{blue}{\frac{\frac{1}{21}}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
      9. metadata-eval0.1%

        \[\leadsto x \cdot \frac{\color{blue}{0.047619047619047616}}{\sqrt{\frac{\pi}{{x}^{12}}}} \]
    10. Simplified0.1%

      \[\leadsto \color{blue}{x \cdot \frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u0.1%

        \[\leadsto x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
      2. expm1-udef0.1%

        \[\leadsto x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1\right)} \]
      3. sqrt-div0.1%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\color{blue}{\frac{\sqrt{\pi}}{\sqrt{{x}^{12}}}}}\right)} - 1\right) \]
      4. sqrt-pow10.1%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{\color{blue}{{x}^{\left(\frac{12}{2}\right)}}}}\right)} - 1\right) \]
      5. metadata-eval0.1%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{\color{blue}{6}}}}\right)} - 1\right) \]
    12. Applied egg-rr0.1%

      \[\leadsto x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)} - 1\right)} \]
    13. Step-by-step derivation
      1. expm1-def0.1%

        \[\leadsto x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)\right)} \]
      2. expm1-log1p0.1%

        \[\leadsto x \cdot \color{blue}{\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}} \]
      3. associate-/r/0.1%

        \[\leadsto x \cdot \color{blue}{\left(\frac{0.047619047619047616}{\sqrt{\pi}} \cdot {x}^{6}\right)} \]
      4. *-commutative0.1%

        \[\leadsto x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \]
    14. Simplified0.1%

      \[\leadsto x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \]
    15. Step-by-step derivation
      1. associate-*r*0.1%

        \[\leadsto \color{blue}{\left(x \cdot {x}^{6}\right) \cdot \frac{0.047619047619047616}{\sqrt{\pi}}} \]
      2. pow10.1%

        \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {x}^{6}\right) \cdot \frac{0.047619047619047616}{\sqrt{\pi}} \]
      3. pow-prod-up0.1%

        \[\leadsto \color{blue}{{x}^{\left(1 + 6\right)}} \cdot \frac{0.047619047619047616}{\sqrt{\pi}} \]
      4. metadata-eval0.1%

        \[\leadsto {x}^{\color{blue}{7}} \cdot \frac{0.047619047619047616}{\sqrt{\pi}} \]
      5. clear-num0.1%

        \[\leadsto {x}^{7} \cdot \color{blue}{\frac{1}{\frac{\sqrt{\pi}}{0.047619047619047616}}} \]
      6. un-div-inv0.1%

        \[\leadsto \color{blue}{\frac{{x}^{7}}{\frac{\sqrt{\pi}}{0.047619047619047616}}} \]
      7. div-inv0.1%

        \[\leadsto \frac{{x}^{7}}{\color{blue}{\sqrt{\pi} \cdot \frac{1}{0.047619047619047616}}} \]
      8. metadata-eval0.1%

        \[\leadsto \frac{{x}^{7}}{\sqrt{\pi} \cdot \color{blue}{21}} \]
    16. Applied egg-rr0.1%

      \[\leadsto \color{blue}{\frac{{x}^{7}}{\sqrt{\pi} \cdot 21}} \]
    17. Step-by-step derivation
      1. *-lft-identity0.1%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{7}}}{\sqrt{\pi} \cdot 21} \]
      2. *-commutative0.1%

        \[\leadsto \frac{1 \cdot {x}^{7}}{\color{blue}{21 \cdot \sqrt{\pi}}} \]
      3. times-frac0.1%

        \[\leadsto \color{blue}{\frac{1}{21} \cdot \frac{{x}^{7}}{\sqrt{\pi}}} \]
      4. metadata-eval0.1%

        \[\leadsto \color{blue}{0.047619047619047616} \cdot \frac{{x}^{7}}{\sqrt{\pi}} \]
    18. Simplified0.1%

      \[\leadsto \color{blue}{0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.02:\\ \;\;\;\;\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 34.3% accurate, 8.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt{{x}^{14} \cdot \frac{0.0022675736961451248}{\pi}}\\


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

    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. Simplified99.4%

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left(x \cdot \sqrt{\frac{1}{\pi}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*33.8%

        \[\leadsto \color{blue}{\left(2 \cdot x\right) \cdot \sqrt{\frac{1}{\pi}}} \]
      2. *-commutative33.8%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot x\right)} \]
    8. Simplified33.8%

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

    if 1.8500000000000001 < 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. Simplified99.4%

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

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \left(\frac{1}{{x}^{6}} \cdot \sqrt{\pi}\right)}\right|} \]
    5. Step-by-step derivation
      1. associate-*l/37.0%

        \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \color{blue}{\frac{1 \cdot \sqrt{\pi}}{{x}^{6}}}\right|} \]
      2. *-lft-identity37.0%

        \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \frac{\color{blue}{\sqrt{\pi}}}{{x}^{6}}\right|} \]
    6. Simplified37.0%

      \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}}\right|} \]
    7. Step-by-step derivation
      1. expm1-log1p-u36.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)\right)} \]
      2. expm1-udef36.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)} - 1} \]
    8. Applied egg-rr3.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def3.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
      2. expm1-log1p3.6%

        \[\leadsto \color{blue}{0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
      3. *-commutative3.6%

        \[\leadsto \color{blue}{\frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot 0.047619047619047616} \]
      4. metadata-eval3.6%

        \[\leadsto \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot \color{blue}{\frac{1}{21}} \]
      5. times-frac3.6%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
      6. associate-*r/3.6%

        \[\leadsto \color{blue}{x \cdot \frac{1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
      7. *-commutative3.6%

        \[\leadsto x \cdot \frac{1}{\color{blue}{21 \cdot \sqrt{\frac{\pi}{{x}^{12}}}}} \]
      8. associate-/r*3.6%

        \[\leadsto x \cdot \color{blue}{\frac{\frac{1}{21}}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
      9. metadata-eval3.6%

        \[\leadsto x \cdot \frac{\color{blue}{0.047619047619047616}}{\sqrt{\frac{\pi}{{x}^{12}}}} \]
    10. Simplified3.6%

      \[\leadsto \color{blue}{x \cdot \frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u3.6%

        \[\leadsto x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
      2. expm1-udef3.6%

        \[\leadsto x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1\right)} \]
      3. sqrt-div3.6%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\color{blue}{\frac{\sqrt{\pi}}{\sqrt{{x}^{12}}}}}\right)} - 1\right) \]
      4. sqrt-pow13.6%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{\color{blue}{{x}^{\left(\frac{12}{2}\right)}}}}\right)} - 1\right) \]
      5. metadata-eval3.6%

        \[\leadsto x \cdot \left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{\color{blue}{6}}}}\right)} - 1\right) \]
    12. Applied egg-rr3.6%

      \[\leadsto x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)} - 1\right)} \]
    13. Step-by-step derivation
      1. expm1-def3.6%

        \[\leadsto x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)\right)} \]
      2. expm1-log1p3.6%

        \[\leadsto x \cdot \color{blue}{\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}} \]
      3. associate-/r/3.6%

        \[\leadsto x \cdot \color{blue}{\left(\frac{0.047619047619047616}{\sqrt{\pi}} \cdot {x}^{6}\right)} \]
      4. *-commutative3.6%

        \[\leadsto x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \]
    14. Simplified3.6%

      \[\leadsto x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \]
    15. Step-by-step derivation
      1. *-commutative3.6%

        \[\leadsto x \cdot \color{blue}{\left(\frac{0.047619047619047616}{\sqrt{\pi}} \cdot {x}^{6}\right)} \]
      2. associate-/r/3.6%

        \[\leadsto x \cdot \color{blue}{\frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}} \]
      3. add-sqr-sqrt3.4%

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}} \cdot \sqrt{x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}}} \]
      4. sqrt-unprod35.2%

        \[\leadsto \color{blue}{\sqrt{\left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right) \cdot \left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)}} \]
      5. associate-/r/35.2%

        \[\leadsto \sqrt{\left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right) \cdot \left(x \cdot \color{blue}{\left(\frac{0.047619047619047616}{\sqrt{\pi}} \cdot {x}^{6}\right)}\right)} \]
      6. *-commutative35.2%

        \[\leadsto \sqrt{\left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right) \cdot \left(x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)}\right)} \]
      7. associate-/r/35.2%

        \[\leadsto \sqrt{\left(x \cdot \color{blue}{\left(\frac{0.047619047619047616}{\sqrt{\pi}} \cdot {x}^{6}\right)}\right) \cdot \left(x \cdot \left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)\right)} \]
      8. *-commutative35.2%

        \[\leadsto \sqrt{\left(x \cdot \color{blue}{\left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)}\right) \cdot \left(x \cdot \left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)\right)} \]
      9. associate-*r*35.2%

        \[\leadsto \sqrt{\color{blue}{\left(\left(x \cdot {x}^{6}\right) \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)} \cdot \left(x \cdot \left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)\right)} \]
      10. pow135.2%

        \[\leadsto \sqrt{\left(\left(\color{blue}{{x}^{1}} \cdot {x}^{6}\right) \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right) \cdot \left(x \cdot \left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)\right)} \]
      11. pow-prod-up35.2%

        \[\leadsto \sqrt{\left(\color{blue}{{x}^{\left(1 + 6\right)}} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right) \cdot \left(x \cdot \left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)\right)} \]
      12. metadata-eval35.2%

        \[\leadsto \sqrt{\left({x}^{\color{blue}{7}} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right) \cdot \left(x \cdot \left({x}^{6} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right)\right)} \]
    16. Applied egg-rr35.2%

      \[\leadsto \color{blue}{\sqrt{{x}^{14} \cdot \frac{0.0022675736961451248}{\pi}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.85:\\ \;\;\;\;\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{x}^{14} \cdot \frac{0.0022675736961451248}{\pi}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 34.3% accurate, 17.3× speedup?

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

\\
\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2\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. Simplified99.4%

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

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

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

    \[\leadsto \color{blue}{2 \cdot \left(x \cdot \sqrt{\frac{1}{\pi}}\right)} \]
  7. Step-by-step derivation
    1. associate-*r*33.8%

      \[\leadsto \color{blue}{\left(2 \cdot x\right) \cdot \sqrt{\frac{1}{\pi}}} \]
    2. *-commutative33.8%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot x\right)} \]
  8. Simplified33.8%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot x\right)} \]
  9. Final simplification33.8%

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

Alternative 11: 4.1% accurate, 18.3× speedup?

\[\begin{array}{l} \\ \mathsf{expm1}\left(0\right) \end{array} \]
(FPCore (x) :precision binary64 (expm1 0.0))
double code(double x) {
	return expm1(0.0);
}
public static double code(double x) {
	return Math.expm1(0.0);
}
def code(x):
	return math.expm1(0.0)
function code(x)
	return expm1(0.0)
end
code[x_] := N[(Exp[0.0] - 1), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{expm1}\left(0\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. Simplified99.4%

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

    \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \left(\frac{1}{{x}^{6}} \cdot \sqrt{\pi}\right)}\right|} \]
  5. Step-by-step derivation
    1. associate-*l/37.0%

      \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \color{blue}{\frac{1 \cdot \sqrt{\pi}}{{x}^{6}}}\right|} \]
    2. *-lft-identity37.0%

      \[\leadsto \frac{\left|x\right|}{\left|21 \cdot \frac{\color{blue}{\sqrt{\pi}}}{{x}^{6}}\right|} \]
  6. Simplified37.0%

    \[\leadsto \frac{\left|x\right|}{\left|\color{blue}{21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}}\right|} \]
  7. Step-by-step derivation
    1. expm1-log1p-u36.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)\right)} \]
    2. expm1-udef36.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left|x\right|}{\left|21 \cdot \frac{\sqrt{\pi}}{{x}^{6}}\right|}\right)} - 1} \]
  8. Applied egg-rr3.6%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)} - 1} \]
  9. Step-by-step derivation
    1. expm1-def3.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
    2. expm1-log1p3.6%

      \[\leadsto \color{blue}{0.047619047619047616 \cdot \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
    3. *-commutative3.6%

      \[\leadsto \color{blue}{\frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot 0.047619047619047616} \]
    4. metadata-eval3.6%

      \[\leadsto \frac{x}{\sqrt{\frac{\pi}{{x}^{12}}}} \cdot \color{blue}{\frac{1}{21}} \]
    5. times-frac3.6%

      \[\leadsto \color{blue}{\frac{x \cdot 1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
    6. associate-*r/3.6%

      \[\leadsto \color{blue}{x \cdot \frac{1}{\sqrt{\frac{\pi}{{x}^{12}}} \cdot 21}} \]
    7. *-commutative3.6%

      \[\leadsto x \cdot \frac{1}{\color{blue}{21 \cdot \sqrt{\frac{\pi}{{x}^{12}}}}} \]
    8. associate-/r*3.6%

      \[\leadsto x \cdot \color{blue}{\frac{\frac{1}{21}}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
    9. metadata-eval3.6%

      \[\leadsto x \cdot \frac{\color{blue}{0.047619047619047616}}{\sqrt{\frac{\pi}{{x}^{12}}}} \]
  10. Simplified3.6%

    \[\leadsto \color{blue}{x \cdot \frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}} \]
  11. Step-by-step derivation
    1. expm1-log1p-u3.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{0.047619047619047616}{\sqrt{\frac{\pi}{{x}^{12}}}}\right)\right)} \]
    2. sqrt-div3.6%

      \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{0.047619047619047616}{\color{blue}{\frac{\sqrt{\pi}}{\sqrt{{x}^{12}}}}}\right)\right) \]
    3. sqrt-pow13.6%

      \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{\color{blue}{{x}^{\left(\frac{12}{2}\right)}}}}\right)\right) \]
    4. metadata-eval3.6%

      \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{\color{blue}{6}}}}\right)\right) \]
  12. Applied egg-rr3.6%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{0.047619047619047616}{\frac{\sqrt{\pi}}{{x}^{6}}}\right)\right)} \]
  13. Taylor expanded in x around 0 4.2%

    \[\leadsto \mathsf{expm1}\left(\color{blue}{0}\right) \]
  14. Final simplification4.2%

    \[\leadsto \mathsf{expm1}\left(0\right) \]
  15. Add Preprocessing

Reproduce

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