
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(/
(fma
(* 0.047619047619047616 (* (* (* (* x x) x) x) x))
x
(fma (* (* (* x x) 0.2) x) x (fma 0.6666666666666666 (* x x) 2.0)))
(sqrt PI)))))
double code(double x) {
return fabs(x) * fabs((fma((0.047619047619047616 * ((((x * x) * x) * x) * x)), x, fma((((x * x) * 0.2) * x), x, fma(0.6666666666666666, (x * x), 2.0))) / sqrt(((double) M_PI))));
}
function code(x) return Float64(abs(x) * abs(Float64(fma(Float64(0.047619047619047616 * Float64(Float64(Float64(Float64(x * x) * x) * x) * x)), x, fma(Float64(Float64(Float64(x * x) * 0.2) * x), x, fma(0.6666666666666666, Float64(x * x), 2.0))) / sqrt(pi)))) end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[(N[(0.047619047619047616 * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] * 0.2), $MachinePrecision] * x), $MachinePrecision] * x + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(*
(fabs
(*
(fma
(* (* (* x x) x) x)
(+ 0.2 (* (* x x) 0.047619047619047616))
(fma 0.6666666666666666 (* x x) 2.0))
x))
(/ 1.0 (sqrt PI))))
double code(double x) {
return fabs((fma((((x * x) * x) * x), (0.2 + ((x * x) * 0.047619047619047616)), fma(0.6666666666666666, (x * x), 2.0)) * x)) * (1.0 / sqrt(((double) M_PI)));
}
function code(x) return Float64(abs(Float64(fma(Float64(Float64(Float64(x * x) * x) * x), Float64(0.2 + Float64(Float64(x * x) * 0.047619047619047616)), fma(0.6666666666666666, Float64(x * x), 2.0)) * x)) * Float64(1.0 / sqrt(pi))) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[(0.2 + N[(N[(x * x), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x, 0.2 + \left(x \cdot x\right) \cdot 0.047619047619047616, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right) \cdot x\right| \cdot \frac{1}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(*
(/ 1.0 (sqrt PI))
(fabs
(*
(fma
(* (* (* x x) x) x)
(fma (* x 0.047619047619047616) x 0.2)
(fma 0.6666666666666666 (* x x) 2.0))
x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((fma((((x * x) * x) * x), fma((x * 0.047619047619047616), x, 0.2), fma(0.6666666666666666, (x * x), 2.0)) * x));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(Float64(Float64(Float64(x * x) * x) * x), fma(Float64(x * 0.047619047619047616), x, 0.2), fma(0.6666666666666666, Float64(x * x), 2.0)) * x))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[(N[(x * 0.047619047619047616), $MachinePrecision] * x + 0.2), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x, \mathsf{fma}\left(x \cdot 0.047619047619047616, x, 0.2\right), \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (x) :precision binary64 (if (<= x 1.86) (* (/ 2.0 (sqrt PI)) (fabs x)) (* (fabs x) (fabs (/ (* 0.047619047619047616 (pow x 6.0)) (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = (2.0 / sqrt(((double) M_PI))) * fabs(x);
} else {
tmp = fabs(x) * fabs(((0.047619047619047616 * pow(x, 6.0)) / sqrt(((double) M_PI))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = (2.0 / Math.sqrt(Math.PI)) * Math.abs(x);
} else {
tmp = Math.abs(x) * Math.abs(((0.047619047619047616 * Math.pow(x, 6.0)) / Math.sqrt(Math.PI)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.86: tmp = (2.0 / math.sqrt(math.pi)) * math.fabs(x) else: tmp = math.fabs(x) * math.fabs(((0.047619047619047616 * math.pow(x, 6.0)) / math.sqrt(math.pi))) return tmp
function code(x) tmp = 0.0 if (x <= 1.86) tmp = Float64(Float64(2.0 / sqrt(pi)) * abs(x)); else tmp = Float64(abs(x) * abs(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.86) tmp = (2.0 / sqrt(pi)) * abs(x); else tmp = abs(x) * abs(((0.047619047619047616 * (x ^ 6.0)) / sqrt(pi))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.86], N[(N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x\right| \cdot \left|\frac{0.047619047619047616 \cdot {x}^{6}}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 1.8600000000000001Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
Applied rewrites67.8%
lift-*.f64N/A
Applied rewrites68.3%
if 1.8600000000000001 < x Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-pow.f6436.4
Applied rewrites36.4%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(* (* (* x x) x) x)
(fma (* x 0.047619047619047616) x 0.2)
(fma 0.6666666666666666 (* x x) 2.0))
x))
(sqrt PI)))
double code(double x) {
return fabs((fma((((x * x) * x) * x), fma((x * 0.047619047619047616), x, 0.2), fma(0.6666666666666666, (x * x), 2.0)) * x)) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(Float64(Float64(Float64(x * x) * x) * x), fma(Float64(x * 0.047619047619047616), x, 0.2), fma(0.6666666666666666, Float64(x * x), 2.0)) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[(N[(x * 0.047619047619047616), $MachinePrecision] * x + 0.2), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x, \mathsf{fma}\left(x \cdot 0.047619047619047616, x, 0.2\right), \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right) \cdot x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.4%
(FPCore (x) :precision binary64 (if (<= x 1.86) (* (/ 2.0 (sqrt PI)) (fabs x)) (fabs (* 0.047619047619047616 (/ (* (pow x 6.0) (fabs x)) (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = (2.0 / sqrt(((double) M_PI))) * fabs(x);
} else {
tmp = fabs((0.047619047619047616 * ((pow(x, 6.0) * fabs(x)) / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = (2.0 / Math.sqrt(Math.PI)) * Math.abs(x);
} else {
tmp = Math.abs((0.047619047619047616 * ((Math.pow(x, 6.0) * Math.abs(x)) / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.86: tmp = (2.0 / math.sqrt(math.pi)) * math.fabs(x) else: tmp = math.fabs((0.047619047619047616 * ((math.pow(x, 6.0) * math.fabs(x)) / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= 1.86) tmp = Float64(Float64(2.0 / sqrt(pi)) * abs(x)); else tmp = abs(Float64(0.047619047619047616 * Float64(Float64((x ^ 6.0) * abs(x)) / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.86) tmp = (2.0 / sqrt(pi)) * abs(x); else tmp = abs((0.047619047619047616 * (((x ^ 6.0) * abs(x)) / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.86], N[(N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[Abs[N[(0.047619047619047616 * N[(N[(N[Power[x, 6.0], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|0.047619047619047616 \cdot \frac{{x}^{6} \cdot \left|x\right|}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 1.8600000000000001Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
Applied rewrites67.8%
lift-*.f64N/A
Applied rewrites68.3%
if 1.8600000000000001 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6436.4
Applied rewrites36.4%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt PI)) (fma (pow (fabs x) 7.0) 0.047619047619047616 (* 2.0 (fabs x))))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, (2.0 * fabs(x)))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, Float64(2.0 * abs(x))))) 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[(2.0 * N[Abs[x], $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, 2 \cdot \left|x\right|\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-fabs.f6498.9
Applied rewrites98.9%
(FPCore (x) :precision binary64 (if (<= x 1.86) (* (/ 2.0 (sqrt PI)) (fabs x)) (* (fabs (* 0.047619047619047616 (pow x 7.0))) (/ 1.0 (sqrt PI)))))
double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = (2.0 / sqrt(((double) M_PI))) * fabs(x);
} else {
tmp = fabs((0.047619047619047616 * pow(x, 7.0))) * (1.0 / sqrt(((double) M_PI)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.86) {
tmp = (2.0 / Math.sqrt(Math.PI)) * Math.abs(x);
} else {
tmp = Math.abs((0.047619047619047616 * Math.pow(x, 7.0))) * (1.0 / Math.sqrt(Math.PI));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.86: tmp = (2.0 / math.sqrt(math.pi)) * math.fabs(x) else: tmp = math.fabs((0.047619047619047616 * math.pow(x, 7.0))) * (1.0 / math.sqrt(math.pi)) return tmp
function code(x) tmp = 0.0 if (x <= 1.86) tmp = Float64(Float64(2.0 / sqrt(pi)) * abs(x)); else tmp = Float64(abs(Float64(0.047619047619047616 * (x ^ 7.0))) * Float64(1.0 / sqrt(pi))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.86) tmp = (2.0 / sqrt(pi)) * abs(x); else tmp = abs((0.047619047619047616 * (x ^ 7.0))) * (1.0 / sqrt(pi)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.86], N[(N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.86:\\
\;\;\;\;\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|0.047619047619047616 \cdot {x}^{7}\right| \cdot \frac{1}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.8600000000000001Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
Applied rewrites67.8%
lift-*.f64N/A
Applied rewrites68.3%
if 1.8600000000000001 < x Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-pow.f6436.4
Applied rewrites36.4%
(FPCore (x)
:precision binary64
(fabs
(/
(fma
(* (* 0.047619047619047616 (* x x)) (* (* (* x x) x) x))
(fabs x)
(* 2.0 (fabs x)))
(sqrt PI))))
double code(double x) {
return fabs((fma(((0.047619047619047616 * (x * x)) * (((x * x) * x) * x)), fabs(x), (2.0 * fabs(x))) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(fma(Float64(Float64(0.047619047619047616 * Float64(x * x)) * Float64(Float64(Float64(x * x) * x) * x)), abs(x), Float64(2.0 * abs(x))) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(N[(N[(0.047619047619047616 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right), \left|x\right|, 2 \cdot \left|x\right|\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-pow.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6498.5
Applied rewrites98.5%
Applied rewrites98.5%
(FPCore (x) :precision binary64 (fabs (/ (fma 0.047619047619047616 (pow (* x x) 3.5) (* 2.0 (fabs x))) (sqrt PI))))
double code(double x) {
return fabs((fma(0.047619047619047616, pow((x * x), 3.5), (2.0 * fabs(x))) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(fma(0.047619047619047616, (Float64(x * x) ^ 3.5), Float64(2.0 * abs(x))) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(0.047619047619047616 * N[Power[N[(x * x), $MachinePrecision], 3.5], $MachinePrecision] + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(0.047619047619047616, {\left(x \cdot x\right)}^{3.5}, 2 \cdot \left|x\right|\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-pow.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6498.5
Applied rewrites98.5%
lift-pow.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
sqrt-pow2N/A
lower-pow.f64N/A
metadata-eval98.4
Applied rewrites98.4%
(FPCore (x) :precision binary64 (fabs (/ (* (fabs x) (fma (* x 0.047619047619047616) (* (* (* (* x x) x) x) x) 2.0)) (sqrt PI))))
double code(double x) {
return fabs(((fabs(x) * fma((x * 0.047619047619047616), ((((x * x) * x) * x) * x), 2.0)) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(Float64(abs(x) * fma(Float64(x * 0.047619047619047616), Float64(Float64(Float64(Float64(x * x) * x) * x) * x), 2.0)) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(x * 0.047619047619047616), $MachinePrecision] * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\left|x\right| \cdot \mathsf{fma}\left(x \cdot 0.047619047619047616, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-pow.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6498.5
Applied rewrites98.5%
lift-fma.f64N/A
lift-pow.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow1/2N/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
lift-pow.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites98.5%
Applied rewrites98.5%
(FPCore (x) :precision binary64 (if (<= x 1000000000.0) (* (/ 2.0 (sqrt PI)) (fabs x)) (fabs (* 2.0 (sqrt (/ (* x x) PI))))))
double code(double x) {
double tmp;
if (x <= 1000000000.0) {
tmp = (2.0 / sqrt(((double) M_PI))) * fabs(x);
} else {
tmp = fabs((2.0 * sqrt(((x * x) / ((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1000000000.0) {
tmp = (2.0 / Math.sqrt(Math.PI)) * Math.abs(x);
} else {
tmp = Math.abs((2.0 * Math.sqrt(((x * x) / Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1000000000.0: tmp = (2.0 / math.sqrt(math.pi)) * math.fabs(x) else: tmp = math.fabs((2.0 * math.sqrt(((x * x) / math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= 1000000000.0) tmp = Float64(Float64(2.0 / sqrt(pi)) * abs(x)); else tmp = abs(Float64(2.0 * sqrt(Float64(Float64(x * x) / pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1000000000.0) tmp = (2.0 / sqrt(pi)) * abs(x); else tmp = abs((2.0 * sqrt(((x * x) / pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1000000000.0], N[(N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[Abs[N[(2.0 * N[Sqrt[N[(N[(x * x), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1000000000:\\
\;\;\;\;\frac{2}{\sqrt{\pi}} \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right|\\
\end{array}
\end{array}
if x < 1e9Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
Applied rewrites67.8%
lift-*.f64N/A
Applied rewrites68.3%
if 1e9 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lower-sqrt.f64N/A
lower-/.f6453.6
Applied rewrites53.6%
(FPCore (x) :precision binary64 (* (/ 2.0 (sqrt PI)) (fabs x)))
double code(double x) {
return (2.0 / sqrt(((double) M_PI))) * fabs(x);
}
public static double code(double x) {
return (2.0 / Math.sqrt(Math.PI)) * Math.abs(x);
}
def code(x): return (2.0 / math.sqrt(math.pi)) * math.fabs(x)
function code(x) return Float64(Float64(2.0 / sqrt(pi)) * abs(x)) end
function tmp = code(x) tmp = (2.0 / sqrt(pi)) * abs(x); end
code[x_] := N[(N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\sqrt{\pi}} \cdot \left|x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
Applied rewrites67.8%
lift-*.f64N/A
Applied rewrites68.3%
herbie shell --seed 2025164
(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)))))))