
(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 7 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}
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(*
(* x_m (pow PI -0.5))
(+
2.0
(+
(+ (* 0.047619047619047616 (pow x_m 6.0)) (* 0.2 (pow x_m 4.0)))
(* 0.6666666666666666 (pow x_m 2.0))))))x_m = fabs(x);
double code(double x_m) {
return (x_m * pow(((double) M_PI), -0.5)) * (2.0 + (((0.047619047619047616 * pow(x_m, 6.0)) + (0.2 * pow(x_m, 4.0))) + (0.6666666666666666 * pow(x_m, 2.0))));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return (x_m * Math.pow(Math.PI, -0.5)) * (2.0 + (((0.047619047619047616 * Math.pow(x_m, 6.0)) + (0.2 * Math.pow(x_m, 4.0))) + (0.6666666666666666 * Math.pow(x_m, 2.0))));
}
x_m = math.fabs(x) def code(x_m): return (x_m * math.pow(math.pi, -0.5)) * (2.0 + (((0.047619047619047616 * math.pow(x_m, 6.0)) + (0.2 * math.pow(x_m, 4.0))) + (0.6666666666666666 * math.pow(x_m, 2.0))))
x_m = abs(x) function code(x_m) return Float64(Float64(x_m * (pi ^ -0.5)) * Float64(2.0 + Float64(Float64(Float64(0.047619047619047616 * (x_m ^ 6.0)) + Float64(0.2 * (x_m ^ 4.0))) + Float64(0.6666666666666666 * (x_m ^ 2.0))))) end
x_m = abs(x); function tmp = code(x_m) tmp = (x_m * (pi ^ -0.5)) * (2.0 + (((0.047619047619047616 * (x_m ^ 6.0)) + (0.2 * (x_m ^ 4.0))) + (0.6666666666666666 * (x_m ^ 2.0)))); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(N[(N[(0.047619047619047616 * N[Power[x$95$m, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[Power[x$95$m, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[Power[x$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\left(x\_m \cdot {\pi}^{-0.5}\right) \cdot \left(2 + \left(\left(0.047619047619047616 \cdot {x\_m}^{6} + 0.2 \cdot {x\_m}^{4}\right) + 0.6666666666666666 \cdot {x\_m}^{2}\right)\right)
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
*-un-lft-identity99.9%
inv-pow99.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
expm1-log1p-u99.5%
expm1-undefine36.1%
Applied egg-rr4.4%
sub-neg4.4%
metadata-eval4.4%
+-commutative4.4%
log1p-undefine4.4%
rem-exp-log4.4%
associate-+r+36.0%
metadata-eval36.0%
remove-double-neg36.0%
sub-neg36.0%
neg-sub036.0%
Simplified36.0%
fma-undefine36.0%
fma-undefine36.0%
associate-+r+36.0%
Applied egg-rr36.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (* x_m (pow PI -0.5)) (+ 2.0 (fma 0.047619047619047616 (pow x_m 6.0) (* 0.2 (pow x_m 4.0))))))
x_m = fabs(x);
double code(double x_m) {
return (x_m * pow(((double) M_PI), -0.5)) * (2.0 + fma(0.047619047619047616, pow(x_m, 6.0), (0.2 * pow(x_m, 4.0))));
}
x_m = abs(x) function code(x_m) return Float64(Float64(x_m * (pi ^ -0.5)) * Float64(2.0 + fma(0.047619047619047616, (x_m ^ 6.0), Float64(0.2 * (x_m ^ 4.0))))) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(0.047619047619047616 * N[Power[x$95$m, 6.0], $MachinePrecision] + N[(0.2 * N[Power[x$95$m, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\left(x\_m \cdot {\pi}^{-0.5}\right) \cdot \left(2 + \mathsf{fma}\left(0.047619047619047616, {x\_m}^{6}, 0.2 \cdot {x\_m}^{4}\right)\right)
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
*-un-lft-identity99.9%
inv-pow99.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
expm1-log1p-u99.5%
expm1-undefine36.1%
Applied egg-rr4.4%
sub-neg4.4%
metadata-eval4.4%
+-commutative4.4%
log1p-undefine4.4%
rem-exp-log4.4%
associate-+r+36.0%
metadata-eval36.0%
remove-double-neg36.0%
sub-neg36.0%
neg-sub036.0%
Simplified36.0%
Taylor expanded in x around inf 36.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (fabs x_m) (fabs (/ (+ 2.0 (* 0.047619047619047616 (pow x_m 6.0))) (sqrt PI)))))
x_m = fabs(x);
double code(double x_m) {
return fabs(x_m) * fabs(((2.0 + (0.047619047619047616 * pow(x_m, 6.0))) / sqrt(((double) M_PI))));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.abs(x_m) * Math.abs(((2.0 + (0.047619047619047616 * Math.pow(x_m, 6.0))) / Math.sqrt(Math.PI)));
}
x_m = math.fabs(x) def code(x_m): return math.fabs(x_m) * math.fabs(((2.0 + (0.047619047619047616 * math.pow(x_m, 6.0))) / math.sqrt(math.pi)))
x_m = abs(x) function code(x_m) return Float64(abs(x_m) * abs(Float64(Float64(2.0 + Float64(0.047619047619047616 * (x_m ^ 6.0))) / sqrt(pi)))) end
x_m = abs(x); function tmp = code(x_m) tmp = abs(x_m) * abs(((2.0 + (0.047619047619047616 * (x_m ^ 6.0))) / sqrt(pi))); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[Abs[x$95$m], $MachinePrecision] * N[Abs[N[(N[(2.0 + N[(0.047619047619047616 * N[Power[x$95$m, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\left|x\_m\right| \cdot \left|\frac{2 + 0.047619047619047616 \cdot {x\_m}^{6}}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 99.1%
Taylor expanded in x around 0 98.9%
Final simplification98.9%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (fabs x_m) 0.05) (* x_m (/ 2.0 (sqrt PI))) (* 0.047619047619047616 (* (pow x_m 6.0) (/ x_m (sqrt PI))))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (fabs(x_m) <= 0.05) {
tmp = x_m * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = 0.047619047619047616 * (pow(x_m, 6.0) * (x_m / sqrt(((double) M_PI))));
}
return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m) {
double tmp;
if (Math.abs(x_m) <= 0.05) {
tmp = x_m * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = 0.047619047619047616 * (Math.pow(x_m, 6.0) * (x_m / Math.sqrt(Math.PI)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m): tmp = 0 if math.fabs(x_m) <= 0.05: tmp = x_m * (2.0 / math.sqrt(math.pi)) else: tmp = 0.047619047619047616 * (math.pow(x_m, 6.0) * (x_m / math.sqrt(math.pi))) return tmp
x_m = abs(x) function code(x_m) tmp = 0.0 if (abs(x_m) <= 0.05) tmp = Float64(x_m * Float64(2.0 / sqrt(pi))); else tmp = Float64(0.047619047619047616 * Float64((x_m ^ 6.0) * Float64(x_m / sqrt(pi)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m) tmp = 0.0; if (abs(x_m) <= 0.05) tmp = x_m * (2.0 / sqrt(pi)); else tmp = 0.047619047619047616 * ((x_m ^ 6.0) * (x_m / sqrt(pi))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[Abs[x$95$m], $MachinePrecision], 0.05], N[(x$95$m * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.047619047619047616 * N[(N[Power[x$95$m, 6.0], $MachinePrecision] * N[(x$95$m / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\left|x\_m\right| \leq 0.05:\\
\;\;\;\;x\_m \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;0.047619047619047616 \cdot \left({x\_m}^{6} \cdot \frac{x\_m}{\sqrt{\pi}}\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 0.050000000000000003Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.3%
add-cbrt-cube39.5%
pow339.5%
inv-pow39.5%
sqrt-pow139.5%
metadata-eval39.5%
Applied egg-rr39.5%
rem-cbrt-cube99.3%
fabs-mul99.3%
metadata-eval99.3%
*-commutative99.3%
fabs-mul99.3%
sqr-pow99.3%
fabs-sqr99.3%
sqr-pow99.3%
fabs-fabs99.3%
add-sqr-sqrt49.9%
fabs-sqr49.9%
add-sqr-sqrt52.0%
Applied egg-rr52.0%
pow152.0%
*-commutative52.0%
metadata-eval52.0%
sqrt-pow152.0%
inv-pow52.0%
sqrt-div52.0%
metadata-eval52.0%
un-div-inv51.6%
Applied egg-rr51.6%
unpow151.6%
associate-*l/51.6%
associate-/l*52.0%
Simplified52.0%
if 0.050000000000000003 < (fabs.f64 x) Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 98.1%
add-sqr-sqrt0.0%
unpow-prod-down0.0%
Applied egg-rr0.0%
pow-sqr0.0%
metadata-eval0.0%
Simplified0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
*-commutative0.0%
Applied egg-rr0.1%
Final simplification36.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (fabs x_m) 0.05) (* x_m (/ 2.0 (sqrt PI))) (* (pow x_m 7.0) (/ 0.047619047619047616 (sqrt PI)))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (fabs(x_m) <= 0.05) {
tmp = x_m * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = pow(x_m, 7.0) * (0.047619047619047616 / sqrt(((double) M_PI)));
}
return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m) {
double tmp;
if (Math.abs(x_m) <= 0.05) {
tmp = x_m * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = Math.pow(x_m, 7.0) * (0.047619047619047616 / Math.sqrt(Math.PI));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m): tmp = 0 if math.fabs(x_m) <= 0.05: tmp = x_m * (2.0 / math.sqrt(math.pi)) else: tmp = math.pow(x_m, 7.0) * (0.047619047619047616 / math.sqrt(math.pi)) return tmp
x_m = abs(x) function code(x_m) tmp = 0.0 if (abs(x_m) <= 0.05) tmp = Float64(x_m * Float64(2.0 / sqrt(pi))); else tmp = Float64((x_m ^ 7.0) * Float64(0.047619047619047616 / sqrt(pi))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m) tmp = 0.0; if (abs(x_m) <= 0.05) tmp = x_m * (2.0 / sqrt(pi)); else tmp = (x_m ^ 7.0) * (0.047619047619047616 / sqrt(pi)); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[Abs[x$95$m], $MachinePrecision], 0.05], N[(x$95$m * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x$95$m, 7.0], $MachinePrecision] * N[(0.047619047619047616 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\left|x\_m\right| \leq 0.05:\\
\;\;\;\;x\_m \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{7} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 0.050000000000000003Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.3%
add-cbrt-cube39.5%
pow339.5%
inv-pow39.5%
sqrt-pow139.5%
metadata-eval39.5%
Applied egg-rr39.5%
rem-cbrt-cube99.3%
fabs-mul99.3%
metadata-eval99.3%
*-commutative99.3%
fabs-mul99.3%
sqr-pow99.3%
fabs-sqr99.3%
sqr-pow99.3%
fabs-fabs99.3%
add-sqr-sqrt49.9%
fabs-sqr49.9%
add-sqr-sqrt52.0%
Applied egg-rr52.0%
pow152.0%
*-commutative52.0%
metadata-eval52.0%
sqrt-pow152.0%
inv-pow52.0%
sqrt-div52.0%
metadata-eval52.0%
un-div-inv51.6%
Applied egg-rr51.6%
unpow151.6%
associate-*l/51.6%
associate-/l*52.0%
Simplified52.0%
if 0.050000000000000003 < (fabs.f64 x) Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 98.1%
add-sqr-sqrt0.0%
unpow-prod-down0.0%
Applied egg-rr0.0%
pow-sqr0.0%
metadata-eval0.0%
Simplified0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log0.1%
associate-+r+0.1%
metadata-eval0.1%
+-lft-identity0.1%
associate-*l*0.1%
associate-*r/0.1%
pow-plus0.1%
metadata-eval0.1%
associate-*r/0.1%
*-commutative0.1%
associate-/l*0.1%
Simplified0.1%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (* x_m (pow PI -0.5)) (+ 2.0 (* 0.047619047619047616 (pow x_m 6.0)))))
x_m = fabs(x);
double code(double x_m) {
return (x_m * pow(((double) M_PI), -0.5)) * (2.0 + (0.047619047619047616 * pow(x_m, 6.0)));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return (x_m * Math.pow(Math.PI, -0.5)) * (2.0 + (0.047619047619047616 * Math.pow(x_m, 6.0)));
}
x_m = math.fabs(x) def code(x_m): return (x_m * math.pow(math.pi, -0.5)) * (2.0 + (0.047619047619047616 * math.pow(x_m, 6.0)))
x_m = abs(x) function code(x_m) return Float64(Float64(x_m * (pi ^ -0.5)) * Float64(2.0 + Float64(0.047619047619047616 * (x_m ^ 6.0)))) end
x_m = abs(x); function tmp = code(x_m) tmp = (x_m * (pi ^ -0.5)) * (2.0 + (0.047619047619047616 * (x_m ^ 6.0))); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(0.047619047619047616 * N[Power[x$95$m, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\left(x\_m \cdot {\pi}^{-0.5}\right) \cdot \left(2 + 0.047619047619047616 \cdot {x\_m}^{6}\right)
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
*-un-lft-identity99.9%
inv-pow99.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
expm1-log1p-u99.5%
expm1-undefine36.1%
Applied egg-rr4.4%
sub-neg4.4%
metadata-eval4.4%
+-commutative4.4%
log1p-undefine4.4%
rem-exp-log4.4%
associate-+r+36.0%
metadata-eval36.0%
remove-double-neg36.0%
sub-neg36.0%
neg-sub036.0%
Simplified36.0%
Taylor expanded in x around inf 36.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* x_m (/ 2.0 (sqrt PI))))
x_m = fabs(x);
double code(double x_m) {
return x_m * (2.0 / sqrt(((double) M_PI)));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return x_m * (2.0 / Math.sqrt(Math.PI));
}
x_m = math.fabs(x) def code(x_m): return x_m * (2.0 / math.sqrt(math.pi))
x_m = abs(x) function code(x_m) return Float64(x_m * Float64(2.0 / sqrt(pi))) end
x_m = abs(x); function tmp = code(x_m) tmp = x_m * (2.0 / sqrt(pi)); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(x$95$m * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x\_m \cdot \frac{2}{\sqrt{\pi}}
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 70.6%
add-cbrt-cube48.5%
pow348.5%
inv-pow48.5%
sqrt-pow148.5%
metadata-eval48.5%
Applied egg-rr48.5%
rem-cbrt-cube70.6%
fabs-mul70.6%
metadata-eval70.6%
*-commutative70.6%
fabs-mul70.6%
sqr-pow70.6%
fabs-sqr70.6%
sqr-pow70.6%
fabs-fabs70.6%
add-sqr-sqrt34.5%
fabs-sqr34.5%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
pow136.0%
*-commutative36.0%
metadata-eval36.0%
sqrt-pow136.0%
inv-pow36.0%
sqrt-div36.0%
metadata-eval36.0%
un-div-inv35.8%
Applied egg-rr35.8%
unpow135.8%
associate-*l/35.8%
associate-/l*36.0%
Simplified36.0%
herbie shell --seed 2024182
(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)))))))