Average Error: 0.2 → 0.6
Time: 9.1s
Precision: binary64
Cost: 59328
\[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|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + {x}^{3} \cdot 0.6666666666666666\right) + 0.2 \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot {x}^{3}\right)\right)\right) + {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)\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
  (*
   (/ 1.0 (sqrt PI))
   (+
    (+
     (+ (* 2.0 (fabs x)) (* (pow x 3.0) 0.6666666666666666))
     (* 0.2 (* (fabs x) (* (fabs x) (pow x 3.0)))))
    (* (pow x 6.0) (* x 0.047619047619047616))))))
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(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + (pow(x, 3.0) * 0.6666666666666666)) + (0.2 * (fabs(x) * (fabs(x) * pow(x, 3.0))))) + (pow(x, 6.0) * (x * 0.047619047619047616)))));
}
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) {
	return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + (Math.pow(x, 3.0) * 0.6666666666666666)) + (0.2 * (Math.abs(x) * (Math.abs(x) * Math.pow(x, 3.0))))) + (Math.pow(x, 6.0) * (x * 0.047619047619047616)))));
}
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):
	return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + (math.pow(x, 3.0) * 0.6666666666666666)) + (0.2 * (math.fabs(x) * (math.fabs(x) * math.pow(x, 3.0))))) + (math.pow(x, 6.0) * (x * 0.047619047619047616)))))
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)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64((x ^ 3.0) * 0.6666666666666666)) + Float64(0.2 * Float64(abs(x) * Float64(abs(x) * (x ^ 3.0))))) + Float64((x ^ 6.0) * Float64(x * 0.047619047619047616)))))
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)
	tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((x ^ 3.0) * 0.6666666666666666)) + (0.2 * (abs(x) * (abs(x) * (x ^ 3.0))))) + ((x ^ 6.0) * (x * 0.047619047619047616)))));
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_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 3.0], $MachinePrecision] * 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 6.0], $MachinePrecision] * N[(x * 0.047619047619047616), $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|
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + {x}^{3} \cdot 0.6666666666666666\right) + 0.2 \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot {x}^{3}\right)\right)\right) + {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)\right|

Error

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. Applied egg-rr0.6

    \[\leadsto \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) + \color{blue}{\left(0 + {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)}\right)\right| \]
  3. Applied egg-rr0.8

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \color{blue}{\left(0 + {x}^{3} \cdot 0.6666666666666666\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) + \left(0 + {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)\right)\right| \]
  4. Applied egg-rr0.6

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

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

Alternatives

Alternative 1
Error0.6
Cost58560
\[\left|{\left(\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.2, {x}^{5}, \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right), 0.047619047619047616 \cdot {x}^{7}\right)\right)}\right)}^{-1}\right| \]
Alternative 2
Error0.5
Cost45824
\[\left|\frac{\mathsf{fma}\left(0.2, {x}^{5}, \mathsf{fma}\left(x, 2 + 0.6666666666666666 \cdot \left(x \cdot x\right), 0.047619047619047616 \cdot {x}^{7}\right)\right)}{\sqrt{\pi}}\right| \]
Alternative 3
Error1.3
Cost45440
\[\left|\frac{\mathsf{fma}\left(0.2, {x}^{5}, \mathsf{fma}\left(x, 2, 0.047619047619047616 \cdot {x}^{7}\right)\right)}{\sqrt{\pi}}\right| \]
Alternative 4
Error0.7
Cost39428
\[\begin{array}{l} t_0 := \sqrt{\frac{1}{\pi}}\\ \mathbf{if}\;x \leq -1787.138185799516:\\ \;\;\;\;\left|\frac{0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}}{\sqrt{\pi}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|0.6666666666666666 \cdot \left({x}^{3} \cdot t_0\right) + 2 \cdot \left(x \cdot t_0\right)\right|\\ \end{array} \]
Alternative 5
Error0.7
Cost32772
\[\begin{array}{l} \mathbf{if}\;x \leq -1787.138185799516:\\ \;\;\;\;\left|\frac{0.047619047619047616 \cdot {x}^{7} + 0.2 \cdot {x}^{5}}{\sqrt{\pi}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \left(\sqrt{\frac{1}{\pi}} \cdot \left(2 + x \cdot \left(x \cdot 0.6666666666666666\right)\right)\right)\right|\\ \end{array} \]
Alternative 6
Error0.8
Cost26052
\[\begin{array}{l} \mathbf{if}\;x \leq -1787.138185799516:\\ \;\;\;\;\left|\frac{0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \left(\sqrt{\frac{1}{\pi}} \cdot \left(2 + x \cdot \left(x \cdot 0.6666666666666666\right)\right)\right)\right|\\ \end{array} \]
Alternative 7
Error4.5
Cost19968
\[\left|x \cdot \left(\sqrt{\frac{1}{\pi}} \cdot \left(2 + x \cdot \left(x \cdot 0.6666666666666666\right)\right)\right)\right| \]
Alternative 8
Error5.2
Cost19456
\[\left|\frac{2}{\frac{\sqrt{\pi}}{x}}\right| \]
Alternative 9
Error4.8
Cost19456
\[\left|x \cdot \frac{2}{\sqrt{\pi}}\right| \]

Error

Reproduce

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