
(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 15 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 (/ 1.0 (sqrt PI))) (t_1 (* (* (* x x) x) x)))
(fabs
(fma
(* t_0 (* (* (* t_1 (fabs x)) x) x))
0.047619047619047616
(*
(fma
(* 0.2 (fabs x))
t_1
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0)))
t_0)))))
double code(double x) {
double t_0 = 1.0 / sqrt(((double) M_PI));
double t_1 = ((x * x) * x) * x;
return fabs(fma((t_0 * (((t_1 * fabs(x)) * x) * x)), 0.047619047619047616, (fma((0.2 * fabs(x)), t_1, (fabs(x) * fma((x * x), 0.6666666666666666, 2.0))) * t_0)));
}
function code(x) t_0 = Float64(1.0 / sqrt(pi)) t_1 = Float64(Float64(Float64(x * x) * x) * x) return abs(fma(Float64(t_0 * Float64(Float64(Float64(t_1 * abs(x)) * x) * x)), 0.047619047619047616, Float64(fma(Float64(0.2 * abs(x)), t_1, Float64(abs(x) * fma(Float64(x * x), 0.6666666666666666, 2.0))) * t_0))) end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]}, N[Abs[N[(N[(t$95$0 * N[(N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * 0.047619047619047616 + N[(N[(N[(0.2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$1 + N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\pi}}\\
t_1 := \left(\left(x \cdot x\right) \cdot x\right) \cdot x\\
\left|\mathsf{fma}\left(t\_0 \cdot \left(\left(\left(t\_1 \cdot \left|x\right|\right) \cdot x\right) \cdot x\right), 0.047619047619047616, \mathsf{fma}\left(0.2 \cdot \left|x\right|, t\_1, \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right) \cdot t\_0\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(fma
(pow (fabs x) 7.0)
0.047619047619047616
(fma
(* 0.2 (fabs x))
(* (* (* x x) x) x)
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0)))))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, fma((0.2 * fabs(x)), (((x * x) * x) * x), (fabs(x) * fma((x * x), 0.6666666666666666, 2.0))))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, fma(Float64(0.2 * abs(x)), Float64(Float64(Float64(x * x) * x) * x), Float64(abs(x) * fma(Float64(x * x), 0.6666666666666666, 2.0)))))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616 + N[(N[(0.2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(0.2 \cdot \left|x\right|, \left(\left(x \cdot x\right) \cdot x\right) \cdot x, \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(*
(/ 1.0 (sqrt PI))
(fabs
(fma
(fabs x)
(fma (* 0.2 (* x x)) (* x x) (* (* t_0 t_0) 0.047619047619047616))
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0)))))))
double code(double x) {
double t_0 = (x * x) * x;
return (1.0 / sqrt(((double) M_PI))) * fabs(fma(fabs(x), fma((0.2 * (x * x)), (x * x), ((t_0 * t_0) * 0.047619047619047616)), (fabs(x) * fma((x * x), 0.6666666666666666, 2.0))));
}
function code(x) t_0 = Float64(Float64(x * x) * x) return Float64(Float64(1.0 / sqrt(pi)) * abs(fma(abs(x), fma(Float64(0.2 * Float64(x * x)), Float64(x * x), Float64(Float64(t_0 * t_0) * 0.047619047619047616)), Float64(abs(x) * fma(Float64(x * x), 0.6666666666666666, 2.0))))) end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(N[(0.2 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(t\_0 \cdot t\_0\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt PI))))
(if (<= x 2.2)
(fabs (fma (* 2.0 t_0) x (* (* (* (* x x) x) 0.6666666666666666) t_0)))
(* 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 = fabs(fma((2.0 * t_0), x, ((((x * x) * x) * 0.6666666666666666) * t_0)));
} 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 = abs(fma(Float64(2.0 * t_0), x, Float64(Float64(Float64(Float64(x * x) * x) * 0.6666666666666666) * t_0))); 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[Abs[N[(N[(2.0 * t$95$0), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision] * t$95$0), $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:\\
\;\;\;\;\left|\mathsf{fma}\left(2 \cdot t\_0, x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot 0.6666666666666666\right) \cdot t\_0\right)\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%
Taylor expanded in x around 0
Applied rewrites89.6%
if 2.2000000000000002 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites36.3%
Taylor expanded in x around 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-eval36.3
Applied rewrites36.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt PI))))
(if (<= x 1.9)
(fabs (* (+ x x) t_0))
(* 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 <= 1.9) {
tmp = fabs(((x + x) * t_0));
} else {
tmp = t_0 * fabs((pow(x, 7.0) * 0.047619047619047616));
}
return tmp;
}
public static double code(double x) {
double t_0 = 1.0 / Math.sqrt(Math.PI);
double tmp;
if (x <= 1.9) {
tmp = Math.abs(((x + x) * t_0));
} else {
tmp = t_0 * Math.abs((Math.pow(x, 7.0) * 0.047619047619047616));
}
return tmp;
}
def code(x): t_0 = 1.0 / math.sqrt(math.pi) tmp = 0 if x <= 1.9: tmp = math.fabs(((x + x) * t_0)) else: tmp = t_0 * math.fabs((math.pow(x, 7.0) * 0.047619047619047616)) return tmp
function code(x) t_0 = Float64(1.0 / sqrt(pi)) tmp = 0.0 if (x <= 1.9) tmp = abs(Float64(Float64(x + x) * t_0)); else tmp = Float64(t_0 * abs(Float64((x ^ 7.0) * 0.047619047619047616))); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / sqrt(pi); tmp = 0.0; if (x <= 1.9) tmp = abs(((x + x) * t_0)); else tmp = t_0 * abs(((x ^ 7.0) * 0.047619047619047616)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.9], N[Abs[N[(N[(x + x), $MachinePrecision] * t$95$0), $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 1.9:\\
\;\;\;\;\left|\left(x + x\right) \cdot t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left|{x}^{7} \cdot 0.047619047619047616\right|\\
\end{array}
\end{array}
if x < 1.8999999999999999Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lower-*.f64N/A
Applied rewrites68.3%
if 1.8999999999999999 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites36.3%
Taylor expanded in x around 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-eval36.3
Applied rewrites36.3%
(FPCore (x)
:precision binary64
(if (<= x 1.9)
(fabs (* (+ x x) (/ 1.0 (sqrt PI))))
(/
(fabs (* (* (* (* (* (* x x) x) x) x) (* x x)) 0.047619047619047616))
(sqrt PI))))
double code(double x) {
double tmp;
if (x <= 1.9) {
tmp = fabs(((x + x) * (1.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs(((((((x * x) * x) * x) * x) * (x * x)) * 0.047619047619047616)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.9) {
tmp = Math.abs(((x + x) * (1.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs(((((((x * x) * x) * x) * x) * (x * x)) * 0.047619047619047616)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.9: tmp = math.fabs(((x + x) * (1.0 / math.sqrt(math.pi)))) else: tmp = math.fabs(((((((x * x) * x) * x) * x) * (x * x)) * 0.047619047619047616)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 1.9) tmp = abs(Float64(Float64(x + x) * Float64(1.0 / sqrt(pi)))); else tmp = Float64(abs(Float64(Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * x) * Float64(x * x)) * 0.047619047619047616)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.9) tmp = abs(((x + x) * (1.0 / sqrt(pi)))); else tmp = abs(((((((x * x) * x) * x) * x) * (x * x)) * 0.047619047619047616)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.9], N[Abs[N[(N[(x + x), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9:\\
\;\;\;\;\left|\left(x + x\right) \cdot \frac{1}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot 0.047619047619047616\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.8999999999999999Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lower-*.f64N/A
Applied rewrites68.3%
if 1.8999999999999999 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
Applied rewrites36.3%
Applied rewrites36.3%
(FPCore (x) :precision binary64 (if (<= x 1.9) (fabs (* (+ x x) (/ 1.0 (sqrt PI)))) (/ (fabs (* (pow x 7.0) 0.047619047619047616)) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 1.9) {
tmp = fabs(((x + x) * (1.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs((pow(x, 7.0) * 0.047619047619047616)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.9) {
tmp = Math.abs(((x + x) * (1.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs((Math.pow(x, 7.0) * 0.047619047619047616)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.9: tmp = math.fabs(((x + x) * (1.0 / math.sqrt(math.pi)))) else: tmp = math.fabs((math.pow(x, 7.0) * 0.047619047619047616)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 1.9) tmp = abs(Float64(Float64(x + x) * Float64(1.0 / sqrt(pi)))); else tmp = Float64(abs(Float64((x ^ 7.0) * 0.047619047619047616)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.9) tmp = abs(((x + x) * (1.0 / sqrt(pi)))); else tmp = abs(((x ^ 7.0) * 0.047619047619047616)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.9], N[Abs[N[(N[(x + x), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9:\\
\;\;\;\;\left|\left(x + x\right) \cdot \frac{1}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|{x}^{7} \cdot 0.047619047619047616\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.8999999999999999Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lower-*.f64N/A
Applied rewrites68.3%
if 1.8999999999999999 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
Applied rewrites36.3%
Taylor expanded in x around 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-eval36.3
Applied rewrites36.3%
(FPCore (x)
:precision binary64
(/
(fabs
(fma
(fma
(* x x)
(fma (* (* x x) x) 0.047619047619047616 (* 0.2 x))
(* 0.6666666666666666 x))
(* x x)
(+ x x)))
(sqrt PI)))
double code(double x) {
return fabs(fma(fma((x * x), fma(((x * x) * x), 0.047619047619047616, (0.2 * x)), (0.6666666666666666 * x)), (x * x), (x + x))) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(fma(fma(Float64(x * x), fma(Float64(Float64(x * x) * x), 0.047619047619047616, Float64(0.2 * x)), Float64(0.6666666666666666 * x)), Float64(x * x), Float64(x + x))) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * 0.047619047619047616 + N[(0.2 * x), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, 0.047619047619047616, 0.2 \cdot x\right), 0.6666666666666666 \cdot x\right), x \cdot x, x + x\right)\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(*
(fma (fma (* x x) 0.047619047619047616 0.2) (* x x) 0.6666666666666666)
x)
x
2.0)
x))
(sqrt PI)))
double code(double x) {
return fabs((fma((fma(fma((x * x), 0.047619047619047616, 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(fma(Float64(x * x), 0.047619047619047616, 0.2), Float64(x * x), 0.6666666666666666) * x), x, 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] * 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(\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right) \cdot x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites99.4%
(FPCore (x) :precision binary64 (if (<= x 1.8) (fabs (* (+ x x) (/ 1.0 (sqrt PI)))) (/ (fabs (* (* (* (* (* x x) x) x) 0.2) x)) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 1.8) {
tmp = fabs(((x + x) * (1.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs((((((x * x) * x) * x) * 0.2) * x)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.8) {
tmp = Math.abs(((x + x) * (1.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs((((((x * x) * x) * x) * 0.2) * x)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.8: tmp = math.fabs(((x + x) * (1.0 / math.sqrt(math.pi)))) else: tmp = math.fabs((((((x * x) * x) * x) * 0.2) * x)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 1.8) tmp = abs(Float64(Float64(x + x) * Float64(1.0 / sqrt(pi)))); else tmp = Float64(abs(Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * 0.2) * x)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.8) tmp = abs(((x + x) * (1.0 / sqrt(pi)))); else tmp = abs((((((x * x) * x) * x) * 0.2) * x)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.8], N[Abs[N[(N[(x + x), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 0.2), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8:\\
\;\;\;\;\left|\left(x + x\right) \cdot \frac{1}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot 0.2\right) \cdot x\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.80000000000000004Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lower-*.f64N/A
Applied rewrites68.3%
if 1.80000000000000004 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.3%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
sqr-powN/A
metadata-evalN/A
pow2N/A
metadata-evalN/A
pow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
metadata-eval30.9
Applied rewrites30.9%
(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(Float64(0.2 * x) * x), Float64(x * x), 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(0.2 * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\left(0.2 \cdot x\right) \cdot x, x \cdot x, 2\right) \cdot x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.3%
Taylor expanded in x around inf
metadata-evalN/A
pow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
metadata-eval92.9
Applied rewrites92.9%
(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(Float64(x * x), 0.6666666666666666, 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow-plusN/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval93.3
Applied rewrites93.3%
Taylor expanded in x around 0
Applied rewrites89.2%
(FPCore (x) :precision binary64 (if (<= x 2e-10) (fabs (* (+ x x) (/ 1.0 (sqrt PI)))) (/ (sqrt (* (+ x x) (+ x x))) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 2e-10) {
tmp = fabs(((x + x) * (1.0 / sqrt(((double) M_PI)))));
} else {
tmp = sqrt(((x + x) * (x + x))) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 2e-10) {
tmp = Math.abs(((x + x) * (1.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.sqrt(((x + x) * (x + x))) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 2e-10: tmp = math.fabs(((x + x) * (1.0 / math.sqrt(math.pi)))) else: tmp = math.sqrt(((x + x) * (x + x))) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 2e-10) tmp = abs(Float64(Float64(x + x) * Float64(1.0 / sqrt(pi)))); else tmp = Float64(sqrt(Float64(Float64(x + x) * Float64(x + x))) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 2e-10) tmp = abs(((x + x) * (1.0 / sqrt(pi)))); else tmp = sqrt(((x + x) * (x + x))) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 2e-10], N[Abs[N[(N[(x + x), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(N[(x + x), $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\left|\left(x + x\right) \cdot \frac{1}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(x + x\right) \cdot \left(x + x\right)}}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 2.00000000000000007e-10Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lower-*.f64N/A
Applied rewrites68.3%
if 2.00000000000000007e-10 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow-plusN/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval93.3
Applied rewrites93.3%
Taylor expanded in x around 0
Applied rewrites67.9%
Applied rewrites53.2%
(FPCore (x) :precision binary64 (fabs (* (+ x x) (/ 1.0 (sqrt PI)))))
double code(double x) {
return fabs(((x + x) * (1.0 / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs(((x + x) * (1.0 / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs(((x + x) * (1.0 / math.sqrt(math.pi))))
function code(x) return abs(Float64(Float64(x + x) * Float64(1.0 / sqrt(pi)))) end
function tmp = code(x) tmp = abs(((x + x) * (1.0 / sqrt(pi)))); end
code[x_] := N[Abs[N[(N[(x + x), $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(x + x\right) \cdot \frac{1}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites68.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lower-*.f64N/A
Applied rewrites68.3%
(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 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow-plusN/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval93.3
Applied rewrites93.3%
Taylor expanded in x around 0
Applied rewrites67.9%
herbie shell --seed 2025130
(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)))))))