
(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
(let* ((t_0 (* (fabs x) (* x x))) (t_1 (* (fabs x) (* (fabs x) t_0))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* 0.6666666666666666 t_0)) (* 0.2 t_1))
(* 0.047619047619047616 (* (fabs x) (* (fabs x) t_1))))))))
double code(double x) {
double t_0 = fabs(x) * (x * x);
double t_1 = fabs(x) * (fabs(x) * t_0);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + (0.6666666666666666 * t_0)) + (0.2 * t_1)) + (0.047619047619047616 * (fabs(x) * (fabs(x) * t_1))))));
}
public static double code(double x) {
double t_0 = Math.abs(x) * (x * x);
double t_1 = Math.abs(x) * (Math.abs(x) * t_0);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + (0.6666666666666666 * t_0)) + (0.2 * t_1)) + (0.047619047619047616 * (Math.abs(x) * (Math.abs(x) * t_1))))));
}
def code(x): t_0 = math.fabs(x) * (x * x) t_1 = math.fabs(x) * (math.fabs(x) * t_0) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + (0.6666666666666666 * t_0)) + (0.2 * t_1)) + (0.047619047619047616 * (math.fabs(x) * (math.fabs(x) * t_1))))))
function code(x) t_0 = Float64(abs(x) * Float64(x * x)) t_1 = Float64(abs(x) * Float64(abs(x) * t_0)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(0.6666666666666666 * t_0)) + Float64(0.2 * t_1)) + Float64(0.047619047619047616 * Float64(abs(x) * Float64(abs(x) * t_1)))))) end
function tmp = code(x) t_0 = abs(x) * (x * x); t_1 = abs(x) * (abs(x) * t_0); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + (0.6666666666666666 * t_0)) + (0.2 * t_1)) + (0.047619047619047616 * (abs(x) * (abs(x) * t_1)))))); end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * t$95$0), $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[(0.6666666666666666 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.2 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|x\right| \cdot \left(x \cdot x\right)\\
t_1 := \left|x\right| \cdot \left(\left|x\right| \cdot t\_0\right)\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + 0.6666666666666666 \cdot t\_0\right) + 0.2 \cdot t\_1\right) + 0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot t\_1\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (fabs x) (* x x))) (t_1 (* (* x x) t_0)))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (fma 2.0 (fabs x) (* 0.6666666666666666 t_0)) (* 0.2 t_1))
(* 0.047619047619047616 (* (* x x) t_1)))))))
double code(double x) {
double t_0 = fabs(x) * (x * x);
double t_1 = (x * x) * t_0;
return fabs(((1.0 / sqrt(((double) M_PI))) * ((fma(2.0, fabs(x), (0.6666666666666666 * t_0)) + (0.2 * t_1)) + (0.047619047619047616 * ((x * x) * t_1)))));
}
function code(x) t_0 = Float64(abs(x) * Float64(x * x)) t_1 = Float64(Float64(x * x) * t_0) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(fma(2.0, abs(x), Float64(0.6666666666666666 * t_0)) + Float64(0.2 * t_1)) + Float64(0.047619047619047616 * Float64(Float64(x * x) * t_1))))) end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision] + N[(0.6666666666666666 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.2 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[(N[(x * x), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|x\right| \cdot \left(x \cdot x\right)\\
t_1 := \left(x \cdot x\right) \cdot t\_0\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\mathsf{fma}\left(2, \left|x\right|, 0.6666666666666666 \cdot t\_0\right) + 0.2 \cdot t\_1\right) + 0.047619047619047616 \cdot \left(\left(x \cdot x\right) \cdot t\_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(*
(pow PI -0.5)
(+
2.0
(+
(* 0.047619047619047616 (pow x 6.0))
(+ (* 0.2 (pow x 4.0)) (* 0.6666666666666666 (pow x 2.0)))))))))
double code(double x) {
return fabs(x) * fabs((pow(((double) M_PI), -0.5) * (2.0 + ((0.047619047619047616 * pow(x, 6.0)) + ((0.2 * pow(x, 4.0)) + (0.6666666666666666 * pow(x, 2.0)))))));
}
public static double code(double x) {
return Math.abs(x) * Math.abs((Math.pow(Math.PI, -0.5) * (2.0 + ((0.047619047619047616 * Math.pow(x, 6.0)) + ((0.2 * Math.pow(x, 4.0)) + (0.6666666666666666 * Math.pow(x, 2.0)))))));
}
def code(x): return math.fabs(x) * math.fabs((math.pow(math.pi, -0.5) * (2.0 + ((0.047619047619047616 * math.pow(x, 6.0)) + ((0.2 * math.pow(x, 4.0)) + (0.6666666666666666 * math.pow(x, 2.0)))))))
function code(x) return Float64(abs(x) * abs(Float64((pi ^ -0.5) * Float64(2.0 + Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(Float64(0.2 * (x ^ 4.0)) + Float64(0.6666666666666666 * (x ^ 2.0)))))))) end
function tmp = code(x) tmp = abs(x) * abs(((pi ^ -0.5) * (2.0 + ((0.047619047619047616 * (x ^ 6.0)) + ((0.2 * (x ^ 4.0)) + (0.6666666666666666 * (x ^ 2.0))))))); end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(2.0 + N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|{\pi}^{-0.5} \cdot \left(2 + \left(0.047619047619047616 \cdot {x}^{6} + \left(0.2 \cdot {x}^{4} + 0.6666666666666666 \cdot {x}^{2}\right)\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
*-un-lft-identity99.9%
inv-pow99.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(/
(+
(+ (* 0.047619047619047616 (pow x 6.0)) (* 0.2 (pow x 4.0)))
(fma 0.6666666666666666 (* x x) 2.0))
(sqrt PI)))))
double code(double x) {
return fabs(x) * fabs(((((0.047619047619047616 * pow(x, 6.0)) + (0.2 * pow(x, 4.0))) + fma(0.6666666666666666, (x * x), 2.0)) / sqrt(((double) M_PI))));
}
function code(x) return Float64(abs(x) * abs(Float64(Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(0.2 * (x ^ 4.0))) + fma(0.6666666666666666, Float64(x * x), 2.0)) / sqrt(pi)))) end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[(N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{\left(0.047619047619047616 \cdot {x}^{6} + 0.2 \cdot {x}^{4}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
Simplified99.9%
fma-undefine99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(*
(sqrt (/ 1.0 PI))
(+
2.0
(+
(* 0.047619047619047616 (pow x 6.0))
(* 0.6666666666666666 (pow x 2.0))))))))
double code(double x) {
return fabs(x) * fabs((sqrt((1.0 / ((double) M_PI))) * (2.0 + ((0.047619047619047616 * pow(x, 6.0)) + (0.6666666666666666 * pow(x, 2.0))))));
}
public static double code(double x) {
return Math.abs(x) * Math.abs((Math.sqrt((1.0 / Math.PI)) * (2.0 + ((0.047619047619047616 * Math.pow(x, 6.0)) + (0.6666666666666666 * Math.pow(x, 2.0))))));
}
def code(x): return math.fabs(x) * math.fabs((math.sqrt((1.0 / math.pi)) * (2.0 + ((0.047619047619047616 * math.pow(x, 6.0)) + (0.6666666666666666 * math.pow(x, 2.0))))))
function code(x) return Float64(abs(x) * abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(2.0 + Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(0.6666666666666666 * (x ^ 2.0))))))) end
function tmp = code(x) tmp = abs(x) * abs((sqrt((1.0 / pi)) * (2.0 + ((0.047619047619047616 * (x ^ 6.0)) + (0.6666666666666666 * (x ^ 2.0)))))); end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(2.0 + N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\sqrt{\frac{1}{\pi}} \cdot \left(2 + \left(0.047619047619047616 \cdot {x}^{6} + 0.6666666666666666 \cdot {x}^{2}\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 98.8%
Taylor expanded in x around 0 98.8%
(FPCore (x)
:precision binary64
(*
(fabs x)
(fabs
(/
(+
(* 0.047619047619047616 (pow x 6.0))
(fma 0.6666666666666666 (* x x) 2.0))
(sqrt PI)))))
double code(double x) {
return fabs(x) * fabs((((0.047619047619047616 * pow(x, 6.0)) + fma(0.6666666666666666, (x * x), 2.0)) / sqrt(((double) M_PI))));
}
function code(x) return Float64(abs(x) * abs(Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + 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[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 98.8%
(FPCore (x) :precision binary64 (if (<= (fabs x) 2.0) (fabs (* x (/ (fma 0.2 (pow x 4.0) 2.0) (sqrt PI)))) (* 0.047619047619047616 (* (pow x 6.0) (/ (fabs x) (sqrt PI))))))
double code(double x) {
double tmp;
if (fabs(x) <= 2.0) {
tmp = fabs((x * (fma(0.2, pow(x, 4.0), 2.0) / sqrt(((double) M_PI)))));
} else {
tmp = 0.047619047619047616 * (pow(x, 6.0) * (fabs(x) / sqrt(((double) M_PI))));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) <= 2.0) tmp = abs(Float64(x * Float64(fma(0.2, (x ^ 4.0), 2.0) / sqrt(pi)))); else tmp = Float64(0.047619047619047616 * Float64((x ^ 6.0) * Float64(abs(x) / sqrt(pi)))); end return tmp end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2.0], N[Abs[N[(x * N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(0.047619047619047616 * N[(N[Power[x, 6.0], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2:\\
\;\;\;\;\left|x \cdot \frac{\mathsf{fma}\left(0.2, {x}^{4}, 2\right)}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;0.047619047619047616 \cdot \left({x}^{6} \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 2Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 98.8%
Taylor expanded in x around 0 97.4%
mul-fabs97.4%
fma-define97.4%
Applied egg-rr97.4%
if 2 < (fabs.f64 x) Initial program 100.0%
Simplified99.9%
Taylor expanded in x around inf 99.2%
*-un-lft-identity99.2%
fabs-mul99.2%
metadata-eval99.2%
*-commutative99.2%
inv-pow99.2%
sqrt-pow199.2%
metadata-eval99.2%
*-commutative99.2%
Applied egg-rr99.2%
*-lft-identity99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
fabs-mul99.2%
metadata-eval99.2%
pow-sqr99.2%
fabs-sqr99.2%
pow-sqr99.2%
metadata-eval99.2%
fabs-mul99.2%
fabs-fabs99.2%
rem-sqrt-square99.2%
pow-sqr99.2%
metadata-eval99.2%
unpow-199.2%
unpow1/299.2%
Simplified99.2%
(FPCore (x) :precision binary64 (if (<= (fabs x) 0.4) (* 2.0 (* x (pow PI -0.5))) (* 0.047619047619047616 (* (pow x 6.0) (/ (fabs x) (sqrt PI))))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.4) {
tmp = 2.0 * (x * pow(((double) M_PI), -0.5));
} else {
tmp = 0.047619047619047616 * (pow(x, 6.0) * (fabs(x) / sqrt(((double) M_PI))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 0.4) {
tmp = 2.0 * (x * Math.pow(Math.PI, -0.5));
} else {
tmp = 0.047619047619047616 * (Math.pow(x, 6.0) * (Math.abs(x) / Math.sqrt(Math.PI)));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 0.4: tmp = 2.0 * (x * math.pow(math.pi, -0.5)) else: tmp = 0.047619047619047616 * (math.pow(x, 6.0) * (math.fabs(x) / math.sqrt(math.pi))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 0.4) tmp = Float64(2.0 * Float64(x * (pi ^ -0.5))); else tmp = Float64(0.047619047619047616 * Float64((x ^ 6.0) * Float64(abs(x) / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 0.4) tmp = 2.0 * (x * (pi ^ -0.5)); else tmp = 0.047619047619047616 * ((x ^ 6.0) * (abs(x) / sqrt(pi))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.4], N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.047619047619047616 * N[(N[Power[x, 6.0], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.4:\\
\;\;\;\;2 \cdot \left(x \cdot {\pi}^{-0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;0.047619047619047616 \cdot \left({x}^{6} \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 0.40000000000000002Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 97.8%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 97.8%
fabs-mul97.8%
metadata-eval97.8%
fabs-mul97.8%
unpow-197.8%
metadata-eval97.8%
pow-sqr97.8%
rem-sqrt-square97.8%
fabs-fabs97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
exp-to-pow97.8%
metadata-eval97.8%
distribute-rgt-neg-in97.8%
exp-neg97.8%
fabs-fabs97.8%
associate-*l/97.6%
*-lft-identity97.6%
exp-to-pow97.2%
unpow1/297.2%
Simplified97.2%
add-log-exp9.5%
Applied egg-rr9.5%
rem-log-exp97.2%
div-inv97.8%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt53.0%
pow1/253.0%
pow-flip53.0%
metadata-eval53.0%
Applied egg-rr53.0%
if 0.40000000000000002 < (fabs.f64 x) Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 98.3%
*-un-lft-identity98.3%
fabs-mul98.3%
metadata-eval98.3%
*-commutative98.3%
inv-pow98.3%
sqrt-pow198.3%
metadata-eval98.3%
*-commutative98.3%
Applied egg-rr98.3%
*-lft-identity98.3%
*-commutative98.3%
*-commutative98.3%
associate-*l*98.3%
fabs-mul98.3%
metadata-eval98.3%
pow-sqr98.3%
fabs-sqr98.3%
pow-sqr98.3%
metadata-eval98.3%
fabs-mul98.3%
fabs-fabs98.3%
rem-sqrt-square98.3%
pow-sqr98.3%
metadata-eval98.3%
unpow-198.3%
unpow1/298.3%
Simplified98.3%
(FPCore (x) :precision binary64 (if (<= (fabs x) 5e+15) (* 2.0 (* x (pow PI -0.5))) (* 2.0 (log (exp (/ x (sqrt PI)))))))
double code(double x) {
double tmp;
if (fabs(x) <= 5e+15) {
tmp = 2.0 * (x * pow(((double) M_PI), -0.5));
} else {
tmp = 2.0 * log(exp((x / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 5e+15) {
tmp = 2.0 * (x * Math.pow(Math.PI, -0.5));
} else {
tmp = 2.0 * Math.log(Math.exp((x / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 5e+15: tmp = 2.0 * (x * math.pow(math.pi, -0.5)) else: tmp = 2.0 * math.log(math.exp((x / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 5e+15) tmp = Float64(2.0 * Float64(x * (pi ^ -0.5))); else tmp = Float64(2.0 * log(exp(Float64(x / sqrt(pi))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 5e+15) tmp = 2.0 * (x * (pi ^ -0.5)); else tmp = 2.0 * log(exp((x / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 5e+15], N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Log[N[Exp[N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{+15}:\\
\;\;\;\;2 \cdot \left(x \cdot {\pi}^{-0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \log \left(e^{\frac{x}{\sqrt{\pi}}}\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 5e15Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 95.8%
associate-*r*95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in x around 0 95.8%
fabs-mul95.8%
metadata-eval95.8%
fabs-mul95.8%
unpow-195.8%
metadata-eval95.8%
pow-sqr95.8%
rem-sqrt-square95.8%
fabs-fabs95.8%
rem-square-sqrt95.8%
fabs-sqr95.8%
rem-square-sqrt95.8%
exp-to-pow95.8%
metadata-eval95.8%
distribute-rgt-neg-in95.8%
exp-neg95.8%
fabs-fabs95.8%
associate-*l/95.5%
*-lft-identity95.5%
exp-to-pow95.1%
unpow1/295.1%
Simplified95.1%
add-log-exp9.4%
Applied egg-rr9.4%
rem-log-exp95.1%
div-inv95.8%
add-sqr-sqrt49.9%
fabs-sqr49.9%
add-sqr-sqrt51.8%
pow1/251.8%
pow-flip51.8%
metadata-eval51.8%
Applied egg-rr51.8%
if 5e15 < (fabs.f64 x) Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 6.0%
associate-*r*6.0%
*-commutative6.0%
Simplified6.0%
Taylor expanded in x around 0 6.0%
fabs-mul6.0%
metadata-eval6.0%
fabs-mul6.0%
unpow-16.0%
metadata-eval6.0%
pow-sqr6.0%
rem-sqrt-square6.0%
fabs-fabs6.0%
rem-square-sqrt6.0%
fabs-sqr6.0%
rem-square-sqrt6.0%
exp-to-pow6.0%
metadata-eval6.0%
distribute-rgt-neg-in6.0%
exp-neg6.0%
fabs-fabs6.0%
associate-*l/6.0%
*-lft-identity6.0%
exp-to-pow6.0%
unpow1/26.0%
Simplified6.0%
add-log-exp96.8%
Applied egg-rr96.8%
expm1-log1p-u96.8%
expm1-undefine96.8%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
log1p-undefine0.0%
rem-exp-log0.0%
associate-+r-0.0%
expm1-undefine0.0%
rem-exp-log0.0%
log1p-undefine0.0%
log1p-expm10.0%
Simplified0.0%
(FPCore (x) :precision binary64 (* (fabs x) (fabs (/ (+ 2.0 (* 0.047619047619047616 (pow x 6.0))) (sqrt PI)))))
double code(double x) {
return fabs(x) * fabs(((2.0 + (0.047619047619047616 * pow(x, 6.0))) / sqrt(((double) M_PI))));
}
public static double code(double x) {
return Math.abs(x) * Math.abs(((2.0 + (0.047619047619047616 * Math.pow(x, 6.0))) / Math.sqrt(Math.PI)));
}
def code(x): return math.fabs(x) * math.fabs(((2.0 + (0.047619047619047616 * math.pow(x, 6.0))) / math.sqrt(math.pi)))
function code(x) return Float64(abs(x) * abs(Float64(Float64(2.0 + Float64(0.047619047619047616 * (x ^ 6.0))) / sqrt(pi)))) end
function tmp = code(x) tmp = abs(x) * abs(((2.0 + (0.047619047619047616 * (x ^ 6.0))) / sqrt(pi))); end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[Abs[N[(N[(2.0 + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{2 + 0.047619047619047616 \cdot {x}^{6}}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 98.8%
Taylor expanded in x around 0 98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (* 2.0 (* x (pow PI -0.5))))
double code(double x) {
return 2.0 * (x * pow(((double) M_PI), -0.5));
}
public static double code(double x) {
return 2.0 * (x * Math.pow(Math.PI, -0.5));
}
def code(x): return 2.0 * (x * math.pow(math.pi, -0.5))
function code(x) return Float64(2.0 * Float64(x * (pi ^ -0.5))) end
function tmp = code(x) tmp = 2.0 * (x * (pi ^ -0.5)); end
code[x_] := N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(x \cdot {\pi}^{-0.5}\right)
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 65.3%
associate-*r*65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in x around 0 65.3%
fabs-mul65.3%
metadata-eval65.3%
fabs-mul65.3%
unpow-165.3%
metadata-eval65.3%
pow-sqr65.3%
rem-sqrt-square65.3%
fabs-fabs65.3%
rem-square-sqrt65.3%
fabs-sqr65.3%
rem-square-sqrt65.3%
exp-to-pow65.3%
metadata-eval65.3%
distribute-rgt-neg-in65.3%
exp-neg65.3%
fabs-fabs65.3%
associate-*l/65.1%
*-lft-identity65.1%
exp-to-pow64.8%
unpow1/264.8%
Simplified64.8%
add-log-exp39.1%
Applied egg-rr39.1%
rem-log-exp64.8%
div-inv65.3%
add-sqr-sqrt33.0%
fabs-sqr33.0%
add-sqr-sqrt34.3%
pow1/234.3%
pow-flip34.3%
metadata-eval34.3%
Applied egg-rr34.3%
(FPCore (x) :precision binary64 (/ (* 2.0 x) (sqrt PI)))
double code(double x) {
return (2.0 * x) / sqrt(((double) M_PI));
}
public static double code(double x) {
return (2.0 * x) / Math.sqrt(Math.PI);
}
def code(x): return (2.0 * x) / math.sqrt(math.pi)
function code(x) return Float64(Float64(2.0 * x) / sqrt(pi)) end
function tmp = code(x) tmp = (2.0 * x) / sqrt(pi); end
code[x_] := N[(N[(2.0 * x), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot x}{\sqrt{\pi}}
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 65.3%
associate-*r*65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in x around 0 65.3%
fabs-mul65.3%
metadata-eval65.3%
fabs-mul65.3%
unpow-165.3%
metadata-eval65.3%
pow-sqr65.3%
rem-sqrt-square65.3%
fabs-fabs65.3%
rem-square-sqrt65.3%
fabs-sqr65.3%
rem-square-sqrt65.3%
exp-to-pow65.3%
metadata-eval65.3%
distribute-rgt-neg-in65.3%
exp-neg65.3%
fabs-fabs65.3%
associate-*l/65.1%
*-lft-identity65.1%
exp-to-pow64.8%
unpow1/264.8%
Simplified64.8%
expm1-log1p-u64.8%
expm1-undefine8.4%
Applied egg-rr8.4%
log1p-undefine8.4%
rem-exp-log8.4%
metadata-eval8.4%
rem-square-sqrt8.4%
fabs-sqr8.4%
rem-square-sqrt8.4%
fabs-mul8.4%
+-commutative8.4%
associate--l+64.8%
metadata-eval64.8%
+-rgt-identity64.8%
fabs-mul64.8%
metadata-eval64.8%
Simplified65.3%
associate-*r/64.8%
add-sqr-sqrt32.9%
fabs-sqr32.9%
add-sqr-sqrt34.1%
Applied egg-rr34.1%
Final simplification34.1%
herbie shell --seed 2024151
(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)))))))