| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 33280 |
\[\left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left({x}^{4} \cdot \left(0.2 + 0.047619047619047616 \cdot \left(x \cdot x\right)\right) + \mathsf{fma}\left(x \cdot 0.6666666666666666, x, 2\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
(*
(sqrt (/ 1.0 PI))
(+
(* (pow x 3.0) (+ 0.6666666666666666 (* x (* x 0.2))))
(fma 2.0 x (* 0.047619047619047616 (pow x 7.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) {
return fabs((sqrt((1.0 / ((double) M_PI))) * ((pow(x, 3.0) * (0.6666666666666666 + (x * (x * 0.2)))) + fma(2.0, x, (0.047619047619047616 * pow(x, 7.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) return abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64((x ^ 3.0) * Float64(0.6666666666666666 + Float64(x * Float64(x * 0.2)))) + fma(2.0, x, Float64(0.047619047619047616 * (x ^ 7.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_] := N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(0.6666666666666666 + N[(x * N[(x * 0.2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * x + N[(0.047619047619047616 * N[Power[x, 7.0], $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|
\left|\sqrt{\frac{1}{\pi}} \cdot \left({x}^{3} \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.2\right)\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
Initial program 0.2
Simplified0.6
[Start]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|
\] |
|---|---|
associate-*l/ [=>]0.6 | \[ \left|\color{blue}{\frac{1 \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)}{\sqrt{\pi}}}\right|
\] |
Taylor expanded in x around 0 0.2
Simplified0.2
[Start]0.2 | \[ \left|2 \cdot \left(\left|x\right| \cdot \sqrt{\frac{1}{\pi}}\right) + \left(0.047619047619047616 \cdot \left(\left({\left(\left|x\right|\right)}^{3} \cdot {x}^{4}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + \left(\left(0.6666666666666666 \cdot \left|x\right| + 0.2 \cdot {\left(\left|x\right|\right)}^{3}\right) \cdot {x}^{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right|
\] |
|---|---|
associate-+r+ [=>]0.2 | \[ \left|\color{blue}{\left(2 \cdot \left(\left|x\right| \cdot \sqrt{\frac{1}{\pi}}\right) + 0.047619047619047616 \cdot \left(\left({\left(\left|x\right|\right)}^{3} \cdot {x}^{4}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right) + \left(\left(0.6666666666666666 \cdot \left|x\right| + 0.2 \cdot {\left(\left|x\right|\right)}^{3}\right) \cdot {x}^{2}\right) \cdot \sqrt{\frac{1}{\pi}}}\right|
\] |
associate-*r* [=>]0.2 | \[ \left|\left(\color{blue}{\left(2 \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\pi}}} + 0.047619047619047616 \cdot \left(\left({\left(\left|x\right|\right)}^{3} \cdot {x}^{4}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right) + \left(\left(0.6666666666666666 \cdot \left|x\right| + 0.2 \cdot {\left(\left|x\right|\right)}^{3}\right) \cdot {x}^{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right|
\] |
associate-*r* [=>]0.2 | \[ \left|\left(\left(2 \cdot \left|x\right|\right) \cdot \sqrt{\frac{1}{\pi}} + \color{blue}{\left(0.047619047619047616 \cdot \left({\left(\left|x\right|\right)}^{3} \cdot {x}^{4}\right)\right) \cdot \sqrt{\frac{1}{\pi}}}\right) + \left(\left(0.6666666666666666 \cdot \left|x\right| + 0.2 \cdot {\left(\left|x\right|\right)}^{3}\right) \cdot {x}^{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right|
\] |
distribute-rgt-out [=>]0.2 | \[ \left|\color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot \left|x\right| + 0.047619047619047616 \cdot \left({\left(\left|x\right|\right)}^{3} \cdot {x}^{4}\right)\right)} + \left(\left(0.6666666666666666 \cdot \left|x\right| + 0.2 \cdot {\left(\left|x\right|\right)}^{3}\right) \cdot {x}^{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right|
\] |
*-commutative [=>]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot \left|x\right| + 0.047619047619047616 \cdot \left({\left(\left|x\right|\right)}^{3} \cdot {x}^{4}\right)\right) + \color{blue}{\sqrt{\frac{1}{\pi}} \cdot \left(\left(0.6666666666666666 \cdot \left|x\right| + 0.2 \cdot {\left(\left|x\right|\right)}^{3}\right) \cdot {x}^{2}\right)}\right|
\] |
Applied egg-rr0.2
Simplified0.2
[Start]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(\left(\left(x \cdot x\right) \cdot \left(0.2 \cdot {x}^{3}\right) + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
|---|---|
associate-*r* [=>]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(\left(\color{blue}{\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot {x}^{3}} + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
associate-*r* [=>]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot {x}^{3} + \color{blue}{\left(\left(x \cdot x\right) \cdot x\right) \cdot 0.6666666666666666}\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
unpow3 [<=]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot {x}^{3} + \color{blue}{{x}^{3}} \cdot 0.6666666666666666\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
*-commutative [<=]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot {x}^{3} + \color{blue}{0.6666666666666666 \cdot {x}^{3}}\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
distribute-rgt-out [=>]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left(\color{blue}{{x}^{3} \cdot \left(\left(x \cdot x\right) \cdot 0.2 + 0.6666666666666666\right)} + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
+-commutative [<=]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left({x}^{3} \cdot \color{blue}{\left(0.6666666666666666 + \left(x \cdot x\right) \cdot 0.2\right)} + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
associate-*l* [=>]0.2 | \[ \left|\sqrt{\frac{1}{\pi}} \cdot \left({x}^{3} \cdot \left(0.6666666666666666 + \color{blue}{x \cdot \left(x \cdot 0.2\right)}\right) + \mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)\right)\right|
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 33280 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 33028 |
| Alternative 3 | |
|---|---|
| Error | 0.5 |
| Cost | 32900 |
| Alternative 4 | |
|---|---|
| Error | 0.5 |
| Cost | 32772 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 26372 |
| Alternative 6 | |
|---|---|
| Error | 1.0 |
| Cost | 26052 |
| Alternative 7 | |
|---|---|
| Error | 5.0 |
| Cost | 19456 |
herbie shell --seed 2023046
(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)))))))