
(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 14 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
(*
(/ 1.0 (sqrt PI))
(fabs
(*
(fma
(fma (* x x) 0.2 0.6666666666666666)
(* x x)
(fma (pow x 6.0) 0.047619047619047616 2.0))
x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((fma(fma((x * x), 0.2, 0.6666666666666666), (x * x), fma(pow(x, 6.0), 0.047619047619047616, 2.0)) * x));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(fma(Float64(x * x), 0.2, 0.6666666666666666), Float64(x * x), fma((x ^ 6.0), 0.047619047619047616, 2.0)) * x))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * 0.2 + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(N[Power[x, 6.0], $MachinePrecision] * 0.047619047619047616 + 2.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, \mathsf{fma}\left({x}^{6}, 0.047619047619047616, 2\right)\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-+l+N/A
lower-fma.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-fma.f64N/A
lift-pow.f6499.9
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(*
(/ 1.0 (sqrt PI))
(fabs
(fma
(fabs x)
(* (fma (* x x) 0.047619047619047616 0.2) (* (* (* x x) x) x))
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs(fma(fabs(x), (fma((x * x), 0.047619047619047616, 0.2) * (((x * x) * x) * x)), (fabs(x) * fma((x * x), 0.6666666666666666, 2.0))));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(fma(abs(x), Float64(fma(Float64(x * x), 0.047619047619047616, 0.2) * Float64(Float64(Float64(x * x) * x) * x)), Float64(abs(x) * fma(Float64(x * x), 0.6666666666666666, 2.0))))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right) \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
pow-plusN/A
lower-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(*
(/ 1.0 (sqrt PI))
(fabs
(*
(fma
(fma (fma 0.047619047619047616 (* x x) 0.2) (* x x) 0.6666666666666666)
(* x x)
2.0)
x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((fma(fma(fma(0.047619047619047616, (x * x), 0.2), (x * x), 0.6666666666666666), (x * x), 2.0) * x));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(fma(fma(0.047619047619047616, Float64(x * x), 0.2), Float64(x * x), 0.6666666666666666), Float64(x * x), 2.0) * x))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(N[(0.047619047619047616 * N[(x * x), $MachinePrecision] + 0.2), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), x \cdot x, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(if (<= x 2.65)
(*
(/ 1.0 (sqrt PI))
(fabs (* (fma (fma (* x x) 0.2 0.6666666666666666) (* x x) 2.0) x)))
(/ (fabs (* (* (pow x 6.0) 0.047619047619047616) (fabs x))) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 2.65) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fma(fma((x * x), 0.2, 0.6666666666666666), (x * x), 2.0) * x));
} 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.65) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(fma(Float64(x * x), 0.2, 0.6666666666666666), Float64(x * x), 2.0) * x))); else tmp = Float64(abs(Float64(Float64((x ^ 6.0) * 0.047619047619047616) * abs(x))) / sqrt(pi)); end return tmp end
code[x_] := If[LessEqual[x, 2.65], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * 0.2 + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[(N[Power[x, 6.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.65:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left({x}^{6} \cdot 0.047619047619047616\right) \cdot \left|x\right|\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 2.64999999999999991Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f6493.1
Applied rewrites93.1%
if 2.64999999999999991 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lift-fabs.f6435.8
Applied rewrites35.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt PI))))
(if (<= x 2.65)
(*
t_0
(fabs (* (fma (fma (* x x) 0.2 0.6666666666666666) (* x x) 2.0) x)))
(* t_0 (fabs (* (pow x 7.0) 0.047619047619047616))))))
double code(double x) {
double t_0 = 1.0 / sqrt(((double) M_PI));
double tmp;
if (x <= 2.65) {
tmp = t_0 * fabs((fma(fma((x * x), 0.2, 0.6666666666666666), (x * x), 2.0) * x));
} else {
tmp = t_0 * fabs((pow(x, 7.0) * 0.047619047619047616));
}
return tmp;
}
function code(x) t_0 = Float64(1.0 / sqrt(pi)) tmp = 0.0 if (x <= 2.65) tmp = Float64(t_0 * abs(Float64(fma(fma(Float64(x * x), 0.2, 0.6666666666666666), Float64(x * x), 2.0) * x))); else tmp = Float64(t_0 * abs(Float64((x ^ 7.0) * 0.047619047619047616))); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.65], N[(t$95$0 * N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * 0.2 + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\pi}}\\
\mathbf{if}\;x \leq 2.65:\\
\;\;\;\;t\_0 \cdot \left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left|{x}^{7} \cdot 0.047619047619047616\right|\\
\end{array}
\end{array}
if x < 2.64999999999999991Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f6493.1
Applied rewrites93.1%
if 2.64999999999999991 < x Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt PI))))
(if (<= x 2.2)
(* t_0 (fabs (* (fma 0.6666666666666666 (* x x) 2.0) x)))
(* t_0 (fabs (* (pow x 7.0) 0.047619047619047616))))))
double code(double x) {
double t_0 = 1.0 / sqrt(((double) M_PI));
double tmp;
if (x <= 2.2) {
tmp = t_0 * fabs((fma(0.6666666666666666, (x * x), 2.0) * x));
} else {
tmp = t_0 * fabs((pow(x, 7.0) * 0.047619047619047616));
}
return tmp;
}
function code(x) t_0 = Float64(1.0 / sqrt(pi)) tmp = 0.0 if (x <= 2.2) tmp = Float64(t_0 * abs(Float64(fma(0.6666666666666666, Float64(x * x), 2.0) * x))); else tmp = Float64(t_0 * abs(Float64((x ^ 7.0) * 0.047619047619047616))); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.2], N[(t$95$0 * N[Abs[N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\pi}}\\
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;t\_0 \cdot \left|\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left|{x}^{7} \cdot 0.047619047619047616\right|\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lift-*.f6488.9
Applied rewrites88.9%
if 2.2000000000000002 < x Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6435.8
Applied rewrites35.8%
(FPCore (x) :precision binary64 (fabs (* (fma (pow (fabs x) 7.0) -0.047619047619047616 (* -2.0 (fabs x))) (/ 1.0 (sqrt PI)))))
double code(double x) {
return fabs((fma(pow(fabs(x), 7.0), -0.047619047619047616, (-2.0 * fabs(x))) * (1.0 / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(fma((abs(x) ^ 7.0), -0.047619047619047616, Float64(-2.0 * abs(x))) * Float64(1.0 / sqrt(pi)))) end
code[x_] := N[Abs[N[(N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * -0.047619047619047616 + N[(-2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, -0.047619047619047616, -2 \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites73.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
lift-fabs.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift-fabs.f64N/A
inv-powN/A
sqrt-pow1N/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
Applied rewrites98.8%
(FPCore (x) :precision binary64 (/ (fabs (- (* (pow (fabs x) 7.0) -0.047619047619047616) (+ x x))) (sqrt PI)))
double code(double x) {
return fabs(((pow(fabs(x), 7.0) * -0.047619047619047616) - (x + x))) / sqrt(((double) M_PI));
}
public static double code(double x) {
return Math.abs(((Math.pow(Math.abs(x), 7.0) * -0.047619047619047616) - (x + x))) / Math.sqrt(Math.PI);
}
def code(x): return math.fabs(((math.pow(math.fabs(x), 7.0) * -0.047619047619047616) - (x + x))) / math.sqrt(math.pi)
function code(x) return Float64(abs(Float64(Float64((abs(x) ^ 7.0) * -0.047619047619047616) - Float64(x + x))) / sqrt(pi)) end
function tmp = code(x) tmp = abs((((abs(x) ^ 7.0) * -0.047619047619047616) - (x + x))) / sqrt(pi); end
code[x_] := N[(N[Abs[N[(N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * -0.047619047619047616), $MachinePrecision] - N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|{\left(\left|x\right|\right)}^{7} \cdot -0.047619047619047616 - \left(x + x\right)\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites73.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-pow.f64N/A
lift-fabs.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift-fabs.f6498.4
Applied rewrites98.4%
Applied rewrites98.4%
Applied rewrites98.4%
(FPCore (x) :precision binary64 (if (<= x 2.25) (* (/ 1.0 (sqrt PI)) (fabs (* (fma 0.6666666666666666 (* x x) 2.0) x))) (fabs (/ (* -0.2 (* (* (* x x) (* x x)) x)) (sqrt PI)))))
double code(double x) {
double tmp;
if (x <= 2.25) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fma(0.6666666666666666, (x * x), 2.0) * x));
} else {
tmp = fabs(((-0.2 * (((x * x) * (x * x)) * x)) / sqrt(((double) M_PI))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 2.25) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(0.6666666666666666, Float64(x * x), 2.0) * x))); else tmp = abs(Float64(Float64(-0.2 * Float64(Float64(Float64(x * x) * Float64(x * x)) * x)) / sqrt(pi))); end return tmp end
code[x_] := If[LessEqual[x, 2.25], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[(-0.2 * N[(N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-0.2 \cdot \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x\right)}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 2.25Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lift-*.f6488.9
Applied rewrites88.9%
if 2.25 < x Initial program 99.8%
Applied rewrites73.8%
Taylor expanded in x around inf
lower-*.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow2N/A
associate-*l*N/A
lower-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6429.7
Applied rewrites29.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
unpow3N/A
pow2N/A
associate-*l*N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6429.7
Applied rewrites29.7%
(FPCore (x) :precision binary64 (* (/ 1.0 (sqrt PI)) (fabs (* (fma 0.6666666666666666 (* x x) 2.0) x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((fma(0.6666666666666666, (x * x), 2.0) * x));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(0.6666666666666666, Float64(x * x), 2.0) * x))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lift-*.f6488.9
Applied rewrites88.9%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (* x x) 0.6666666666666666 2.0) (fabs x))) (sqrt PI)))
double code(double x) {
return fabs((fma((x * x), 0.6666666666666666, 2.0) * fabs(x))) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * abs(x))) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|x\right|\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-/.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-pow.f6433.8
Applied rewrites33.8%
Taylor expanded in x around 0
associate-*r*N/A
*-commutativeN/A
pow2N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fabs.f6488.4
Applied rewrites88.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (/ 1.0 (sqrt PI)))
(t_2 (* (* t_0 (fabs x)) (fabs x))))
(if (<=
(fabs
(*
t_1
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_2))
(* (/ 1.0 21.0) (* (* t_2 (fabs x)) (fabs x))))))
5e-13)
(* t_1 (fabs (+ x x)))
(sqrt (/ (* (+ x x) (+ x x)) PI)))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = 1.0 / sqrt(((double) M_PI));
double t_2 = (t_0 * fabs(x)) * fabs(x);
double tmp;
if (fabs((t_1 * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * fabs(x)) * fabs(x)))))) <= 5e-13) {
tmp = t_1 * fabs((x + x));
} else {
tmp = sqrt((((x + x) * (x + x)) / ((double) M_PI)));
}
return tmp;
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = 1.0 / Math.sqrt(Math.PI);
double t_2 = (t_0 * Math.abs(x)) * Math.abs(x);
double tmp;
if (Math.abs((t_1 * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * Math.abs(x)) * Math.abs(x)))))) <= 5e-13) {
tmp = t_1 * Math.abs((x + x));
} else {
tmp = Math.sqrt((((x + x) * (x + x)) / Math.PI));
}
return tmp;
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = 1.0 / math.sqrt(math.pi) t_2 = (t_0 * math.fabs(x)) * math.fabs(x) tmp = 0 if math.fabs((t_1 * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * math.fabs(x)) * math.fabs(x)))))) <= 5e-13: tmp = t_1 * math.fabs((x + x)) else: tmp = math.sqrt((((x + x) * (x + x)) / math.pi)) return tmp
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(1.0 / sqrt(pi)) t_2 = Float64(Float64(t_0 * abs(x)) * abs(x)) tmp = 0.0 if (abs(Float64(t_1 * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_2)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_2 * abs(x)) * abs(x)))))) <= 5e-13) tmp = Float64(t_1 * abs(Float64(x + x))); else tmp = sqrt(Float64(Float64(Float64(x + x) * Float64(x + x)) / pi)); end return tmp end
function tmp_2 = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = 1.0 / sqrt(pi); t_2 = (t_0 * abs(x)) * abs(x); tmp = 0.0; if (abs((t_1 * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * abs(x)) * abs(x)))))) <= 5e-13) tmp = t_1 * abs((x + x)); else tmp = sqrt((((x + x) * (x + x)) / pi)); end tmp_2 = tmp; 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[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[N[(t$95$1 * 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$2), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 5e-13], N[(t$95$1 * N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(N[(x + x), $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision] / Pi), $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 := \frac{1}{\sqrt{\pi}}\\
t_2 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\mathbf{if}\;\left|t\_1 \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_2\right) + \frac{1}{21} \cdot \left(\left(t\_2 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \leq 5 \cdot 10^{-13}:\\
\;\;\;\;t\_1 \cdot \left|x + x\right|\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\left(x + x\right) \cdot \left(x + x\right)}{\pi}}\\
\end{array}
\end{array}
if (fabs.f64 (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 (PI.f64))) (+.f64 (+.f64 (+.f64 (*.f64 #s(literal 2 binary64) (fabs.f64 x)) (*.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 5 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 21 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))))) < 4.9999999999999999e-13Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6468.8
Applied rewrites68.8%
if 4.9999999999999999e-13 < (fabs.f64 (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 (PI.f64))) (+.f64 (+.f64 (+.f64 (*.f64 #s(literal 2 binary64) (fabs.f64 x)) (*.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 5 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 21 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))))) Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-/.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-pow.f6433.8
Applied rewrites33.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f6468.4
Applied rewrites68.4%
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-PI.f64N/A
lift-sqrt.f64N/A
Applied rewrites52.4%
(FPCore (x) :precision binary64 (* (/ 1.0 (sqrt PI)) (fabs (+ x x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((x + x));
}
public static double code(double x) {
return (1.0 / Math.sqrt(Math.PI)) * Math.abs((x + x));
}
def code(x): return (1.0 / math.sqrt(math.pi)) * math.fabs((x + x))
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(x + x))) end
function tmp = code(x) tmp = (1.0 / sqrt(pi)) * abs((x + x)); end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|x + x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6468.8
Applied rewrites68.8%
(FPCore (x) :precision binary64 (/ (fabs (+ x x)) (sqrt PI)))
double code(double x) {
return fabs((x + x)) / sqrt(((double) M_PI));
}
public static double code(double x) {
return Math.abs((x + x)) / Math.sqrt(Math.PI);
}
def code(x): return math.fabs((x + x)) / math.sqrt(math.pi)
function code(x) return Float64(abs(Float64(x + x)) / sqrt(pi)) end
function tmp = code(x) tmp = abs((x + x)) / sqrt(pi); end
code[x_] := N[(N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x + x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-/.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-pow.f6433.8
Applied rewrites33.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f6468.4
Applied rewrites68.4%
lift-*.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
count-2-revN/A
flip3-+N/A
Applied rewrites68.4%
herbie shell --seed 2025132
(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)))))))