
(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}
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}
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}
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}
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(fma (pow (fabs x) 7.0) 0.047619047619047616 (* (fabs x) 2.0))
(*
(fabs x)
(fma (* 0.6666666666666666 x) x (* (* 0.2 (* x x)) (* x x))))))))double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * (fma(pow(fabs(x), 7.0), 0.047619047619047616, (fabs(x) * 2.0)) + (fabs(x) * fma((0.6666666666666666 * x), x, ((0.2 * (x * x)) * (x * x)))))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(fma((abs(x) ^ 7.0), 0.047619047619047616, Float64(abs(x) * 2.0)) + Float64(abs(x) * fma(Float64(0.6666666666666666 * x), x, Float64(Float64(0.2 * Float64(x * x)) * Float64(x * x))))))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616 + N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(0.6666666666666666 * x), $MachinePrecision] * x + N[(N[(0.2 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \left|x\right| \cdot 2\right) + \left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, \left(0.2 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right)\right)\right|
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]
\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|
Initial program 99.8%
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}
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}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(*
(fabs
(*
(fma
(* (* (* (* (* x x) x) x) x) 0.047619047619047616)
x
(fma (* x x) (fma (* 0.2 x) x 0.6666666666666666) 2.0))
(fabs x)))
0.5641895835477563))double code(double x) {
return fabs((fma((((((x * x) * x) * x) * x) * 0.047619047619047616), x, fma((x * x), fma((0.2 * x), x, 0.6666666666666666), 2.0)) * fabs(x))) * 0.5641895835477563;
}
function code(x) return Float64(abs(Float64(fma(Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * x) * 0.047619047619047616), x, fma(Float64(x * x), fma(Float64(0.2 * x), x, 0.6666666666666666), 2.0)) * abs(x))) * 0.5641895835477563) end
code[x_] := N[(N[Abs[N[(N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 0.047619047619047616), $MachinePrecision] * x + N[(N[(x * x), $MachinePrecision] * N[(N[(0.2 * x), $MachinePrecision] * x + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision]
\left|\mathsf{fma}\left(\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot 0.047619047619047616, x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right)\right) \cdot \left|x\right|\right| \cdot 0.5641895835477563
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.4%
Evaluated real constant99.6%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 0.65)
(* (/ 1.0 (sqrt PI)) (fabs (+ (fabs x) (fabs x))))
(/
1.0
(/ (sqrt PI) (fabs (* (pow (fabs (fabs x)) 7.0) 0.047619047619047616))))))double code(double x) {
double tmp;
if (fabs(x) <= 0.65) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fabs(x) + fabs(x)));
} else {
tmp = 1.0 / (sqrt(((double) M_PI)) / fabs((pow(fabs(fabs(x)), 7.0) * 0.047619047619047616)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 0.65) {
tmp = (1.0 / Math.sqrt(Math.PI)) * Math.abs((Math.abs(x) + Math.abs(x)));
} else {
tmp = 1.0 / (Math.sqrt(Math.PI) / Math.abs((Math.pow(Math.abs(Math.abs(x)), 7.0) * 0.047619047619047616)));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 0.65: tmp = (1.0 / math.sqrt(math.pi)) * math.fabs((math.fabs(x) + math.fabs(x))) else: tmp = 1.0 / (math.sqrt(math.pi) / math.fabs((math.pow(math.fabs(math.fabs(x)), 7.0) * 0.047619047619047616))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 0.65) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(abs(x) + abs(x)))); else tmp = Float64(1.0 / Float64(sqrt(pi) / abs(Float64((abs(abs(x)) ^ 7.0) * 0.047619047619047616)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 0.65) tmp = (1.0 / sqrt(pi)) * abs((abs(x) + abs(x))); else tmp = 1.0 / (sqrt(pi) / abs(((abs(abs(x)) ^ 7.0) * 0.047619047619047616))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.65], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[Pi], $MachinePrecision] / N[Abs[N[(N[Power[N[Abs[N[Abs[x], $MachinePrecision]], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.65:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\left|x\right| + \left|x\right|\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{\pi}}{\left|{\left(\left|\left|x\right|\right|\right)}^{7} \cdot 0.047619047619047616\right|}}\\
\end{array}
if x < 0.65000000000000002Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6467.9%
Applied rewrites67.9%
if 0.65000000000000002 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-fabs.f6436.7%
Applied rewrites36.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
Applied rewrites36.7%
(FPCore (x) :precision binary64 (if (<= (fabs x) 0.65) (* (/ 1.0 (sqrt PI)) (fabs (+ (fabs x) (fabs x)))) (/ (fabs (* 0.047619047619047616 (pow (fabs x) 7.0))) (sqrt PI))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.65) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fabs(x) + fabs(x)));
} else {
tmp = fabs((0.047619047619047616 * pow(fabs(x), 7.0))) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 0.65) {
tmp = (1.0 / Math.sqrt(Math.PI)) * Math.abs((Math.abs(x) + Math.abs(x)));
} else {
tmp = Math.abs((0.047619047619047616 * Math.pow(Math.abs(x), 7.0))) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 0.65: tmp = (1.0 / math.sqrt(math.pi)) * math.fabs((math.fabs(x) + math.fabs(x))) else: tmp = math.fabs((0.047619047619047616 * math.pow(math.fabs(x), 7.0))) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 0.65) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(abs(x) + abs(x)))); else tmp = Float64(abs(Float64(0.047619047619047616 * (abs(x) ^ 7.0))) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 0.65) tmp = (1.0 / sqrt(pi)) * abs((abs(x) + abs(x))); else tmp = abs((0.047619047619047616 * (abs(x) ^ 7.0))) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.65], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.65:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\left|x\right| + \left|x\right|\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|0.047619047619047616 \cdot {\left(\left|x\right|\right)}^{7}\right|}{\sqrt{\pi}}\\
\end{array}
if x < 0.65000000000000002Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6467.9%
Applied rewrites67.9%
if 0.65000000000000002 < x Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-pow.f6436.7%
Applied rewrites36.7%
(FPCore (x)
:precision binary64
(/
(fabs
(fma
(fabs x)
(+ 2.0 (* (* x x) 0.6666666666666666))
(* 0.047619047619047616 (pow (fabs x) 7.0))))
1.772453850905516))double code(double x) {
return fabs(fma(fabs(x), (2.0 + ((x * x) * 0.6666666666666666)), (0.047619047619047616 * pow(fabs(x), 7.0)))) / 1.772453850905516;
}
function code(x) return Float64(abs(fma(abs(x), Float64(2.0 + Float64(Float64(x * x) * 0.6666666666666666)), Float64(0.047619047619047616 * (abs(x) ^ 7.0)))) / 1.772453850905516) end
code[x_] := N[(N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(2.0 + N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 1.772453850905516), $MachinePrecision]
\frac{\left|\mathsf{fma}\left(\left|x\right|, 2 + \left(x \cdot x\right) \cdot 0.6666666666666666, 0.047619047619047616 \cdot {\left(\left|x\right|\right)}^{7}\right)\right|}{1.772453850905516}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.4%
Evaluated real constant99.6%
Taylor expanded in x around 0
Applied rewrites99.0%
(FPCore (x) :precision binary64 (/ (fabs (fma (fabs x) 2.0 (* 0.047619047619047616 (pow (fabs x) 7.0)))) 1.772453850905516))
double code(double x) {
return fabs(fma(fabs(x), 2.0, (0.047619047619047616 * pow(fabs(x), 7.0)))) / 1.772453850905516;
}
function code(x) return Float64(abs(fma(abs(x), 2.0, Float64(0.047619047619047616 * (abs(x) ^ 7.0)))) / 1.772453850905516) end
code[x_] := N[(N[Abs[N[(N[Abs[x], $MachinePrecision] * 2.0 + N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 1.772453850905516), $MachinePrecision]
\frac{\left|\mathsf{fma}\left(\left|x\right|, 2, 0.047619047619047616 \cdot {\left(\left|x\right|\right)}^{7}\right)\right|}{1.772453850905516}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.4%
Evaluated real constant99.6%
Taylor expanded in x around 0
Applied rewrites98.7%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 18.0)
(* (/ 1.0 (sqrt PI)) (fabs (+ (fabs x) (fabs x))))
(fabs
(/
(*
(* (* (fabs (fabs x)) (fabs x)) (* (* (fabs x) (fabs x)) (fabs x)))
-0.2)
-1.772453850905516))))double code(double x) {
double tmp;
if (fabs(x) <= 18.0) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fabs(x) + fabs(x)));
} else {
tmp = fabs(((((fabs(fabs(x)) * fabs(x)) * ((fabs(x) * fabs(x)) * fabs(x))) * -0.2) / -1.772453850905516));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 18.0) {
tmp = (1.0 / Math.sqrt(Math.PI)) * Math.abs((Math.abs(x) + Math.abs(x)));
} else {
tmp = Math.abs(((((Math.abs(Math.abs(x)) * Math.abs(x)) * ((Math.abs(x) * Math.abs(x)) * Math.abs(x))) * -0.2) / -1.772453850905516));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 18.0: tmp = (1.0 / math.sqrt(math.pi)) * math.fabs((math.fabs(x) + math.fabs(x))) else: tmp = math.fabs(((((math.fabs(math.fabs(x)) * math.fabs(x)) * ((math.fabs(x) * math.fabs(x)) * math.fabs(x))) * -0.2) / -1.772453850905516)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 18.0) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(abs(x) + abs(x)))); else tmp = abs(Float64(Float64(Float64(Float64(abs(abs(x)) * abs(x)) * Float64(Float64(abs(x) * abs(x)) * abs(x))) * -0.2) / -1.772453850905516)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 18.0) tmp = (1.0 / sqrt(pi)) * abs((abs(x) + abs(x))); else tmp = abs(((((abs(abs(x)) * abs(x)) * ((abs(x) * abs(x)) * abs(x))) * -0.2) / -1.772453850905516)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 18.0], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[(N[(N[(N[Abs[N[Abs[x], $MachinePrecision]], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.2), $MachinePrecision] / -1.772453850905516), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 18:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\left|x\right| + \left|x\right|\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(\left(\left|\left|x\right|\right| \cdot \left|x\right|\right) \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) \cdot -0.2}{-1.772453850905516}\right|\\
\end{array}
if x < 18Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6467.9%
Applied rewrites67.9%
if 18 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-fabs.f6431.3%
Applied rewrites31.3%
lift-*.f64N/A
*-commutativeN/A
lift-fabs.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-plusN/A
pow3N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.3%
Evaluated real constant31.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (fabs x) (fabs x))))
(if (<= (fabs x) 5e-94)
(* (/ 1.0 (sqrt PI)) (fabs t_0))
(sqrt (/ (* t_0 t_0) PI)))))double code(double x) {
double t_0 = fabs(x) + fabs(x);
double tmp;
if (fabs(x) <= 5e-94) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs(t_0);
} else {
tmp = sqrt(((t_0 * t_0) / ((double) M_PI)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.abs(x) + Math.abs(x);
double tmp;
if (Math.abs(x) <= 5e-94) {
tmp = (1.0 / Math.sqrt(Math.PI)) * Math.abs(t_0);
} else {
tmp = Math.sqrt(((t_0 * t_0) / Math.PI));
}
return tmp;
}
def code(x): t_0 = math.fabs(x) + math.fabs(x) tmp = 0 if math.fabs(x) <= 5e-94: tmp = (1.0 / math.sqrt(math.pi)) * math.fabs(t_0) else: tmp = math.sqrt(((t_0 * t_0) / math.pi)) return tmp
function code(x) t_0 = Float64(abs(x) + abs(x)) tmp = 0.0 if (abs(x) <= 5e-94) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(t_0)); else tmp = sqrt(Float64(Float64(t_0 * t_0) / pi)); end return tmp end
function tmp_2 = code(x) t_0 = abs(x) + abs(x); tmp = 0.0; if (abs(x) <= 5e-94) tmp = (1.0 / sqrt(pi)) * abs(t_0); else tmp = sqrt(((t_0 * t_0) / pi)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 5e-94], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[t$95$0], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|x\right| + \left|x\right|\\
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-94}:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{t\_0 \cdot t\_0}{\pi}}\\
\end{array}
if x < 4.9999999999999995e-94Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6467.9%
Applied rewrites67.9%
if 4.9999999999999995e-94 < x Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
sqrt-undivN/A
Applied rewrites53.6%
(FPCore (x) :precision binary64 (* (/ 1.0 (sqrt PI)) (fabs (+ x x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((x + x));
}
public static double code(double x) {
return (1.0 / Math.sqrt(Math.PI)) * Math.abs((x + x));
}
def code(x): return (1.0 / math.sqrt(math.pi)) * math.fabs((x + x))
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(x + x))) end
function tmp = code(x) tmp = (1.0 / sqrt(pi)) * abs((x + x)); end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{\pi}} \cdot \left|x + x\right|
Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6467.9%
Applied rewrites67.9%
(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]
\frac{\left|x + x\right|}{\sqrt{\pi}}
Initial program 99.8%
Applied rewrites99.4%
lift-fabs.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
fabs-mulN/A
lift-fabs.f64N/A
fabs-fabsN/A
mul-fabsN/A
lower-fabs.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-*.f6467.5%
Applied rewrites67.5%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.5%
Applied rewrites67.5%
herbie shell --seed 2025206
(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)))))))