| Alternative 1 | |
|---|---|
| Error | 0.21% |
| Cost | 39616 |
\[\left|{\pi}^{-0.5} \cdot \left(x \cdot \left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + \left(0.047619047619047616 \cdot {x}^{6} + {x}^{4} \cdot 0.2\right)\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
(*
(pow PI -0.5)
(*
x
(fma
(pow x 4.0)
0.2
(+
(+ (* 0.047619047619047616 (pow x 6.0)) (* (* x x) 0.6666666666666666))
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) {
return fabs((pow(((double) M_PI), -0.5) * (x * fma(pow(x, 4.0), 0.2, (((0.047619047619047616 * pow(x, 6.0)) + ((x * x) * 0.6666666666666666)) + 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) return abs(Float64((pi ^ -0.5) * Float64(x * fma((x ^ 4.0), 0.2, Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(Float64(x * x) * 0.6666666666666666)) + 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_] := N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(x * N[(N[Power[x, 4.0], $MachinePrecision] * 0.2 + N[(N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + 2.0), $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|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \left(0.047619047619047616 \cdot {x}^{6} + \left(x \cdot x\right) \cdot 0.6666666666666666\right) + 2\right)\right)\right|
Initial program 0.23
Simplified0.85
[Start]0.23 | \[ \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.88 | \[ \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|
\] |
Applied egg-rr0.21
Applied egg-rr0.21
Applied egg-rr0.21
Simplified0.21
[Start]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right) + {\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right)\right)\right|
\] |
|---|---|
distribute-lft-out [=>]0.21 | \[ \left|\color{blue}{{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + x \cdot \mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right)\right)}\right|
\] |
distribute-lft-in [<=]0.21 | \[ \left|{\pi}^{-0.5} \cdot \color{blue}{\left(x \cdot \left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + \mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right)\right)\right)}\right|
\] |
+-commutative [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \color{blue}{\left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)}\right)\right|
\] |
fma-udef [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \left(\color{blue}{\left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right|
\] |
associate-+l+ [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \color{blue}{\left(0.2 \cdot {x}^{4} + \left(0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}\right)\right|
\] |
*-commutative [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \left(\color{blue}{{x}^{4} \cdot 0.2} + \left(0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right)\right|
\] |
fma-def [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left({x}^{4}, 0.2, 0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)}\right)\right|
\] |
fma-def [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \color{blue}{\mathsf{fma}\left(0.047619047619047616, {x}^{6}, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)}\right)\right)\right|
\] |
fma-udef [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \mathsf{fma}\left(0.047619047619047616, {x}^{6}, \color{blue}{0.6666666666666666 \cdot \left(x \cdot x\right) + 2}\right)\right)\right)\right|
\] |
associate-*r* [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \mathsf{fma}\left(0.047619047619047616, {x}^{6}, \color{blue}{\left(0.6666666666666666 \cdot x\right) \cdot x} + 2\right)\right)\right)\right|
\] |
*-commutative [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \mathsf{fma}\left(0.047619047619047616, {x}^{6}, \color{blue}{x \cdot \left(0.6666666666666666 \cdot x\right)} + 2\right)\right)\right)\right|
\] |
fma-def [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \mathsf{fma}\left(0.047619047619047616, {x}^{6}, \color{blue}{\mathsf{fma}\left(x, 0.6666666666666666 \cdot x, 2\right)}\right)\right)\right)\right|
\] |
*-commutative [=>]0.21 | \[ \left|{\pi}^{-0.5} \cdot \left(x \cdot \mathsf{fma}\left({x}^{4}, 0.2, \mathsf{fma}\left(0.047619047619047616, {x}^{6}, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.6666666666666666}, 2\right)\right)\right)\right)\right|
\] |
Applied egg-rr0.21
Final simplification0.21
| Alternative 1 | |
|---|---|
| Error | 0.21% |
| Cost | 39616 |
| Alternative 2 | |
|---|---|
| Error | 1.11% |
| Cost | 32896 |
| Alternative 3 | |
|---|---|
| Error | 0.87% |
| Cost | 32772 |
| Alternative 4 | |
|---|---|
| Error | 1.11% |
| Cost | 26372 |
| Alternative 5 | |
|---|---|
| Error | 1.76% |
| Cost | 26308 |
| Alternative 6 | |
|---|---|
| Error | 1.75% |
| Cost | 26116 |
| Alternative 7 | |
|---|---|
| Error | 4.9% |
| Cost | 26052 |
| Alternative 8 | |
|---|---|
| Error | 1.75% |
| Cost | 26052 |
| Alternative 9 | |
|---|---|
| Error | 1.74% |
| Cost | 26052 |
| Alternative 10 | |
|---|---|
| Error | 1.74% |
| Cost | 26052 |
| Alternative 11 | |
|---|---|
| Error | 7.26% |
| Cost | 19840 |
| Alternative 12 | |
|---|---|
| Error | 7.15% |
| Cost | 19456 |
herbie shell --seed 2023093
(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)))))))