Average Error: 0.2 → 0.2
Time: 4.1s
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}}\\ \left|0.047619047619047616 \cdot \left(t_0 \cdot {\left(\left|x\right|\right)}^{7}\right) + \left(2 \cdot \left(t_0 \cdot \left|x\right|\right) + \left(0.2 \cdot \left(t_0 \cdot {\left(\left|x\right|\right)}^{5}\right) + 0.6666666666666666 \cdot \left(t_0 \cdot \left(\left|x\right| \cdot {x}^{2}\right)\right)\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))))
   (fabs
    (+
     (* 0.047619047619047616 (* t_0 (pow (fabs x) 7.0)))
     (+
      (* 2.0 (* t_0 (fabs x)))
      (+
       (* 0.2 (* t_0 (pow (fabs x) 5.0)))
       (* 0.6666666666666666 (* t_0 (* (fabs x) (pow x 2.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)));
	return fabs(((0.047619047619047616 * (t_0 * pow(fabs(x), 7.0))) + ((2.0 * (t_0 * fabs(x))) + ((0.2 * (t_0 * pow(fabs(x), 5.0))) + (0.6666666666666666 * (t_0 * (fabs(x) * pow(x, 2.0))))))));
}
public static double code(double x) {
	return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * ((Math.abs(x) * Math.abs(x)) * Math.abs(x)))) + ((1.0 / 5.0) * ((((Math.abs(x) * Math.abs(x)) * Math.abs(x)) * Math.abs(x)) * Math.abs(x)))) + ((1.0 / 21.0) * ((((((Math.abs(x) * Math.abs(x)) * Math.abs(x)) * Math.abs(x)) * Math.abs(x)) * Math.abs(x)) * Math.abs(x))))));
}
public static double code(double x) {
	double t_0 = Math.sqrt((1.0 / Math.PI));
	return Math.abs(((0.047619047619047616 * (t_0 * Math.pow(Math.abs(x), 7.0))) + ((2.0 * (t_0 * Math.abs(x))) + ((0.2 * (t_0 * Math.pow(Math.abs(x), 5.0))) + (0.6666666666666666 * (t_0 * (Math.abs(x) * Math.pow(x, 2.0))))))));
}
def code(x):
	return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * ((math.fabs(x) * math.fabs(x)) * math.fabs(x)))) + ((1.0 / 5.0) * ((((math.fabs(x) * math.fabs(x)) * math.fabs(x)) * math.fabs(x)) * math.fabs(x)))) + ((1.0 / 21.0) * ((((((math.fabs(x) * math.fabs(x)) * math.fabs(x)) * math.fabs(x)) * math.fabs(x)) * math.fabs(x)) * math.fabs(x))))))
def code(x):
	t_0 = math.sqrt((1.0 / math.pi))
	return math.fabs(((0.047619047619047616 * (t_0 * math.pow(math.fabs(x), 7.0))) + ((2.0 * (t_0 * math.fabs(x))) + ((0.2 * (t_0 * math.pow(math.fabs(x), 5.0))) + (0.6666666666666666 * (t_0 * (math.fabs(x) * math.pow(x, 2.0))))))))
function code(x)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * Float64(Float64(abs(x) * abs(x)) * abs(x)))) + Float64(Float64(1.0 / 5.0) * Float64(Float64(Float64(Float64(abs(x) * abs(x)) * abs(x)) * abs(x)) * abs(x)))) + Float64(Float64(1.0 / 21.0) * Float64(Float64(Float64(Float64(Float64(Float64(abs(x) * abs(x)) * abs(x)) * abs(x)) * abs(x)) * abs(x)) * abs(x))))))
end
function code(x)
	t_0 = sqrt(Float64(1.0 / pi))
	return abs(Float64(Float64(0.047619047619047616 * Float64(t_0 * (abs(x) ^ 7.0))) + Float64(Float64(2.0 * Float64(t_0 * abs(x))) + Float64(Float64(0.2 * Float64(t_0 * (abs(x) ^ 5.0))) + Float64(0.6666666666666666 * Float64(t_0 * Float64(abs(x) * (x ^ 2.0))))))))
end
function tmp = code(x)
	tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * ((abs(x) * abs(x)) * abs(x)))) + ((1.0 / 5.0) * ((((abs(x) * abs(x)) * abs(x)) * abs(x)) * abs(x)))) + ((1.0 / 21.0) * ((((((abs(x) * abs(x)) * abs(x)) * abs(x)) * abs(x)) * abs(x)) * abs(x))))));
end
function tmp = code(x)
	t_0 = sqrt((1.0 / pi));
	tmp = abs(((0.047619047619047616 * (t_0 * (abs(x) ^ 7.0))) + ((2.0 * (t_0 * abs(x))) + ((0.2 * (t_0 * (abs(x) ^ 5.0))) + (0.6666666666666666 * (t_0 * (abs(x) * (x ^ 2.0))))))));
end
code[x_] := 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] * N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(0.047619047619047616 * N[(t$95$0 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.2 * N[(t$95$0 * N[Power[N[Abs[x], $MachinePrecision], 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(t$95$0 * N[(N[Abs[x], $MachinePrecision] * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\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}}\\
\left|0.047619047619047616 \cdot \left(t_0 \cdot {\left(\left|x\right|\right)}^{7}\right) + \left(2 \cdot \left(t_0 \cdot \left|x\right|\right) + \left(0.2 \cdot \left(t_0 \cdot {\left(\left|x\right|\right)}^{5}\right) + 0.6666666666666666 \cdot \left(t_0 \cdot \left(\left|x\right| \cdot {x}^{2}\right)\right)\right)\right)\right|
\end{array}

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

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

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

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

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

Reproduce

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