
(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}
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
(*
(/ 1.0 (sqrt PI))
(fma
(pow (fabs x) 7.0)
0.047619047619047616
(fma
(pow (fabs x) 5.0)
0.2
(fma (* 0.6666666666666666 (* x x)) (fabs x) (* (fabs x) 2.0)))))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, fma(pow(fabs(x), 5.0), 0.2, fma((0.6666666666666666 * (x * x)), fabs(x), (fabs(x) * 2.0))))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, fma((abs(x) ^ 5.0), 0.2, fma(Float64(0.6666666666666666 * Float64(x * x)), abs(x), Float64(abs(x) * 2.0)))))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616 + N[(N[Power[N[Abs[x], $MachinePrecision], 5.0], $MachinePrecision] * 0.2 + N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left({\left(\left|x\right|\right)}^{5}, 0.2, \mathsf{fma}\left(0.6666666666666666 \cdot \left(x \cdot x\right), \left|x\right|, \left|x\right| \cdot 2\right)\right)\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(fma
(fma
(* (fabs x) (fma (* x x) 0.047619047619047616 0.2))
(* x x)
(* 0.6666666666666666 (fabs x)))
(* x x)
(* (fabs x) 2.0))
(/ 1.0 (sqrt PI)))))
double code(double x) {
return fabs((fma(fma((fabs(x) * fma((x * x), 0.047619047619047616, 0.2)), (x * x), (0.6666666666666666 * fabs(x))), (x * x), (fabs(x) * 2.0)) * (1.0 / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(fma(fma(Float64(abs(x) * fma(Float64(x * x), 0.047619047619047616, 0.2)), Float64(x * x), Float64(0.6666666666666666 * abs(x))), Float64(x * x), Float64(abs(x) * 2.0)) * Float64(1.0 / sqrt(pi)))) end
code[x_] := N[Abs[N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(0.6666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\mathsf{fma}\left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), x \cdot x, 0.6666666666666666 \cdot \left|x\right|\right), x \cdot x, \left|x\right| \cdot 2\right) \cdot \frac{1}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
metadata-evalN/A
lift-fabs.f64N/A
metadata-evalN/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-eval99.8
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(if (<= x 1.85)
(fabs
(*
(fma (* 0.6666666666666666 (* x x)) (fabs x) (* (fabs x) 2.0))
(/ 1.0 (sqrt PI))))
(fabs
(/
(*
(fma (/ (fabs x) (* x x)) 0.2 (* 0.047619047619047616 (fabs x)))
(pow x 6.0))
(sqrt PI)))))
double code(double x) {
double tmp;
if (x <= 1.85) {
tmp = fabs((fma((0.6666666666666666 * (x * x)), fabs(x), (fabs(x) * 2.0)) * (1.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs(((fma((fabs(x) / (x * x)), 0.2, (0.047619047619047616 * fabs(x))) * pow(x, 6.0)) / sqrt(((double) M_PI))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.85) tmp = abs(Float64(fma(Float64(0.6666666666666666 * Float64(x * x)), abs(x), Float64(abs(x) * 2.0)) * Float64(1.0 / sqrt(pi)))); else tmp = abs(Float64(Float64(fma(Float64(abs(x) / Float64(x * x)), 0.2, Float64(0.047619047619047616 * abs(x))) * (x ^ 6.0)) / sqrt(pi))); end return tmp end
code[x_] := If[LessEqual[x, 1.85], N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(N[Abs[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] * 0.2 + N[(0.047619047619047616 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.85:\\
\;\;\;\;\left|\mathsf{fma}\left(0.6666666666666666 \cdot \left(x \cdot x\right), \left|x\right|, \left|x\right| \cdot 2\right) \cdot \frac{1}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\frac{\left|x\right|}{x \cdot x}, 0.2, 0.047619047619047616 \cdot \left|x\right|\right) \cdot {x}^{6}}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 1.8500000000000001Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2-fabs-revN/A
pow2N/A
pow3N/A
pow3N/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift-fabs.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-*.f6489.3
Applied rewrites89.3%
if 1.8500000000000001 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites34.3%
metadata-evalN/A
metadata-evalN/A
Applied rewrites34.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt PI))))
(if (<= x 1.85)
(fabs
(* (fma (* 0.6666666666666666 (* x x)) (fabs x) (* (fabs x) 2.0)) t_0))
(fabs
(*
(* (pow x 4.0) (* (fabs x) (fma (* x x) 0.047619047619047616 0.2)))
t_0)))))
double code(double x) {
double t_0 = 1.0 / sqrt(((double) M_PI));
double tmp;
if (x <= 1.85) {
tmp = fabs((fma((0.6666666666666666 * (x * x)), fabs(x), (fabs(x) * 2.0)) * t_0));
} else {
tmp = fabs(((pow(x, 4.0) * (fabs(x) * fma((x * x), 0.047619047619047616, 0.2))) * t_0));
}
return tmp;
}
function code(x) t_0 = Float64(1.0 / sqrt(pi)) tmp = 0.0 if (x <= 1.85) tmp = abs(Float64(fma(Float64(0.6666666666666666 * Float64(x * x)), abs(x), Float64(abs(x) * 2.0)) * t_0)); else tmp = abs(Float64(Float64((x ^ 4.0) * Float64(abs(x) * fma(Float64(x * x), 0.047619047619047616, 0.2))) * t_0)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.85], N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\pi}}\\
\mathbf{if}\;x \leq 1.85:\\
\;\;\;\;\left|\mathsf{fma}\left(0.6666666666666666 \cdot \left(x \cdot x\right), \left|x\right|, \left|x\right| \cdot 2\right) \cdot t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left({x}^{4} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right)\right)\right) \cdot t\_0\right|\\
\end{array}
\end{array}
if x < 1.8500000000000001Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2-fabs-revN/A
pow2N/A
pow3N/A
pow3N/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift-fabs.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-*.f6489.3
Applied rewrites89.3%
if 1.8500000000000001 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites34.3%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f64N/A
pow2-fabs-revN/A
pow2N/A
pow2N/A
pow2-fabs-revN/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
Applied rewrites36.6%
(FPCore (x)
:precision binary64
(if (<= x 2.2)
(fabs
(*
(fma (* 0.6666666666666666 (* x x)) (fabs x) (* (fabs x) 2.0))
(/ 1.0 (sqrt PI))))
(fabs (/ (* (* (pow x 6.0) 0.047619047619047616) (fabs x)) (sqrt PI)))))
double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = fabs((fma((0.6666666666666666 * (x * x)), fabs(x), (fabs(x) * 2.0)) * (1.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs((((pow(x, 6.0) * 0.047619047619047616) * fabs(x)) / sqrt(((double) M_PI))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 2.2) tmp = abs(Float64(fma(Float64(0.6666666666666666 * Float64(x * x)), abs(x), Float64(abs(x) * 2.0)) * Float64(1.0 / sqrt(pi)))); else tmp = abs(Float64(Float64(Float64((x ^ 6.0) * 0.047619047619047616) * abs(x)) / sqrt(pi))); end return tmp end
code[x_] := If[LessEqual[x, 2.2], N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Power[x, 6.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;\left|\mathsf{fma}\left(0.6666666666666666 \cdot \left(x \cdot x\right), \left|x\right|, \left|x\right| \cdot 2\right) \cdot \frac{1}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left({x}^{6} \cdot 0.047619047619047616\right) \cdot \left|x\right|}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2-fabs-revN/A
pow2N/A
pow3N/A
pow3N/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift-fabs.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-*.f6489.3
Applied rewrites89.3%
if 2.2000000000000002 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites36.3%
(FPCore (x)
:precision binary64
(fabs
(/
(fma
(*
(fma
(* (* (fabs x) (fma (* x x) 0.047619047619047616 0.2)) x)
x
(* 0.6666666666666666 (fabs x)))
x)
x
(* (fabs x) 2.0))
(sqrt PI))))
double code(double x) {
return fabs((fma((fma(((fabs(x) * fma((x * x), 0.047619047619047616, 0.2)) * x), x, (0.6666666666666666 * fabs(x))) * x), x, (fabs(x) * 2.0)) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(fma(Float64(fma(Float64(Float64(abs(x) * fma(Float64(x * x), 0.047619047619047616, 0.2)) * x), x, Float64(0.6666666666666666 * abs(x))) * x), x, Float64(abs(x) * 2.0)) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x + N[(0.6666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right)\right) \cdot x, x, 0.6666666666666666 \cdot \left|x\right|\right) \cdot x, x, \left|x\right| \cdot 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Applied rewrites99.4%
(FPCore (x) :precision binary64 (fabs (* (fma (* 0.6666666666666666 (* x x)) (fabs x) (* (fabs x) 2.0)) (/ 1.0 (sqrt PI)))))
double code(double x) {
return fabs((fma((0.6666666666666666 * (x * x)), fabs(x), (fabs(x) * 2.0)) * (1.0 / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(fma(Float64(0.6666666666666666 * Float64(x * x)), abs(x), Float64(abs(x) * 2.0)) * Float64(1.0 / sqrt(pi)))) end
code[x_] := N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(0.6666666666666666 \cdot \left(x \cdot x\right), \left|x\right|, \left|x\right| \cdot 2\right) \cdot \frac{1}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2-fabs-revN/A
pow2N/A
pow3N/A
pow3N/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift-fabs.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-*.f6489.3
Applied rewrites89.3%
(FPCore (x) :precision binary64 (if (<= x 1.7) (fabs (* (fabs x) (/ 2.0 (sqrt PI)))) (/ (fabs (* (* (* x x) (fabs x)) 0.6666666666666666)) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = fabs((fabs(x) * (2.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs((((x * x) * fabs(x)) * 0.6666666666666666)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = Math.abs((Math.abs(x) * (2.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs((((x * x) * Math.abs(x)) * 0.6666666666666666)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = math.fabs((math.fabs(x) * (2.0 / math.sqrt(math.pi)))) else: tmp = math.fabs((((x * x) * math.fabs(x)) * 0.6666666666666666)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = abs(Float64(abs(x) * Float64(2.0 / sqrt(pi)))); else tmp = Float64(abs(Float64(Float64(Float64(x * x) * abs(x)) * 0.6666666666666666)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = abs((abs(x) * (2.0 / sqrt(pi)))); else tmp = abs((((x * x) * abs(x)) * 0.6666666666666666)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.6666666666666666), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;\left|\left|x\right| \cdot \frac{2}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(\left(x \cdot x\right) \cdot \left|x\right|\right) \cdot 0.6666666666666666\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites67.7%
lift-/.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
if 1.69999999999999996 < x Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.4%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
pow2-fabs-revN/A
pow2N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
lift-*.f64N/A
metadata-eval26.9
Applied rewrites26.9%
(FPCore (x) :precision binary64 (if (<= x 1e-8) (fabs (* (fabs x) (/ 2.0 (sqrt PI)))) (fabs (/ (* (sqrt (* x x)) 2.0) (sqrt PI)))))
double code(double x) {
double tmp;
if (x <= 1e-8) {
tmp = fabs((fabs(x) * (2.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs(((sqrt((x * x)) * 2.0) / sqrt(((double) M_PI))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1e-8) {
tmp = Math.abs((Math.abs(x) * (2.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs(((Math.sqrt((x * x)) * 2.0) / Math.sqrt(Math.PI)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e-8: tmp = math.fabs((math.fabs(x) * (2.0 / math.sqrt(math.pi)))) else: tmp = math.fabs(((math.sqrt((x * x)) * 2.0) / math.sqrt(math.pi))) return tmp
function code(x) tmp = 0.0 if (x <= 1e-8) tmp = abs(Float64(abs(x) * Float64(2.0 / sqrt(pi)))); else tmp = abs(Float64(Float64(sqrt(Float64(x * x)) * 2.0) / sqrt(pi))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e-8) tmp = abs((abs(x) * (2.0 / sqrt(pi)))); else tmp = abs(((sqrt((x * x)) * 2.0) / sqrt(pi))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e-8], N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-8}:\\
\;\;\;\;\left|\left|x\right| \cdot \frac{2}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\sqrt{x \cdot x} \cdot 2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 1e-8Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites67.7%
lift-/.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
if 1e-8 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites67.7%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
lower-sqrt.f6453.2
Applied rewrites53.2%
(FPCore (x) :precision binary64 (fabs (* (fabs x) (/ 2.0 (sqrt PI)))))
double code(double x) {
return fabs((fabs(x) * (2.0 / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((Math.abs(x) * (2.0 / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((math.fabs(x) * (2.0 / math.sqrt(math.pi))))
function code(x) return abs(Float64(abs(x) * Float64(2.0 / sqrt(pi)))) end
function tmp = code(x) tmp = abs((abs(x) * (2.0 / sqrt(pi)))); end
code[x_] := N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left|x\right| \cdot \frac{2}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites67.7%
lift-/.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
herbie shell --seed 2025135
(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)))))))