
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 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))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* x x) (fabs x))))
(* (/ 1.0 5.0) (fabs (* (* (* (* x x) x) x) x))))
(* (pow (fabs x) 6.0) (* (fabs x) 0.047619047619047616))))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * ((x * x) * fabs(x)))) + ((1.0 / 5.0) * fabs(((((x * x) * x) * x) * x)))) + (pow(fabs(x), 6.0) * (fabs(x) * 0.047619047619047616)))));
}
public static double code(double x) {
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * ((x * x) * Math.abs(x)))) + ((1.0 / 5.0) * Math.abs(((((x * x) * x) * x) * x)))) + (Math.pow(Math.abs(x), 6.0) * (Math.abs(x) * 0.047619047619047616)))));
}
def code(x): return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * ((x * x) * math.fabs(x)))) + ((1.0 / 5.0) * math.fabs(((((x * x) * x) * x) * x)))) + (math.pow(math.fabs(x), 6.0) * (math.fabs(x) * 0.047619047619047616)))))
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * Float64(Float64(x * x) * abs(x)))) + Float64(Float64(1.0 / 5.0) * abs(Float64(Float64(Float64(Float64(x * x) * x) * x) * x)))) + Float64((abs(x) ^ 6.0) * Float64(abs(x) * 0.047619047619047616))))) end
function tmp = code(x) tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * ((x * x) * abs(x)))) + ((1.0 / 5.0) * abs(((((x * x) * x) * x) * x)))) + ((abs(x) ^ 6.0) * (abs(x) * 0.047619047619047616))))); end
code[x_] := 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] * N[(N[(x * x), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Abs[x], $MachinePrecision], 6.0], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(x \cdot x\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + {\left(\left|x\right|\right)}^{6} \cdot \left(\left|x\right| \cdot 0.047619047619047616\right)\right)\right|
\end{array}
Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* x x) (fabs x))))
(* (/ 1.0 5.0) (fabs (* (* (* (* x x) x) x) x))))
(* (pow (fabs x) 7.0) 0.047619047619047616)))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * ((x * x) * fabs(x)))) + ((1.0 / 5.0) * fabs(((((x * x) * x) * x) * x)))) + (pow(fabs(x), 7.0) * 0.047619047619047616))));
}
public static double code(double x) {
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * ((x * x) * Math.abs(x)))) + ((1.0 / 5.0) * Math.abs(((((x * x) * x) * x) * x)))) + (Math.pow(Math.abs(x), 7.0) * 0.047619047619047616))));
}
def code(x): return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * ((x * x) * math.fabs(x)))) + ((1.0 / 5.0) * math.fabs(((((x * x) * x) * x) * x)))) + (math.pow(math.fabs(x), 7.0) * 0.047619047619047616))))
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * Float64(Float64(x * x) * abs(x)))) + Float64(Float64(1.0 / 5.0) * abs(Float64(Float64(Float64(Float64(x * x) * x) * x) * x)))) + Float64((abs(x) ^ 7.0) * 0.047619047619047616)))) end
function tmp = code(x) tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * ((x * x) * abs(x)))) + ((1.0 / 5.0) * abs(((((x * x) * x) * x) * x)))) + ((abs(x) ^ 7.0) * 0.047619047619047616)))); end
code[x_] := 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] * N[(N[(x * x), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(x \cdot x\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + {\left(\left|x\right|\right)}^{7} \cdot 0.047619047619047616\right)\right|
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
metadata-evalN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-fabs.f64N/A
lower-pow.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(* (fma (* x x) 0.6666666666666666 2.0) x)
(* (/ 1.0 5.0) (fabs (* (* (* (* x x) x) x) x))))
(* (pow (fabs x) 6.0) (* (fabs x) 0.047619047619047616))))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * (((fma((x * x), 0.6666666666666666, 2.0) * x) + ((1.0 / 5.0) * fabs(((((x * x) * x) * x) * x)))) + (pow(fabs(x), 6.0) * (fabs(x) * 0.047619047619047616)))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x) + Float64(Float64(1.0 / 5.0) * abs(Float64(Float64(Float64(Float64(x * x) * x) * x) * x)))) + Float64((abs(x) ^ 6.0) * Float64(abs(x) * 0.047619047619047616))))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Abs[x], $MachinePrecision], 6.0], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x + \frac{1}{5} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + {\left(\left|x\right|\right)}^{6} \cdot \left(\left|x\right| \cdot 0.047619047619047616\right)\right)\right|
\end{array}
Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow2N/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
Applied rewrites81.9%
Final simplification81.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (fabs (* (* (* (* x x) x) x) x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* 0.6666666666666666 x)))
(* (/ 1.0 5.0) t_0))
(* (/ 1.0 21.0) (* (* t_0 (fabs x)) (* (sqrt x) (sqrt x)))))))))
double code(double x) {
double t_0 = fabs(((((x * x) * x) * x) * x));
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((x * x) * (0.6666666666666666 * x))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * fabs(x)) * (sqrt(x) * sqrt(x)))))));
}
public static double code(double x) {
double t_0 = Math.abs(((((x * x) * x) * x) * x));
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((x * x) * (0.6666666666666666 * x))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * Math.abs(x)) * (Math.sqrt(x) * Math.sqrt(x)))))));
}
def code(x): t_0 = math.fabs(((((x * x) * x) * x) * x)) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((x * x) * (0.6666666666666666 * x))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * math.fabs(x)) * (math.sqrt(x) * math.sqrt(x)))))))
function code(x) t_0 = abs(Float64(Float64(Float64(Float64(x * x) * x) * x) * x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(x * x) * Float64(0.6666666666666666 * x))) + Float64(Float64(1.0 / 5.0) * t_0)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_0 * abs(x)) * Float64(sqrt(x) * sqrt(x))))))) end
function tmp = code(x) t_0 = abs(((((x * x) * x) * x) * x)); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((x * x) * (0.6666666666666666 * x))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * abs(x)) * (sqrt(x) * sqrt(x))))))); end
code[x_] := Block[{t$95$0 = N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 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[(x * x), $MachinePrecision] * N[(0.6666666666666666 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(0.6666666666666666 \cdot x\right)\right) + \frac{1}{5} \cdot t\_0\right) + \frac{1}{21} \cdot \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6434.7
Applied rewrites34.7%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
pow3N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
pow3N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6434.7
Applied rewrites34.7%
Final simplification34.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (fabs (* (* (* (* x x) x) x) x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(fma (* (* x x) 0.6666666666666666) (fabs x) (* (fabs x) 2.0))
(* (/ 1.0 5.0) t_0))
(* (/ 1.0 21.0) (* (* t_0 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = fabs(((((x * x) * x) * x) * x));
return fabs(((1.0 / sqrt(((double) M_PI))) * ((fma(((x * x) * 0.6666666666666666), fabs(x), (fabs(x) * 2.0)) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * fabs(x)) * fabs(x))))));
}
function code(x) t_0 = abs(Float64(Float64(Float64(Float64(x * x) * x) * x) * x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(fma(Float64(Float64(x * x) * 0.6666666666666666), abs(x), Float64(abs(x) * 2.0)) + Float64(Float64(1.0 / 5.0) * t_0)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_0 * abs(x)) * abs(x)))))) end
code[x_] := Block[{t$95$0 = N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.6666666666666666, \left|x\right|, \left|x\right| \cdot 2\right) + \frac{1}{5} \cdot t\_0\right) + \frac{1}{21} \cdot \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-fabs.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(fma (* (* x x) 0.6666666666666666) x (* x 2.0))
(* 0.2 (fabs (* (* t_0 x) x))))
(* (/ 1.0 21.0) (* (* t_0 t_0) (fabs x))))))))
double code(double x) {
double t_0 = (x * x) * x;
return fabs(((1.0 / sqrt(((double) M_PI))) * ((fma(((x * x) * 0.6666666666666666), x, (x * 2.0)) + (0.2 * fabs(((t_0 * x) * x)))) + ((1.0 / 21.0) * ((t_0 * t_0) * fabs(x))))));
}
function code(x) t_0 = Float64(Float64(x * x) * x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(fma(Float64(Float64(x * x) * 0.6666666666666666), x, Float64(x * 2.0)) + Float64(0.2 * abs(Float64(Float64(t_0 * x) * x)))) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_0 * t_0) * abs(x)))))) end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision] * x + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[Abs[N[(N[(t$95$0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.6666666666666666, x, x \cdot 2\right) + 0.2 \cdot \left|\left(t\_0 \cdot x\right) \cdot x\right|\right) + \frac{1}{21} \cdot \left(\left(t\_0 \cdot t\_0\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
swap-sqrN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
unswap-sqrN/A
Applied rewrites99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites81.9%
lift-/.f64N/A
metadata-eval81.9
Applied rewrites81.9%
Final simplification81.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(* x 2.0)
(*
0.047619047619047616
(* (* (fabs (* (* (* (* x x) x) x) x)) (fabs x)) (fabs x)))))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * ((x * 2.0) + (0.047619047619047616 * ((fabs(((((x * x) * x) * x) * x)) * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((x * 2.0) + (0.047619047619047616 * ((Math.abs(((((x * x) * x) * x) * x)) * Math.abs(x)) * Math.abs(x))))));
}
def code(x): return math.fabs(((1.0 / math.sqrt(math.pi)) * ((x * 2.0) + (0.047619047619047616 * ((math.fabs(((((x * x) * x) * x) * x)) * math.fabs(x)) * math.fabs(x))))))
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(x * 2.0) + Float64(0.047619047619047616 * Float64(Float64(abs(Float64(Float64(Float64(Float64(x * x) * x) * x) * x)) * abs(x)) * abs(x)))))) end
function tmp = code(x) tmp = abs(((1.0 / sqrt(pi)) * ((x * 2.0) + (0.047619047619047616 * ((abs(((((x * x) * x) * x) * x)) * abs(x)) * abs(x)))))); end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(x * 2.0), $MachinePrecision] + N[(0.047619047619047616 * N[(N[(N[Abs[N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(x \cdot 2 + 0.047619047619047616 \cdot \left(\left(\left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6434.5
Applied rewrites34.5%
Taylor expanded in x around inf
Applied rewrites99.3%
lift-/.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt PI)) (+ x x))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * (x + x)));
}
public static double code(double x) {
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * (x + x)));
}
def code(x): return math.fabs(((1.0 / math.sqrt(math.pi)) * (x + x)))
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(x + x))) end
function tmp = code(x) tmp = abs(((1.0 / sqrt(pi)) * (x + x))); end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(x + x\right)\right|
\end{array}
Initial program 99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6434.5
Applied rewrites34.5%
Taylor expanded in x around inf
Applied rewrites69.2%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6469.2
Applied rewrites69.2%
herbie shell --seed 2025066
(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)))))))