
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, 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] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, 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] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(*
(pow PI -0.5)
(+
2.0
(+
(* 0.047619047619047616 (pow x 6.0))
(+ (* 0.2 (pow x 4.0)) (* 0.6666666666666666 (* x x)))))))))
double code(double x) {
return fabs(x) * fabs((pow(((double) M_PI), -0.5) * (2.0 + ((0.047619047619047616 * pow(x, 6.0)) + ((0.2 * pow(x, 4.0)) + (0.6666666666666666 * (x * x)))))));
}
public static double code(double x) {
return Math.abs(x) * Math.abs((Math.pow(Math.PI, -0.5) * (2.0 + ((0.047619047619047616 * Math.pow(x, 6.0)) + ((0.2 * Math.pow(x, 4.0)) + (0.6666666666666666 * (x * x)))))));
}
def code(x): return math.fabs(x) * math.fabs((math.pow(math.pi, -0.5) * (2.0 + ((0.047619047619047616 * math.pow(x, 6.0)) + ((0.2 * math.pow(x, 4.0)) + (0.6666666666666666 * (x * x)))))))
function code(x) return Float64(abs(x) * abs(Float64((pi ^ -0.5) * Float64(2.0 + Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(Float64(0.2 * (x ^ 4.0)) + Float64(0.6666666666666666 * Float64(x * x)))))))) end
function tmp = code(x) tmp = abs(x) * abs(((pi ^ -0.5) * (2.0 + ((0.047619047619047616 * (x ^ 6.0)) + ((0.2 * (x ^ 4.0)) + (0.6666666666666666 * (x * x))))))); end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(2.0 + N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|{\pi}^{-0.5} \cdot \left(2 + \left(0.047619047619047616 \cdot {x}^{6} + \left(0.2 \cdot {x}^{4} + 0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)\right)\right|
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
pow299.8%
Applied egg-rr99.8%
*-un-lft-identity99.8%
pow1/299.8%
inv-pow99.8%
pow-pow99.8%
metadata-eval99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 0.0005)
(fabs
(*
(sqrt (/ 1.0 PI))
(* (fabs x) (fma 0.6666666666666666 (pow x 2.0) 2.0))))
(* x (* 0.047619047619047616 (* (pow PI -0.5) (pow x 6.0))))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.0005) {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * (fabs(x) * fma(0.6666666666666666, pow(x, 2.0), 2.0))));
} else {
tmp = x * (0.047619047619047616 * (pow(((double) M_PI), -0.5) * pow(x, 6.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) <= 0.0005) tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(abs(x) * fma(0.6666666666666666, (x ^ 2.0), 2.0)))); else tmp = Float64(x * Float64(0.047619047619047616 * Float64((pi ^ -0.5) * (x ^ 6.0)))); end return tmp end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.0005], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(0.6666666666666666 * N[Power[x, 2.0], $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(x * N[(0.047619047619047616 * N[(N[Power[Pi, -0.5], $MachinePrecision] * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.0005:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.047619047619047616 \cdot \left({\pi}^{-0.5} \cdot {x}^{6}\right)\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-4Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-*r*99.8%
unpow299.8%
sqr-abs99.8%
unpow399.8%
*-commutative99.8%
associate-*r*99.8%
distribute-rgt-in99.8%
*-commutative99.8%
Simplified99.8%
if 5.0000000000000001e-4 < (fabs.f64 x) Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
unpow-199.2%
metadata-eval99.2%
pow-sqr99.2%
rem-sqrt-square99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
rem-square-sqrt99.2%
*-commutative99.2%
associate-*r*99.2%
*-commutative99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
Simplified99.2%
pow199.2%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.1%
Applied egg-rr0.1%
unpow10.1%
*-commutative0.1%
associate-*l*0.1%
Simplified0.1%
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(/
(+
(* (pow x 4.0) (+ 0.2 (* 0.047619047619047616 (* x x))))
(fma 0.6666666666666666 (* x x) 2.0))
(sqrt PI)))))
double code(double x) {
return fabs(x) * fabs((((pow(x, 4.0) * (0.2 + (0.047619047619047616 * (x * x)))) + fma(0.6666666666666666, (x * x), 2.0)) / sqrt(((double) M_PI))));
}
function code(x) return Float64(abs(x) * abs(Float64(Float64(Float64((x ^ 4.0) * Float64(0.2 + Float64(0.047619047619047616 * Float64(x * x)))) + fma(0.6666666666666666, Float64(x * x), 2.0)) / sqrt(pi)))) end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[(N[(N[Power[x, 4.0], $MachinePrecision] * N[(0.2 + N[(0.047619047619047616 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{{x}^{4} \cdot \left(0.2 + 0.047619047619047616 \cdot \left(x \cdot x\right)\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
pow299.8%
Applied egg-rr99.8%
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(/
(+
(* 0.047619047619047616 (pow x 6.0))
(fma 0.6666666666666666 (* x x) 2.0))
(sqrt PI)))))
double code(double x) {
return fabs(x) * fabs((((0.047619047619047616 * pow(x, 6.0)) + fma(0.6666666666666666, (x * x), 2.0)) / sqrt(((double) M_PI))));
}
function code(x) return Float64(abs(x) * abs(Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + fma(0.6666666666666666, Float64(x * x), 2.0)) / sqrt(pi)))) end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 99.6%
(FPCore (x) :precision binary64 (* (fma 0.047619047619047616 (pow x 6.0) (fma 0.6666666666666666 (pow x 2.0) 2.0)) (/ x (sqrt PI))))
double code(double x) {
return fma(0.047619047619047616, pow(x, 6.0), fma(0.6666666666666666, pow(x, 2.0), 2.0)) * (x / sqrt(((double) M_PI)));
}
function code(x) return Float64(fma(0.047619047619047616, (x ^ 6.0), fma(0.6666666666666666, (x ^ 2.0), 2.0)) * Float64(x / sqrt(pi))) end
code[x_] := N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision] + N[(0.6666666666666666 * N[Power[x, 2.0], $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.047619047619047616, {x}^{6}, \mathsf{fma}\left(0.6666666666666666, {x}^{2}, 2\right)\right) \cdot \frac{x}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 99.6%
pow199.6%
add-sqr-sqrt35.6%
fabs-sqr35.6%
add-sqr-sqrt37.3%
add-sqr-sqrt36.7%
fabs-sqr36.7%
add-sqr-sqrt37.3%
*-commutative37.3%
fma-define37.3%
pow237.3%
Applied egg-rr37.3%
unpow137.3%
remove-double-neg37.3%
distribute-lft-neg-in37.3%
*-commutative37.3%
associate-*l/37.1%
associate-/l*37.1%
distribute-frac-neg37.1%
distribute-frac-neg237.1%
distribute-rgt-neg-in37.1%
fma-undefine37.1%
*-commutative37.1%
fma-define37.1%
distribute-frac-neg237.1%
remove-double-neg37.1%
Simplified37.1%
(FPCore (x) :precision binary64 (if (<= (fabs x) 0.0005) (* x (/ (fma 0.2 (pow x 4.0) 2.0) (sqrt PI))) (* x (* 0.047619047619047616 (* (pow PI -0.5) (pow x 6.0))))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.0005) {
tmp = x * (fma(0.2, pow(x, 4.0), 2.0) / sqrt(((double) M_PI)));
} else {
tmp = x * (0.047619047619047616 * (pow(((double) M_PI), -0.5) * pow(x, 6.0)));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) <= 0.0005) tmp = Float64(x * Float64(fma(0.2, (x ^ 4.0), 2.0) / sqrt(pi))); else tmp = Float64(x * Float64(0.047619047619047616 * Float64((pi ^ -0.5) * (x ^ 6.0)))); end return tmp end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.0005], N[(x * N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.047619047619047616 * N[(N[Power[Pi, -0.5], $MachinePrecision] * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.0005:\\
\;\;\;\;x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, 2\right)}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.047619047619047616 \cdot \left({\pi}^{-0.5} \cdot {x}^{6}\right)\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-4Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
Taylor expanded in x around 0 99.3%
pow199.3%
add-sqr-sqrt49.9%
fabs-sqr49.9%
add-sqr-sqrt52.2%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt52.2%
fma-define52.2%
Applied egg-rr52.2%
unpow152.2%
Simplified52.2%
if 5.0000000000000001e-4 < (fabs.f64 x) Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
unpow-199.2%
metadata-eval99.2%
pow-sqr99.2%
rem-sqrt-square99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
rem-square-sqrt99.2%
*-commutative99.2%
associate-*r*99.2%
*-commutative99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
Simplified99.2%
pow199.2%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.1%
Applied egg-rr0.1%
unpow10.1%
*-commutative0.1%
associate-*l*0.1%
Simplified0.1%
(FPCore (x) :precision binary64 (if (<= (fabs x) 0.0005) (* x (/ 2.0 (sqrt PI))) (* x (* 0.047619047619047616 (* (pow PI -0.5) (pow x 6.0))))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.0005) {
tmp = x * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = x * (0.047619047619047616 * (pow(((double) M_PI), -0.5) * pow(x, 6.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 0.0005) {
tmp = x * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = x * (0.047619047619047616 * (Math.pow(Math.PI, -0.5) * Math.pow(x, 6.0)));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 0.0005: tmp = x * (2.0 / math.sqrt(math.pi)) else: tmp = x * (0.047619047619047616 * (math.pow(math.pi, -0.5) * math.pow(x, 6.0))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 0.0005) tmp = Float64(x * Float64(2.0 / sqrt(pi))); else tmp = Float64(x * Float64(0.047619047619047616 * Float64((pi ^ -0.5) * (x ^ 6.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 0.0005) tmp = x * (2.0 / sqrt(pi)); else tmp = x * (0.047619047619047616 * ((pi ^ -0.5) * (x ^ 6.0))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.0005], N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.047619047619047616 * N[(N[Power[Pi, -0.5], $MachinePrecision] * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.0005:\\
\;\;\;\;x \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.047619047619047616 \cdot \left({\pi}^{-0.5} \cdot {x}^{6}\right)\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-4Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-*r*99.3%
*-commutative99.3%
unpow-199.3%
metadata-eval99.3%
pow-sqr99.3%
rem-sqrt-square99.3%
rem-square-sqrt99.3%
fabs-sqr99.3%
rem-square-sqrt99.3%
associate-*l*99.3%
fabs-mul99.3%
fabs-mul99.3%
fabs-fabs99.3%
metadata-eval99.3%
rem-square-sqrt99.3%
fabs-sqr99.3%
Simplified99.3%
associate-*r*99.3%
metadata-eval99.3%
sqrt-pow199.3%
inv-pow99.3%
*-commutative99.3%
metadata-eval99.3%
rem-sqrt-square40.3%
sqrt-prod40.3%
sqrt-prod40.2%
pow240.2%
*-commutative40.2%
associate-*l/40.3%
pow240.3%
*-un-lft-identity40.3%
sqrt-div40.2%
*-commutative40.2%
sqrt-prod40.2%
sqrt-prod49.7%
add-sqr-sqrt51.9%
metadata-eval51.9%
Applied egg-rr51.9%
associate-/l*52.2%
Simplified52.2%
if 5.0000000000000001e-4 < (fabs.f64 x) Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
unpow-199.2%
metadata-eval99.2%
pow-sqr99.2%
rem-sqrt-square99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
rem-square-sqrt99.2%
*-commutative99.2%
associate-*r*99.2%
*-commutative99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
Simplified99.2%
pow199.2%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.1%
Applied egg-rr0.1%
unpow10.1%
*-commutative0.1%
associate-*l*0.1%
Simplified0.1%
(FPCore (x) :precision binary64 (if (<= (fabs x) 0.0005) (* x (/ 2.0 (sqrt PI))) (* (pow PI -0.5) (* 0.047619047619047616 (pow x 7.0)))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.0005) {
tmp = x * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = pow(((double) M_PI), -0.5) * (0.047619047619047616 * pow(x, 7.0));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 0.0005) {
tmp = x * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = Math.pow(Math.PI, -0.5) * (0.047619047619047616 * Math.pow(x, 7.0));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 0.0005: tmp = x * (2.0 / math.sqrt(math.pi)) else: tmp = math.pow(math.pi, -0.5) * (0.047619047619047616 * math.pow(x, 7.0)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 0.0005) tmp = Float64(x * Float64(2.0 / sqrt(pi))); else tmp = Float64((pi ^ -0.5) * Float64(0.047619047619047616 * (x ^ 7.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 0.0005) tmp = x * (2.0 / sqrt(pi)); else tmp = (pi ^ -0.5) * (0.047619047619047616 * (x ^ 7.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.0005], N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.0005:\\
\;\;\;\;x \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;{\pi}^{-0.5} \cdot \left(0.047619047619047616 \cdot {x}^{7}\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-4Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-*r*99.3%
*-commutative99.3%
unpow-199.3%
metadata-eval99.3%
pow-sqr99.3%
rem-sqrt-square99.3%
rem-square-sqrt99.3%
fabs-sqr99.3%
rem-square-sqrt99.3%
associate-*l*99.3%
fabs-mul99.3%
fabs-mul99.3%
fabs-fabs99.3%
metadata-eval99.3%
rem-square-sqrt99.3%
fabs-sqr99.3%
Simplified99.3%
associate-*r*99.3%
metadata-eval99.3%
sqrt-pow199.3%
inv-pow99.3%
*-commutative99.3%
metadata-eval99.3%
rem-sqrt-square40.3%
sqrt-prod40.3%
sqrt-prod40.2%
pow240.2%
*-commutative40.2%
associate-*l/40.3%
pow240.3%
*-un-lft-identity40.3%
sqrt-div40.2%
*-commutative40.2%
sqrt-prod40.2%
sqrt-prod49.7%
add-sqr-sqrt51.9%
metadata-eval51.9%
Applied egg-rr51.9%
associate-/l*52.2%
Simplified52.2%
if 5.0000000000000001e-4 < (fabs.f64 x) Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
unpow-199.2%
metadata-eval99.2%
pow-sqr99.2%
rem-sqrt-square99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
rem-square-sqrt99.2%
*-commutative99.2%
associate-*r*99.2%
*-commutative99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
Simplified99.2%
pow199.2%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.1%
Applied egg-rr0.1%
unpow10.1%
associate-*r*0.1%
associate-*r*0.1%
*-commutative0.1%
pow-plus0.1%
metadata-eval0.1%
Simplified0.1%
Final simplification37.1%
(FPCore (x) :precision binary64 (if (<= (fabs x) 1e-16) (* x (/ 2.0 (sqrt PI))) (sqrt (/ (* 4.0 (pow x 2.0)) PI))))
double code(double x) {
double tmp;
if (fabs(x) <= 1e-16) {
tmp = x * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = sqrt(((4.0 * pow(x, 2.0)) / ((double) M_PI)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 1e-16) {
tmp = x * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = Math.sqrt(((4.0 * Math.pow(x, 2.0)) / Math.PI));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 1e-16: tmp = x * (2.0 / math.sqrt(math.pi)) else: tmp = math.sqrt(((4.0 * math.pow(x, 2.0)) / math.pi)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 1e-16) tmp = Float64(x * Float64(2.0 / sqrt(pi))); else tmp = sqrt(Float64(Float64(4.0 * (x ^ 2.0)) / pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 1e-16) tmp = x * (2.0 / sqrt(pi)); else tmp = sqrt(((4.0 * (x ^ 2.0)) / pi)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1e-16], N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(4.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 10^{-16}:\\
\;\;\;\;x \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{4 \cdot {x}^{2}}{\pi}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 9.9999999999999998e-17Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
unpow-199.8%
metadata-eval99.8%
pow-sqr99.8%
rem-sqrt-square99.8%
rem-square-sqrt99.8%
fabs-sqr99.8%
rem-square-sqrt99.8%
associate-*l*99.8%
fabs-mul99.8%
fabs-mul99.8%
fabs-fabs99.8%
metadata-eval99.8%
rem-square-sqrt99.8%
fabs-sqr99.8%
Simplified99.8%
associate-*r*99.8%
metadata-eval99.8%
sqrt-pow199.8%
inv-pow99.8%
*-commutative99.8%
metadata-eval99.8%
rem-sqrt-square39.1%
sqrt-prod39.1%
sqrt-prod39.0%
pow239.0%
*-commutative39.0%
associate-*l/39.0%
pow239.0%
*-un-lft-identity39.0%
sqrt-div39.0%
*-commutative39.0%
sqrt-prod39.0%
sqrt-prod50.2%
add-sqr-sqrt52.5%
metadata-eval52.5%
Applied egg-rr52.5%
associate-/l*52.7%
Simplified52.7%
if 9.9999999999999998e-17 < (fabs.f64 x) Initial program 99.8%
Simplified99.7%
Taylor expanded in x around 0 10.8%
*-commutative10.8%
associate-*l*10.8%
Simplified10.8%
Taylor expanded in x around 0 10.8%
associate-*r*10.8%
*-commutative10.8%
unpow-110.8%
metadata-eval10.8%
pow-sqr10.8%
rem-sqrt-square10.8%
rem-square-sqrt10.8%
fabs-sqr10.8%
rem-square-sqrt10.8%
associate-*l*10.8%
fabs-mul10.8%
fabs-mul10.8%
fabs-fabs10.8%
metadata-eval10.8%
rem-square-sqrt10.8%
fabs-sqr10.8%
Simplified10.8%
associate-*r*10.8%
metadata-eval10.8%
sqrt-pow110.8%
inv-pow10.8%
*-commutative10.8%
metadata-eval10.8%
rem-sqrt-square62.6%
sqrt-prod62.6%
sqrt-prod62.6%
pow262.6%
*-commutative62.6%
associate-*l/62.6%
pow262.6%
*-un-lft-identity62.6%
pow262.6%
Applied egg-rr62.6%
(FPCore (x) :precision binary64 (* x (/ 2.0 (sqrt PI))))
double code(double x) {
return x * (2.0 / sqrt(((double) M_PI)));
}
public static double code(double x) {
return x * (2.0 / Math.sqrt(Math.PI));
}
def code(x): return x * (2.0 / math.sqrt(math.pi))
function code(x) return Float64(x * Float64(2.0 / sqrt(pi))) end
function tmp = code(x) tmp = x * (2.0 / sqrt(pi)); end
code[x_] := N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{2}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 72.3%
*-commutative72.3%
associate-*l*72.3%
Simplified72.3%
Taylor expanded in x around 0 72.3%
associate-*r*72.3%
*-commutative72.3%
unpow-172.3%
metadata-eval72.3%
pow-sqr72.3%
rem-sqrt-square72.3%
rem-square-sqrt72.3%
fabs-sqr72.3%
rem-square-sqrt72.3%
associate-*l*72.3%
fabs-mul72.3%
fabs-mul72.3%
fabs-fabs72.3%
metadata-eval72.3%
rem-square-sqrt72.3%
fabs-sqr72.3%
Simplified72.3%
associate-*r*72.3%
metadata-eval72.3%
sqrt-pow172.3%
inv-pow72.3%
*-commutative72.3%
metadata-eval72.3%
rem-sqrt-square46.4%
sqrt-prod46.4%
sqrt-prod46.3%
pow246.3%
*-commutative46.3%
associate-*l/46.3%
pow246.3%
*-un-lft-identity46.3%
sqrt-div46.3%
*-commutative46.3%
sqrt-prod46.3%
sqrt-prod35.4%
add-sqr-sqrt37.0%
metadata-eval37.0%
Applied egg-rr37.0%
associate-/l*37.2%
Simplified37.2%
herbie shell --seed 2024181
(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)))))))