
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0))
(* (/ 1.0 5.0) (* (* t_0 (fabs x)) (fabs x))))
(* (* (pow (fabs x) 6.0) 0.047619047619047616) (fabs x)))))))
double code(double x) {
double t_0 = (fabs(x) * 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_0 * fabs(x)) * fabs(x)))) + ((pow(fabs(x), 6.0) * 0.047619047619047616) * fabs(x)))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * 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_0 * Math.abs(x)) * Math.abs(x)))) + ((Math.pow(Math.abs(x), 6.0) * 0.047619047619047616) * Math.abs(x)))));
}
def code(x): t_0 = (math.fabs(x) * 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_0 * math.fabs(x)) * math.fabs(x)))) + ((math.pow(math.fabs(x), 6.0) * 0.047619047619047616) * math.fabs(x)))))
function code(x) t_0 = Float64(Float64(abs(x) * 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) * Float64(Float64(t_0 * abs(x)) * abs(x)))) + Float64(Float64((abs(x) ^ 6.0) * 0.047619047619047616) * abs(x))))) end
function tmp = code(x) t_0 = (abs(x) * 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_0 * abs(x)) * abs(x)))) + (((abs(x) ^ 6.0) * 0.047619047619047616) * 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]}, 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] * N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Abs[x], $MachinePrecision], 6.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision] * N[Abs[x], $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|\\
\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 \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \left({\left(\left|x\right|\right)}^{6} \cdot 0.047619047619047616\right) \cdot \left|x\right|\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x))) (t_1 (* (* (- x) x) (- x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0))
(* (/ 1.0 5.0) (* (* t_0 (fabs x)) (fabs x))))
(* (* (* t_1 t_1) 0.047619047619047616) (fabs x)))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (-x * x) * -x;
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * ((t_0 * fabs(x)) * fabs(x)))) + (((t_1 * t_1) * 0.047619047619047616) * fabs(x)))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (-x * x) * -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_0 * Math.abs(x)) * Math.abs(x)))) + (((t_1 * t_1) * 0.047619047619047616) * Math.abs(x)))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (-x * x) * -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_0 * math.fabs(x)) * math.fabs(x)))) + (((t_1 * t_1) * 0.047619047619047616) * math.fabs(x)))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(Float64(-x) * x) * Float64(-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) * Float64(Float64(t_0 * abs(x)) * abs(x)))) + Float64(Float64(Float64(t_1 * t_1) * 0.047619047619047616) * abs(x))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (-x * x) * -x; tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * ((t_0 * abs(x)) * abs(x)))) + (((t_1 * t_1) * 0.047619047619047616) * 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[((-x) * x), $MachinePrecision] * (-x)), $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] * N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.047619047619047616), $MachinePrecision] * N[Abs[x], $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(\left(-x\right) \cdot x\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 \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \left(\left(t\_1 \cdot t\_1\right) \cdot 0.047619047619047616\right) \cdot \left|x\right|\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.9%
lift-fabs.f64N/A
lift-pow.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow2N/A
metadata-evalN/A
pow3N/A
pow2N/A
sqr-abs-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(* (fma (* x x) 0.6666666666666666 2.0) x)
(* 0.2 (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))))
(* 0.047619047619047616 (* (* 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, 2.0) * x) + (0.2 * ((((fabs(x) * fabs(x)) * fabs(x)) * fabs(x)) * fabs(x)))) + (0.047619047619047616 * ((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(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x) + Float64(0.2 * Float64(Float64(Float64(Float64(abs(x) * abs(x)) * abs(x)) * abs(x)) * abs(x)))) + Float64(0.047619047619047616 * 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 + 2.0), $MachinePrecision] * x), $MachinePrecision] + N[(0.2 * N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * 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(x \cdot x, 0.6666666666666666, 2\right) \cdot x + 0.2 \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + 0.047619047619047616 \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-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
lower-+.f64N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
pow2N/A
distribute-rgt-inN/A
Applied rewrites76.9%
lift-/.f64N/A
metadata-eval76.9
Applied rewrites76.9%
lift-/.f64N/A
metadata-eval76.9
Applied rewrites76.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (sqrt PI))))
(/
(fabs
(*
(fma
(fma (fma (* x x) 0.047619047619047616 0.2) (* x x) 0.6666666666666666)
(* x x)
2.0)
x))
(* t_0 t_0))))
double code(double x) {
double t_0 = sqrt(sqrt(((double) M_PI)));
return fabs((fma(fma(fma((x * x), 0.047619047619047616, 0.2), (x * x), 0.6666666666666666), (x * x), 2.0) * x)) / (t_0 * t_0);
}
function code(x) t_0 = sqrt(sqrt(pi)) return Float64(abs(Float64(fma(fma(fma(Float64(x * x), 0.047619047619047616, 0.2), Float64(x * x), 0.6666666666666666), Float64(x * x), 2.0) * x)) / Float64(t_0 * t_0)) end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[Pi], $MachinePrecision]], $MachinePrecision]}, N[(N[Abs[N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\sqrt{\pi}}\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), x \cdot x, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|}{t\_0 \cdot t\_0}
\end{array}
\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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
lift-PI.f64N/A
lift-sqrt.f64N/A
add-sqr-sqrtN/A
lift-sqrt.f64N/A
lift-PI.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6499.6
Applied rewrites99.6%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(fma (* 0.047619047619047616 (* x x)) (* x x) 0.6666666666666666)
(* x x)
2.0)
x))
(sqrt PI)))
double code(double x) {
return fabs((fma(fma((0.047619047619047616 * (x * x)), (x * x), 0.6666666666666666), (x * x), 2.0) * x)) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(fma(Float64(0.047619047619047616 * Float64(x * x)), Float64(x * x), 0.6666666666666666), Float64(x * x), 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(0.047619047619047616 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(0.047619047619047616 \cdot \left(x \cdot x\right), x \cdot x, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|}{\sqrt{\pi}}
\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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
Taylor expanded in x around inf
metadata-evalN/A
pow2N/A
lift-*.f64N/A
lower-*.f64N/A
metadata-eval98.8
Applied rewrites98.8%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (* (fma 0.2 (* x x) 0.6666666666666666) x) x 2.0) x)) (sqrt PI)))
double code(double x) {
return fabs((fma((fma(0.2, (x * x), 0.6666666666666666) * x), x, 2.0) * x)) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(Float64(fma(0.2, Float64(x * x), 0.6666666666666666) * x), x, 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(0.2 * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * x), $MachinePrecision] * x + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right) \cdot x\right|}{\sqrt{\pi}}
\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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites93.4%
lift-fma.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.4
Applied rewrites93.4%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (* 0.2 (* x x)) (* x x) 2.0) x)) (sqrt PI)))
double code(double x) {
return fabs((fma((0.2 * (x * x)), (x * x), 2.0) * x)) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(Float64(0.2 * Float64(x * x)), Float64(x * x), 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(0.2 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, 2\right) \cdot x\right|}{\sqrt{\pi}}
\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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites93.4%
Taylor expanded in x around inf
pow2N/A
lift-*.f64N/A
lower-*.f6492.9
Applied rewrites92.9%
(FPCore (x) :precision binary64 (if (<= x 1.7) (/ (fabs (+ x x)) (sqrt PI)) (/ (fabs (* (* 0.6666666666666666 (* x x)) x)) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = fabs((x + x)) / sqrt(((double) M_PI));
} else {
tmp = fabs(((0.6666666666666666 * (x * x)) * x)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.7) {
tmp = Math.abs((x + x)) / Math.sqrt(Math.PI);
} else {
tmp = Math.abs(((0.6666666666666666 * (x * x)) * x)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.7: tmp = math.fabs((x + x)) / math.sqrt(math.pi) else: tmp = math.fabs(((0.6666666666666666 * (x * x)) * x)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 1.7) tmp = Float64(abs(Float64(x + x)) / sqrt(pi)); else tmp = Float64(abs(Float64(Float64(0.6666666666666666 * Float64(x * x)) * x)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.7) tmp = abs((x + x)) / sqrt(pi); else tmp = abs(((0.6666666666666666 * (x * x)) * x)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.7], N[(N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;\frac{\left|x + x\right|}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(0.6666666666666666 \cdot \left(x \cdot x\right)\right) \cdot x\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.69999999999999996Initial 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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites67.3%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6467.3
Applied rewrites67.3%
if 1.69999999999999996 < x 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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites89.1%
Taylor expanded in x around inf
pow2N/A
lift-*.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
(FPCore (x) :precision binary64 (/ (fabs (* (fma x (* x 0.6666666666666666) 2.0) x)) (sqrt PI)))
double code(double x) {
return fabs((fma(x, (x * 0.6666666666666666), 2.0) * x)) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(x, Float64(x * 0.6666666666666666), 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right) \cdot x\right|}{\sqrt{\pi}}
\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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites89.1%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6489.1
Applied rewrites89.1%
(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.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%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites67.3%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6467.3
Applied rewrites67.3%
herbie shell --seed 2025098
(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)))))))