| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 45952 |
\[\left|{\pi}^{-0.5} \cdot \left(\mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + \left(0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}\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)
(+
(fma 2.0 x (* 0.6666666666666666 (pow x 3.0)))
(fma 0.2 (* x (pow x 4.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((pow(((double) M_PI), -0.5) * (fma(2.0, x, (0.6666666666666666 * pow(x, 3.0))) + fma(0.2, (x * pow(x, 4.0)), (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((pi ^ -0.5) * Float64(fma(2.0, x, Float64(0.6666666666666666 * (x ^ 3.0))) + fma(0.2, Float64(x * (x ^ 4.0)), Float64((x ^ 6.0) * Float64(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[Power[Pi, -0.5], $MachinePrecision] * N[(N[(2.0 * x + N[(0.6666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[(x * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 6.0], $MachinePrecision] * N[(x * 0.047619047619047616), $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|{\pi}^{-0.5} \cdot \left(\mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + \mathsf{fma}\left(0.2, x \cdot {x}^{4}, {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)\right)\right|
Initial program 0.2
Simplified0.2
[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|
\] |
|---|---|
*-lft-identity [<=]0.2 | \[ \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\left(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)\right)}\right|
\] |
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ \left|{\pi}^{-0.5} \cdot \mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + {\pi}^{-0.5} \cdot \mathsf{fma}\left(0.2, x \cdot {x}^{4}, {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)\right|
\] |
|---|---|
distribute-lft-out [=>]0.1 | \[ \left|\color{blue}{{\pi}^{-0.5} \cdot \left(\mathsf{fma}\left(2, x, 0.6666666666666666 \cdot {x}^{3}\right) + \mathsf{fma}\left(0.2, x \cdot {x}^{4}, {x}^{6} \cdot \left(x \cdot 0.047619047619047616\right)\right)\right)}\right|
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 45952 |
| Alternative 2 | |
|---|---|
| Error | 0.5 |
| Cost | 33216 |
| Alternative 3 | |
|---|---|
| Error | 0.7 |
| Cost | 32836 |
| Alternative 4 | |
|---|---|
| Error | 1.1 |
| Cost | 32832 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 32580 |
| Alternative 6 | |
|---|---|
| Error | 0.7 |
| Cost | 32452 |
| Alternative 7 | |
|---|---|
| Error | 0.7 |
| Cost | 26180 |
| Alternative 8 | |
|---|---|
| Error | 2.8 |
| Cost | 26052 |
| Alternative 9 | |
|---|---|
| Error | 4.4 |
| Cost | 19968 |
| Alternative 10 | |
|---|---|
| Error | 4.7 |
| Cost | 19456 |
herbie shell --seed 2023017
(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)))))))