Average Error: 0.2 → 0.2
Time: 5.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|\]
\[\left|\left(\left(\left(2 \cdot x + 0.6666666666666666 \cdot {x}^{3}\right) + 0.2 \cdot {x}^{5}\right) + 0.047619047619047616 \cdot {x}^{7}\right) \cdot \frac{1}{\sqrt{\pi}}\right|\]
\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|
\left|\left(\left(\left(2 \cdot x + 0.6666666666666666 \cdot {x}^{3}\right) + 0.2 \cdot {x}^{5}\right) + 0.047619047619047616 \cdot {x}^{7}\right) \cdot \frac{1}{\sqrt{\pi}}\right|
(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
 (fabs
  (*
   (+
    (+ (+ (* 2.0 x) (* 0.6666666666666666 (pow x 3.0))) (* 0.2 (pow x 5.0)))
    (* 0.047619047619047616 (pow x 7.0)))
   (/ 1.0 (sqrt PI)))))
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) {
	return fabs(((((2.0 * x) + (0.6666666666666666 * pow(x, 3.0))) + (0.2 * pow(x, 5.0))) + (0.047619047619047616 * pow(x, 7.0))) * (1.0 / sqrt((double) M_PI)));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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{\left(\left(2 \cdot x + 0.6666666666666666 \cdot {x}^{3}\right) + 0.2 \cdot {x}^{5}\right) + 0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|}\]
  3. Using strategy rm
  4. Applied div-inv_binary640.2

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

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

Reproduce

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