
(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 11 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
(/
(fma
(*
(fma (fma (* 0.047619047619047616 x) x 0.2) (* x x) 0.6666666666666666)
x)
x
2.0)
(sqrt PI)))))
double code(double x) {
return fabs((x * (fma((fma(fma((0.047619047619047616 * x), x, 0.2), (x * x), 0.6666666666666666) * x), x, 2.0) / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(x * Float64(fma(Float64(fma(fma(Float64(0.047619047619047616 * x), x, 0.2), Float64(x * x), 0.6666666666666666) * x), x, 2.0) / sqrt(pi)))) end
code[x_] := N[Abs[N[(x * N[(N[(N[(N[(N[(N[(0.047619047619047616 * x), $MachinePrecision] * x + 0.2), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * x), $MachinePrecision] * x + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|x \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.047619047619047616 \cdot x, x, 0.2\right), x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
lift-*.f64N/A
pow2N/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(if (<= x 1.86)
(fabs
(*
(fma (* (/ 0.6666666666666666 (sqrt PI)) x) x (/ 2.0 (sqrt PI)))
(fabs x)))
(fabs
(*
(*
(* (* (/ (fma (* x x) 0.047619047619047616 0.2) (sqrt PI)) (* x x)) x)
x)
x))))
double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = fabs((fma(((0.6666666666666666 / sqrt(((double) M_PI))) * x), x, (2.0 / sqrt(((double) M_PI)))) * fabs(x)));
} else {
tmp = fabs((((((fma((x * x), 0.047619047619047616, 0.2) / sqrt(((double) M_PI))) * (x * x)) * x) * x) * x));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 1.86) tmp = abs(Float64(fma(Float64(Float64(0.6666666666666666 / sqrt(pi)) * x), x, Float64(2.0 / sqrt(pi))) * abs(x))); else tmp = abs(Float64(Float64(Float64(Float64(Float64(fma(Float64(x * x), 0.047619047619047616, 0.2) / sqrt(pi)) * Float64(x * x)) * x) * x) * x)); end return tmp end
code[x_] := If[LessEqual[x, 1.86], N[Abs[N[(N[(N[(N[(0.6666666666666666 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x + N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{0.6666666666666666}{\sqrt{\pi}} \cdot x, x, \frac{2}{\sqrt{\pi}}\right) \cdot \left|x\right|\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\left(\left(\frac{\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right)}{\sqrt{\pi}} \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\right) \cdot x\right|\\
\end{array}
\end{array}
if x < 1.8600000000000001Initial program 99.8%
Applied rewrites82.9%
Taylor expanded in x around 0
associate-*r/N/A
associate-*r/N/A
div-add-revN/A
Applied rewrites89.1%
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
div-addN/A
pow2N/A
*-commutativeN/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
pow2N/A
associate-*r*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites89.1%
if 1.8600000000000001 < x Initial program 99.8%
Applied rewrites82.9%
Taylor expanded in x around 0
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lift-sqrt.f6467.9
Applied rewrites67.9%
Taylor expanded in x around inf
Applied rewrites36.9%
(FPCore (x)
:precision binary64
(if (<= x 2.2)
(fabs
(*
(fma (* (/ 0.6666666666666666 (sqrt PI)) x) x (/ 2.0 (sqrt PI)))
(fabs x)))
(fabs (* (/ (pow x 7.0) (sqrt PI)) 0.047619047619047616))))
double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = fabs((fma(((0.6666666666666666 / sqrt(((double) M_PI))) * x), x, (2.0 / sqrt(((double) M_PI)))) * fabs(x)));
} else {
tmp = fabs(((pow(x, 7.0) / sqrt(((double) M_PI))) * 0.047619047619047616));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 2.2) tmp = abs(Float64(fma(Float64(Float64(0.6666666666666666 / sqrt(pi)) * x), x, Float64(2.0 / sqrt(pi))) * abs(x))); else tmp = abs(Float64(Float64((x ^ 7.0) / sqrt(pi)) * 0.047619047619047616)); end return tmp end
code[x_] := If[LessEqual[x, 2.2], N[Abs[N[(N[(N[(N[(0.6666666666666666 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x + N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Power[x, 7.0], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{0.6666666666666666}{\sqrt{\pi}} \cdot x, x, \frac{2}{\sqrt{\pi}}\right) \cdot \left|x\right|\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{{x}^{7}}{\sqrt{\pi}} \cdot 0.047619047619047616\right|\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.8%
Applied rewrites82.9%
Taylor expanded in x around 0
associate-*r/N/A
associate-*r/N/A
div-add-revN/A
Applied rewrites89.1%
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
div-addN/A
pow2N/A
*-commutativeN/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
pow2N/A
associate-*r*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites89.1%
if 2.2000000000000002 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
associate-*r/N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sqr-powN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites36.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-powN/A
metadata-evalN/A
*-commutativeN/A
associate-*l*N/A
associate-/l*N/A
Applied rewrites36.6%
(FPCore (x)
:precision binary64
(fabs
(*
x
(/
(fma (* (* (* (fma (* x x) 0.047619047619047616 0.2) x) x) x) x 2.0)
(sqrt PI)))))
double code(double x) {
return fabs((x * (fma((((fma((x * x), 0.047619047619047616, 0.2) * x) * x) * x), x, 2.0) / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(x * Float64(fma(Float64(Float64(Float64(fma(Float64(x * x), 0.047619047619047616, 0.2) * x) * x) * x), x, 2.0) / sqrt(pi)))) end
code[x_] := N[Abs[N[(x * N[(N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|x \cdot \frac{\mathsf{fma}\left(\left(\left(\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right) \cdot x\right) \cdot x\right) \cdot x, x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
distribute-rgt-inN/A
associate-*l*N/A
pow-flipN/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
associate-*l*N/A
distribute-rgt-inN/A
pow2N/A
+-commutativeN/A
associate-*l*N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
Applied rewrites99.0%
(FPCore (x) :precision binary64 (fabs (* (fma (* (/ 0.6666666666666666 (sqrt PI)) x) x (/ 2.0 (sqrt PI))) (fabs x))))
double code(double x) {
return fabs((fma(((0.6666666666666666 / sqrt(((double) M_PI))) * x), x, (2.0 / sqrt(((double) M_PI)))) * fabs(x)));
}
function code(x) return abs(Float64(fma(Float64(Float64(0.6666666666666666 / sqrt(pi)) * x), x, Float64(2.0 / sqrt(pi))) * abs(x))) end
code[x_] := N[Abs[N[(N[(N[(N[(0.6666666666666666 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x + N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\frac{0.6666666666666666}{\sqrt{\pi}} \cdot x, x, \frac{2}{\sqrt{\pi}}\right) \cdot \left|x\right|\right|
\end{array}
Initial program 99.8%
Applied rewrites82.9%
Taylor expanded in x around 0
associate-*r/N/A
associate-*r/N/A
div-add-revN/A
Applied rewrites89.1%
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
div-addN/A
pow2N/A
*-commutativeN/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
pow2N/A
associate-*r*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites89.1%
(FPCore (x) :precision binary64 (fabs (* x (/ (fma (* 0.6666666666666666 x) x 2.0) (sqrt PI)))))
double code(double x) {
return fabs((x * (fma((0.6666666666666666 * x), x, 2.0) / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(x * Float64(fma(Float64(0.6666666666666666 * x), x, 2.0) / sqrt(pi)))) end
code[x_] := N[Abs[N[(x * N[(N[(N[(0.6666666666666666 * x), $MachinePrecision] * x + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|x \cdot \frac{\mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites89.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(if (<=
(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))))))
2e-5)
(fabs (* x (/ 2.0 (sqrt PI))))
(fabs (* (* x (* x (/ x (sqrt PI)))) 0.6666666666666666)))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
double tmp;
if (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)))))) <= 2e-5) {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs(((x * (x * (x / sqrt(((double) M_PI))))) * 0.6666666666666666));
}
return tmp;
}
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);
double tmp;
if (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)))))) <= 2e-5) {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs(((x * (x * (x / Math.sqrt(Math.PI)))) * 0.6666666666666666));
}
return tmp;
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) tmp = 0 if 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)))))) <= 2e-5: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) else: tmp = math.fabs(((x * (x * (x / math.sqrt(math.pi)))) * 0.6666666666666666)) return tmp
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) tmp = 0.0 if (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)))))) <= 2e-5) tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); else tmp = abs(Float64(Float64(x * Float64(x * Float64(x / sqrt(pi)))) * 0.6666666666666666)); end return tmp end
function tmp_2 = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = 0.0; if (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)))))) <= 2e-5) tmp = abs((x * (2.0 / sqrt(pi)))); else tmp = abs(((x * (x * (x / sqrt(pi)))) * 0.6666666666666666)); 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[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], 2e-5], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * N[(x * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.6666666666666666), $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|\\
\mathbf{if}\;\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| \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(x \cdot \left(x \cdot \frac{x}{\sqrt{\pi}}\right)\right) \cdot 0.6666666666666666\right|\\
\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)))))) < 2.00000000000000016e-5Initial program 99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.7%
if 2.00000000000000016e-5 < (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.7%
Applied rewrites50.4%
Taylor expanded in x around 0
associate-*r/N/A
associate-*r/N/A
div-add-revN/A
Applied rewrites68.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(if (<=
(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))))))
5e-9)
(fabs (* x (/ 2.0 (sqrt PI))))
(/ (fabs (* (sqrt (* x x)) 2.0)) (sqrt PI)))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
double tmp;
if (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)))))) <= 5e-9) {
tmp = 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 t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
double tmp;
if (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)))))) <= 5e-9) {
tmp = 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): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) tmp = 0 if 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)))))) <= 5e-9: tmp = 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) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) tmp = 0.0 if (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)))))) <= 5e-9) tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); else tmp = Float64(abs(Float64(sqrt(Float64(x * x)) * 2.0)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = 0.0; if (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)))))) <= 5e-9) tmp = abs((x * (2.0 / sqrt(pi)))); else tmp = abs((sqrt((x * x)) * 2.0)) / sqrt(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[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], 5e-9], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[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 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\mathbf{if}\;\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| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\sqrt{x \cdot x} \cdot 2\right|}{\sqrt{\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)))))) < 5.0000000000000001e-9Initial program 99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
if 5.0000000000000001e-9 < (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.7%
Applied rewrites36.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f648.9
Applied rewrites8.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
pow2N/A
lower-sqrt.f64N/A
pow2N/A
lift-*.f6452.8
Applied rewrites52.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 2.0 (sqrt PI)))
(t_1 (* (* (fabs x) (fabs x)) (fabs x)))
(t_2 (* (* t_1 (fabs x)) (fabs x))))
(if (<=
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_1)) (* (/ 1.0 5.0) t_2))
(* (/ 1.0 21.0) (* (* t_2 (fabs x)) (fabs x))))))
1e-157)
(fabs (* x t_0))
(fabs (* (sqrt (* x x)) t_0)))))
double code(double x) {
double t_0 = 2.0 / sqrt(((double) M_PI));
double t_1 = (fabs(x) * fabs(x)) * fabs(x);
double t_2 = (t_1 * fabs(x)) * fabs(x);
double tmp;
if (fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_1)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * fabs(x)) * fabs(x)))))) <= 1e-157) {
tmp = fabs((x * t_0));
} else {
tmp = fabs((sqrt((x * x)) * t_0));
}
return tmp;
}
public static double code(double x) {
double t_0 = 2.0 / Math.sqrt(Math.PI);
double t_1 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_2 = (t_1 * Math.abs(x)) * Math.abs(x);
double tmp;
if (Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_1)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * Math.abs(x)) * Math.abs(x)))))) <= 1e-157) {
tmp = Math.abs((x * t_0));
} else {
tmp = Math.abs((Math.sqrt((x * x)) * t_0));
}
return tmp;
}
def code(x): t_0 = 2.0 / math.sqrt(math.pi) t_1 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_2 = (t_1 * math.fabs(x)) * math.fabs(x) tmp = 0 if math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_1)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * math.fabs(x)) * math.fabs(x)))))) <= 1e-157: tmp = math.fabs((x * t_0)) else: tmp = math.fabs((math.sqrt((x * x)) * t_0)) return tmp
function code(x) t_0 = Float64(2.0 / sqrt(pi)) t_1 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_2 = Float64(Float64(t_1 * abs(x)) * abs(x)) tmp = 0.0 if (abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_1)) + Float64(Float64(1.0 / 5.0) * t_2)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_2 * abs(x)) * abs(x)))))) <= 1e-157) tmp = abs(Float64(x * t_0)); else tmp = abs(Float64(sqrt(Float64(x * x)) * t_0)); end return tmp end
function tmp_2 = code(x) t_0 = 2.0 / sqrt(pi); t_1 = (abs(x) * abs(x)) * abs(x); t_2 = (t_1 * abs(x)) * abs(x); tmp = 0.0; if (abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_1)) + ((1.0 / 5.0) * t_2)) + ((1.0 / 21.0) * ((t_2 * abs(x)) * abs(x)))))) <= 1e-157) tmp = abs((x * t_0)); else tmp = abs((sqrt((x * x)) * t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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$1), $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], 1e-157], N[Abs[N[(x * t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{\sqrt{\pi}}\\
t_1 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_2 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\mathbf{if}\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_1\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 10^{-157}:\\
\;\;\;\;\left|x \cdot t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{x \cdot x} \cdot t\_0\right|\\
\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)))))) < 9.99999999999999943e-158Initial program 99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
if 9.99999999999999943e-158 < (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 rewrites74.7%
Taylor expanded in x around 0
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lift-sqrt.f6452.6
Applied rewrites52.6%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-*.f6475.3
Applied rewrites75.3%
(FPCore (x) :precision binary64 (fabs (* x (/ 2.0 (sqrt PI)))))
double code(double x) {
return fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((x * (2.0 / math.sqrt(math.pi))))
function code(x) return abs(Float64(x * Float64(2.0 / sqrt(pi)))) end
function tmp = code(x) tmp = abs((x * (2.0 / sqrt(pi)))); end
code[x_] := N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|x \cdot \frac{2}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites67.9%
(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 abs(Float64(Float64(x + x) / sqrt(pi))) end
function tmp = code(x) tmp = abs(((x + x) / sqrt(pi))); end
code[x_] := N[Abs[N[(N[(x + x), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + x}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-sqrt.f6467.5
Applied rewrites67.5%
herbie shell --seed 2025134
(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)))))))