Average Error: 0.2 → 0.1
Time: 6.6s
Precision: binary64
\[x \leq 0.5\]
\[\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| \]
\[\begin{array}{l} t_0 := \sqrt{\frac{1}{\pi}}\\ t_1 := \sqrt{t_0}\\ \left|t_0 \cdot \mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + t_1 \cdot \left(t_1 \cdot \mathsf{fma}\left(0.047619047619047616, {x}^{7}, 0.2 \cdot {x}^{5}\right)\right)\right| \end{array} \]
\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|
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\pi}}\\
t_1 := \sqrt{t_0}\\
\left|t_0 \cdot \mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + t_1 \cdot \left(t_1 \cdot \mathsf{fma}\left(0.047619047619047616, {x}^{7}, 0.2 \cdot {x}^{5}\right)\right)\right|
\end{array}
(FPCore (x)
 :precision binary64
 (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)))))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (/ 1.0 PI))) (t_1 (sqrt t_0)))
   (fabs
    (+
     (* t_0 (fma 2.0 x (* 0.6666666666666666 (pow x 3.0))))
     (*
      t_1
      (* t_1 (fma 0.047619047619047616 (pow x 7.0) (* 0.2 (pow x 5.0)))))))))
double code(double x) {
	return fabs((1.0 / sqrt((double) M_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)))));
}
double code(double x) {
	double t_0 = sqrt(1.0 / ((double) M_PI));
	double t_1 = sqrt(t_0);
	return fabs((t_0 * fma(2.0, x, (0.6666666666666666 * pow(x, 3.0)))) + (t_1 * (t_1 * fma(0.047619047619047616, pow(x, 7.0), (0.2 * pow(x, 5.0))))));
}

Error

Bits error versus x

Derivation

  1. Initial program 0.2

    \[\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. Simplified0.6

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

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

    \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{\pi}} \cdot \mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + \sqrt{\frac{1}{\pi}} \cdot \mathsf{fma}\left(0.047619047619047616, {x}^{7}, 0.2 \cdot {x}^{5}\right)}\right| \]
  5. Applied add-sqr-sqrt_binary640.1

    \[\leadsto \left|\sqrt{\frac{1}{\pi}} \cdot \mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + \color{blue}{\left(\sqrt{\sqrt{\frac{1}{\pi}}} \cdot \sqrt{\sqrt{\frac{1}{\pi}}}\right)} \cdot \mathsf{fma}\left(0.047619047619047616, {x}^{7}, 0.2 \cdot {x}^{5}\right)\right| \]
  6. Applied associate-*l*_binary640.1

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

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

Reproduce

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