
(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 12 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
(*
(sqrt (/ 1.0 PI))
(fabs
(*
(fma
x
(*
x
(fma x (* x (fma (* x x) 0.047619047619047616 0.2)) 0.6666666666666666))
2.0)
(fabs x)))))
double code(double x) {
return sqrt((1.0 / ((double) M_PI))) * fabs((fma(x, (x * fma(x, (x * fma((x * x), 0.047619047619047616, 0.2)), 0.6666666666666666)), 2.0) * fabs(x)));
}
function code(x) return Float64(sqrt(Float64(1.0 / pi)) * abs(Float64(fma(x, Float64(x * fma(x, Float64(x * fma(Float64(x * x), 0.047619047619047616, 0.2)), 0.6666666666666666)), 2.0) * abs(x)))) end
code[x_] := N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[Abs[N[(N[(x * N[(x * N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision]), $MachinePrecision] + 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{\pi}} \cdot \left|\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right) \cdot \left|x\right|\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 1e-6)
(fabs
(* (/ 1.0 (sqrt PI)) (* (fabs x) (fma x (* x 0.6666666666666666) 2.0))))
(*
(/ (fabs x) (sqrt PI))
(fabs (* (* x x) (* (* x x) (* (* x x) 0.047619047619047616)))))))
double code(double x) {
double tmp;
if (fabs(x) <= 1e-6) {
tmp = fabs(((1.0 / sqrt(((double) M_PI))) * (fabs(x) * fma(x, (x * 0.6666666666666666), 2.0))));
} else {
tmp = (fabs(x) / sqrt(((double) M_PI))) * fabs(((x * x) * ((x * x) * ((x * x) * 0.047619047619047616))));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) <= 1e-6) tmp = abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(abs(x) * fma(x, Float64(x * 0.6666666666666666), 2.0)))); else tmp = Float64(Float64(abs(x) / sqrt(pi)) * abs(Float64(Float64(x * x) * Float64(Float64(x * x) * Float64(Float64(x * x) * 0.047619047619047616))))); end return tmp end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1e-6], N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[Abs[x], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 10^{-6}:\\
\;\;\;\;\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|x\right|}{\sqrt{\pi}} \cdot \left|\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.047619047619047616\right)\right)\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 9.99999999999999955e-7Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
if 9.99999999999999955e-7 < (fabs.f64 x) Initial program 99.0%
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
cube-prodN/A
unpow2N/A
cube-unmultN/A
pow-sqrN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.3
Applied rewrites98.3%
lift-fabs.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites98.4%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(*
(fabs x)
(fma
(* x x)
(fma (* x x) (fma (* x x) 0.047619047619047616 0.2) 0.6666666666666666)
2.0)))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * (fabs(x) * fma((x * x), fma((x * x), fma((x * x), 0.047619047619047616, 0.2), 0.6666666666666666), 2.0))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(abs(x) * fma(Float64(x * x), fma(Float64(x * x), fma(Float64(x * x), 0.047619047619047616, 0.2), 0.6666666666666666), 2.0)))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right)\right)\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(*
(/ (fabs x) (sqrt PI))
(fabs
(fma
x
(*
x
(fma x (* x (fma (* x x) 0.047619047619047616 0.2)) 0.6666666666666666))
2.0))))
double code(double x) {
return (fabs(x) / sqrt(((double) M_PI))) * fabs(fma(x, (x * fma(x, (x * fma((x * x), 0.047619047619047616, 0.2)), 0.6666666666666666)), 2.0));
}
function code(x) return Float64(Float64(abs(x) / sqrt(pi)) * abs(fma(x, Float64(x * fma(x, Float64(x * fma(Float64(x * x), 0.047619047619047616, 0.2)), 0.6666666666666666)), 2.0))) end
code[x_] := N[(N[(N[Abs[x], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x * N[(x * N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision]), $MachinePrecision] + 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x\right|}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right)\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.4%
(FPCore (x)
:precision binary64
(/
(fabs
(*
x
(fma
(* x x)
(fma (* x x) (fma x (* x 0.047619047619047616) 0.2) 0.6666666666666666)
2.0)))
(sqrt PI)))
double code(double x) {
return fabs((x * fma((x * x), fma((x * x), fma(x, (x * 0.047619047619047616), 0.2), 0.6666666666666666), 2.0))) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(x * fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(x * 0.047619047619047616), 0.2), 0.6666666666666666), 2.0))) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.047619047619047616), $MachinePrecision] + 0.2), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.047619047619047616, 0.2\right), 0.6666666666666666\right), 2\right)\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
un-div-invN/A
lower-/.f6499.4
Applied rewrites99.4%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt PI)) (* (fabs x) (fma x (* x (fma (* x x) 0.2 0.6666666666666666)) 2.0)))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * (fabs(x) * fma(x, (x * fma((x * x), 0.2, 0.6666666666666666)), 2.0))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(abs(x) * fma(x, Float64(x * fma(Float64(x * x), 0.2, 0.6666666666666666)), 2.0)))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * 0.2 + 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right)\right)\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6490.6
Applied rewrites90.6%
(FPCore (x) :precision binary64 (/ (fabs (* (fabs x) (fma x (* x (fma x (* x 0.2) 0.6666666666666666)) 2.0))) (sqrt PI)))
double code(double x) {
return fabs((fabs(x) * fma(x, (x * fma(x, (x * 0.2), 0.6666666666666666)), 2.0))) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(abs(x) * fma(x, Float64(x * fma(x, Float64(x * 0.2), 0.6666666666666666)), 2.0))) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(x * N[(x * N[(x * N[(x * 0.2), $MachinePrecision] + 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\left|x\right| \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.2, 0.6666666666666666\right), 2\right)\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites65.0%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
Applied rewrites64.5%
Taylor expanded in x around 0
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.1
Applied rewrites90.1%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt PI)) (* (fabs x) (fma x (* x 0.6666666666666666) 2.0)))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * (fabs(x) * fma(x, (x * 0.6666666666666666), 2.0))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(abs(x) * fma(x, Float64(x * 0.6666666666666666), 2.0)))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)\right)\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6489.3
Applied rewrites89.3%
(FPCore (x) :precision binary64 (* (fabs (/ x (sqrt PI))) (fabs (fma x (* x 0.6666666666666666) 2.0))))
double code(double x) {
return fabs((x / sqrt(((double) M_PI)))) * fabs(fma(x, (x * 0.6666666666666666), 2.0));
}
function code(x) return Float64(abs(Float64(x / sqrt(pi))) * abs(fma(x, Float64(x * 0.6666666666666666), 2.0))) end
code[x_] := N[(N[Abs[N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Abs[N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x}{\sqrt{\pi}}\right| \cdot \left|\mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6489.3
Applied rewrites89.3%
Applied rewrites88.8%
(FPCore (x) :precision binary64 (/ (fabs (* x (fma x (* x 0.6666666666666666) 2.0))) (sqrt PI)))
double code(double x) {
return fabs((x * fma(x, (x * 0.6666666666666666), 2.0))) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(x * fma(x, Float64(x * 0.6666666666666666), 2.0))) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(x * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x \cdot \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right)\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6489.3
Applied rewrites89.3%
Applied rewrites88.8%
(FPCore (x) :precision binary64 (* (fabs x) (fabs (/ 2.0 (sqrt PI)))))
double code(double x) {
return fabs(x) * fabs((2.0 / sqrt(((double) M_PI))));
}
public static double code(double x) {
return Math.abs(x) * Math.abs((2.0 / Math.sqrt(Math.PI)));
}
def code(x): return math.fabs(x) * math.fabs((2.0 / math.sqrt(math.pi)))
function code(x) return Float64(abs(x) * abs(Float64(2.0 / sqrt(pi)))) end
function tmp = code(x) tmp = abs(x) * abs((2.0 / sqrt(pi))); end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{2}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites65.0%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
Applied rewrites64.5%
lift-/.f64N/A
Applied rewrites65.0%
(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 Float64(abs(Float64(x * 2.0)) / sqrt(pi)) end
function tmp = code(x) tmp = abs((x * 2.0)) / sqrt(pi); end
code[x_] := N[(N[Abs[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x \cdot 2\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.6%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites65.0%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
Applied rewrites64.5%
lift-fabs.f64N/A
lift-*.f64N/A
*-commutativeN/A
fabs-mulN/A
Applied rewrites64.5%
Final simplification64.5%
herbie shell --seed 2024234
(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)))))))