
(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 14 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(fma(2.0, abs(x), Float64(0.6666666666666666 * t_0)) + Float64(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[(2.0 * N[Abs[x], $MachinePrecision] + N[(0.6666666666666666 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(0.2 * t$95$1), $MachinePrecision] + N[(0.047619047619047616 * N[(N[(x * 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 \cdot x\right) \cdot t_0\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\mathsf{fma}\left(2, \left|x\right|, 0.6666666666666666 \cdot t_0\right) + \left(0.2 \cdot t_1 + 0.047619047619047616 \cdot \left(\left(x \cdot x\right) \cdot t_1\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
Simplified99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(* (fabs x) (pow PI -0.5))
(+
(fma 0.2 (pow x 4.0) (* 0.047619047619047616 (pow x 6.0)))
(fma 0.6666666666666666 (* x x) 2.0)))))
double code(double x) {
return fabs(((fabs(x) * pow(((double) M_PI), -0.5)) * (fma(0.2, pow(x, 4.0), (0.047619047619047616 * pow(x, 6.0))) + fma(0.6666666666666666, (x * x), 2.0))));
}
function code(x) return abs(Float64(Float64(abs(x) * (pi ^ -0.5)) * Float64(fma(0.2, (x ^ 4.0), Float64(0.047619047619047616 * (x ^ 6.0))) + fma(0.6666666666666666, Float64(x * x), 2.0)))) end
code[x_] := N[Abs[N[(N[(N[Abs[x], $MachinePrecision] * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision] + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\left|x\right| \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.4%
div-inv99.8%
pow1/299.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(/
(fabs x)
(fabs
(/
(sqrt PI)
(+
(fma 0.6666666666666666 (* x x) 2.0)
(+ (* 0.047619047619047616 (pow x 6.0)) (* 0.2 (pow x 4.0))))))))
double code(double x) {
return fabs(x) / fabs((sqrt(((double) M_PI)) / (fma(0.6666666666666666, (x * x), 2.0) + ((0.047619047619047616 * pow(x, 6.0)) + (0.2 * pow(x, 4.0))))));
}
function code(x) return Float64(abs(x) / abs(Float64(sqrt(pi) / Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(0.2 * (x ^ 4.0))))))) end
code[x_] := N[(N[Abs[x], $MachinePrecision] / N[Abs[N[(N[Sqrt[Pi], $MachinePrecision] / N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] + N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x\right|}{\left|\frac{\sqrt{\pi}}{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + \left(0.047619047619047616 \cdot {x}^{6} + 0.2 \cdot {x}^{4}\right)}\right|}
\end{array}
Initial program 99.9%
Simplified99.4%
fma-udef99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(fma 0.6666666666666666 (* x x) 2.0)
(+ (* 0.047619047619047616 (pow x 6.0)) (* 0.2 (pow x 4.0))))
(/ 1.0 (/ (sqrt PI) x)))))
double code(double x) {
return fabs(((fma(0.6666666666666666, (x * x), 2.0) + ((0.047619047619047616 * pow(x, 6.0)) + (0.2 * pow(x, 4.0)))) * (1.0 / (sqrt(((double) M_PI)) / x))));
}
function code(x) return abs(Float64(Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(0.2 * (x ^ 4.0)))) * Float64(1.0 / Float64(sqrt(pi) / x)))) end
code[x_] := N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] + N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[Sqrt[Pi], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + \left(0.047619047619047616 \cdot {x}^{6} + 0.2 \cdot {x}^{4}\right)\right) \cdot \frac{1}{\frac{\sqrt{\pi}}{x}}\right|
\end{array}
Initial program 99.9%
Simplified99.4%
div-inv99.8%
pow1/299.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
add-sqr-sqrt30.6%
fabs-sqr30.6%
add-sqr-sqrt99.8%
metadata-eval99.8%
sqrt-pow199.8%
inv-pow99.8%
*-commutative99.8%
sqrt-div99.8%
metadata-eval99.8%
associate-/r/99.4%
Applied egg-rr99.4%
fma-udef99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(fabs
(*
(* (fabs x) (pow PI -0.5))
(+
(* 0.047619047619047616 (pow x 6.0))
(fma 0.6666666666666666 (* x x) 2.0)))))
double code(double x) {
return fabs(((fabs(x) * pow(((double) M_PI), -0.5)) * ((0.047619047619047616 * pow(x, 6.0)) + fma(0.6666666666666666, (x * x), 2.0))));
}
function code(x) return abs(Float64(Float64(abs(x) * (pi ^ -0.5)) * Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + fma(0.6666666666666666, Float64(x * x), 2.0)))) end
code[x_] := N[Abs[N[(N[(N[Abs[x], $MachinePrecision] * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\left|x\right| \cdot {\pi}^{-0.5}\right) \cdot \left(0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.4%
div-inv99.8%
pow1/299.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 98.7%
Final simplification98.7%
(FPCore (x)
:precision binary64
(/
(fabs x)
(fabs
(/
(sqrt PI)
(+
(* 0.047619047619047616 (pow x 6.0))
(fma 0.6666666666666666 (* x x) 2.0))))))
double code(double x) {
return fabs(x) / fabs((sqrt(((double) M_PI)) / ((0.047619047619047616 * pow(x, 6.0)) + fma(0.6666666666666666, (x * x), 2.0))));
}
function code(x) return Float64(abs(x) / abs(Float64(sqrt(pi) / Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + fma(0.6666666666666666, Float64(x * x), 2.0))))) end
code[x_] := N[(N[Abs[x], $MachinePrecision] / N[Abs[N[(N[Sqrt[Pi], $MachinePrecision] / N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x\right|}{\left|\frac{\sqrt{\pi}}{0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}\right|}
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around inf 98.3%
Final simplification98.3%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 0.2)
(/ x (* (sqrt PI) (fma (pow x 2.0) -0.16666666666666666 0.5)))
(fabs
(* 0.047619047619047616 (* (* (fabs x) (pow x 6.0)) (sqrt (/ 1.0 PI)))))))
double code(double x) {
double tmp;
if (fabs(x) <= 0.2) {
tmp = x / (sqrt(((double) M_PI)) * fma(pow(x, 2.0), -0.16666666666666666, 0.5));
} else {
tmp = fabs((0.047619047619047616 * ((fabs(x) * pow(x, 6.0)) * sqrt((1.0 / ((double) M_PI))))));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) <= 0.2) tmp = Float64(x / Float64(sqrt(pi) * fma((x ^ 2.0), -0.16666666666666666, 0.5))); else tmp = abs(Float64(0.047619047619047616 * Float64(Float64(abs(x) * (x ^ 6.0)) * sqrt(Float64(1.0 / pi))))); end return tmp end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.2], N[(x / N[(N[Sqrt[Pi], $MachinePrecision] * N[(N[Power[x, 2.0], $MachinePrecision] * -0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(0.047619047619047616 * N[(N[(N[Abs[x], $MachinePrecision] * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.2:\\
\;\;\;\;\frac{x}{\sqrt{\pi} \cdot \mathsf{fma}\left({x}^{2}, -0.16666666666666666, 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|0.047619047619047616 \cdot \left(\left(\left|x\right| \cdot {x}^{6}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 0.20000000000000001Initial program 99.8%
Simplified99.2%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
associate-*r*98.5%
distribute-rgt-out98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
*-commutative98.5%
fma-udef98.5%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.5%
unpow198.5%
sqr-pow45.5%
fabs-sqr45.5%
sqr-pow47.7%
unpow147.7%
Simplified47.7%
if 0.20000000000000001 < (fabs.f64 x) Initial program 99.9%
Simplified99.9%
div-inv99.9%
pow1/299.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 98.8%
Taylor expanded in x around inf 98.0%
Final simplification64.6%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (/ (sqrt PI) x))
(+
(* 0.047619047619047616 (pow x 6.0))
(fma 0.6666666666666666 (* x x) 2.0)))))
double code(double x) {
return fabs(((1.0 / (sqrt(((double) M_PI)) / x)) * ((0.047619047619047616 * pow(x, 6.0)) + fma(0.6666666666666666, (x * x), 2.0))));
}
function code(x) return abs(Float64(Float64(1.0 / Float64(sqrt(pi) / x)) * Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + fma(0.6666666666666666, Float64(x * x), 2.0)))) end
code[x_] := N[Abs[N[(N[(1.0 / N[(N[Sqrt[Pi], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\frac{\sqrt{\pi}}{x}} \cdot \left(0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.4%
div-inv99.8%
pow1/299.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
add-sqr-sqrt30.6%
fabs-sqr30.6%
add-sqr-sqrt99.8%
metadata-eval99.8%
sqrt-pow199.8%
inv-pow99.8%
*-commutative99.8%
sqrt-div99.8%
metadata-eval99.8%
associate-/r/99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 98.3%
Final simplification98.3%
(FPCore (x) :precision binary64 (/ (fabs x) (fabs (/ (sqrt PI) (+ 2.0 (* 0.047619047619047616 (pow x 6.0)))))))
double code(double x) {
return fabs(x) / fabs((sqrt(((double) M_PI)) / (2.0 + (0.047619047619047616 * pow(x, 6.0)))));
}
public static double code(double x) {
return Math.abs(x) / Math.abs((Math.sqrt(Math.PI) / (2.0 + (0.047619047619047616 * Math.pow(x, 6.0)))));
}
def code(x): return math.fabs(x) / math.fabs((math.sqrt(math.pi) / (2.0 + (0.047619047619047616 * math.pow(x, 6.0)))))
function code(x) return Float64(abs(x) / abs(Float64(sqrt(pi) / Float64(2.0 + Float64(0.047619047619047616 * (x ^ 6.0)))))) end
function tmp = code(x) tmp = abs(x) / abs((sqrt(pi) / (2.0 + (0.047619047619047616 * (x ^ 6.0))))); end
code[x_] := N[(N[Abs[x], $MachinePrecision] / N[Abs[N[(N[Sqrt[Pi], $MachinePrecision] / N[(2.0 + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x\right|}{\left|\frac{\sqrt{\pi}}{2 + 0.047619047619047616 \cdot {x}^{6}}\right|}
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around inf 98.3%
Taylor expanded in x around 0 97.9%
Final simplification97.9%
(FPCore (x) :precision binary64 (log1p (expm1 (/ x (sqrt (* PI 0.25))))))
double code(double x) {
return log1p(expm1((x / sqrt((((double) M_PI) * 0.25)))));
}
public static double code(double x) {
return Math.log1p(Math.expm1((x / Math.sqrt((Math.PI * 0.25)))));
}
def code(x): return math.log1p(math.expm1((x / math.sqrt((math.pi * 0.25)))))
function code(x) return log1p(expm1(Float64(x / sqrt(Float64(pi * 0.25))))) end
code[x_] := N[Log[1 + N[(Exp[N[(x / N[Sqrt[N[(Pi * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{\sqrt{\pi \cdot 0.25}}\right)\right)
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in x around 0 66.9%
expm1-log1p-u66.9%
expm1-udef6.7%
div-fabs6.7%
*-commutative6.7%
Applied egg-rr6.7%
expm1-def66.9%
expm1-log1p66.9%
fabs-div66.9%
unpow166.9%
sqr-pow30.0%
fabs-sqr30.0%
sqr-pow31.5%
unpow131.5%
rem-square-sqrt31.7%
fabs-sqr31.7%
rem-square-sqrt31.5%
Simplified31.5%
Applied egg-rr31.4%
Final simplification31.4%
(FPCore (x) :precision binary64 (if (<= x 1.8) (* x (/ 2.0 (sqrt PI))) (* 0.2 (* (sqrt (/ 1.0 PI)) (pow x 5.0)))))
double code(double x) {
double tmp;
if (x <= 1.8) {
tmp = x * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = 0.2 * (sqrt((1.0 / ((double) M_PI))) * pow(x, 5.0));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.8) {
tmp = x * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = 0.2 * (Math.sqrt((1.0 / Math.PI)) * Math.pow(x, 5.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.8: tmp = x * (2.0 / math.sqrt(math.pi)) else: tmp = 0.2 * (math.sqrt((1.0 / math.pi)) * math.pow(x, 5.0)) return tmp
function code(x) tmp = 0.0 if (x <= 1.8) tmp = Float64(x * Float64(2.0 / sqrt(pi))); else tmp = Float64(0.2 * Float64(sqrt(Float64(1.0 / pi)) * (x ^ 5.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.8) tmp = x * (2.0 / sqrt(pi)); else tmp = 0.2 * (sqrt((1.0 / pi)) * (x ^ 5.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.8], N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.2 * N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8:\\
\;\;\;\;x \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;0.2 \cdot \left(\sqrt{\frac{1}{\pi}} \cdot {x}^{5}\right)\\
\end{array}
\end{array}
if x < 1.80000000000000004Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in x around 0 66.9%
expm1-log1p-u66.9%
expm1-udef6.7%
div-fabs6.7%
*-commutative6.7%
Applied egg-rr6.7%
expm1-def66.9%
expm1-log1p66.9%
fabs-div66.9%
unpow166.9%
sqr-pow30.0%
fabs-sqr30.0%
sqr-pow31.5%
unpow131.5%
rem-square-sqrt31.7%
fabs-sqr31.7%
rem-square-sqrt31.5%
Simplified31.5%
div-inv31.7%
*-commutative31.7%
*-commutative31.7%
associate-/r*31.7%
metadata-eval31.7%
Applied egg-rr31.7%
if 1.80000000000000004 < x Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 93.5%
*-commutative93.5%
Simplified93.5%
div-inv93.9%
add-sqr-sqrt30.4%
fabs-sqr30.4%
add-sqr-sqrt32.0%
*-commutative32.0%
Applied egg-rr32.0%
Taylor expanded in x around inf 3.6%
Final simplification31.7%
(FPCore (x) :precision binary64 (if (<= x 5e-32) (* x (/ 2.0 (sqrt PI))) (sqrt (* (pow x 2.0) (/ 4.0 PI)))))
double code(double x) {
double tmp;
if (x <= 5e-32) {
tmp = x * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = sqrt((pow(x, 2.0) * (4.0 / ((double) M_PI))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 5e-32) {
tmp = x * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = Math.sqrt((Math.pow(x, 2.0) * (4.0 / Math.PI)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5e-32: tmp = x * (2.0 / math.sqrt(math.pi)) else: tmp = math.sqrt((math.pow(x, 2.0) * (4.0 / math.pi))) return tmp
function code(x) tmp = 0.0 if (x <= 5e-32) tmp = Float64(x * Float64(2.0 / sqrt(pi))); else tmp = sqrt(Float64((x ^ 2.0) * Float64(4.0 / pi))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5e-32) tmp = x * (2.0 / sqrt(pi)); else tmp = sqrt(((x ^ 2.0) * (4.0 / pi))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5e-32], N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[x, 2.0], $MachinePrecision] * N[(4.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-32}:\\
\;\;\;\;x \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{x}^{2} \cdot \frac{4}{\pi}}\\
\end{array}
\end{array}
if x < 5e-32Initial program 99.9%
Simplified99.5%
Taylor expanded in x around 0 93.4%
*-commutative93.4%
Simplified93.4%
Taylor expanded in x around 0 66.1%
expm1-log1p-u66.1%
expm1-udef6.2%
div-fabs6.2%
*-commutative6.2%
Applied egg-rr6.2%
expm1-def66.1%
expm1-log1p66.1%
fabs-div66.1%
unpow166.1%
sqr-pow27.7%
fabs-sqr27.7%
sqr-pow29.4%
unpow129.4%
rem-square-sqrt29.5%
fabs-sqr29.5%
rem-square-sqrt29.4%
Simplified29.4%
div-inv29.6%
*-commutative29.6%
*-commutative29.6%
associate-/r*29.6%
metadata-eval29.6%
Applied egg-rr29.6%
if 5e-32 < x Initial program 99.7%
Simplified99.3%
Taylor expanded in x around 0 94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in x around 0 85.1%
expm1-log1p-u85.1%
expm1-udef18.9%
div-fabs18.9%
*-commutative18.9%
Applied egg-rr18.9%
expm1-def85.1%
expm1-log1p85.1%
fabs-div85.1%
unpow185.1%
sqr-pow84.8%
fabs-sqr84.8%
sqr-pow85.1%
unpow185.1%
rem-square-sqrt84.9%
fabs-sqr84.9%
rem-square-sqrt85.1%
Simplified85.1%
add-sqr-sqrt84.9%
sqrt-unprod85.1%
div-inv85.2%
div-inv85.2%
swap-sqr84.9%
unpow284.9%
*-commutative84.9%
associate-/r*84.9%
metadata-eval84.9%
*-commutative84.9%
associate-/r*84.9%
metadata-eval84.9%
frac-times84.5%
metadata-eval84.5%
add-sqr-sqrt85.1%
Applied egg-rr85.1%
Final simplification31.7%
(FPCore (x) :precision binary64 (* x (/ 2.0 (sqrt PI))))
double code(double x) {
return x * (2.0 / sqrt(((double) M_PI)));
}
public static double code(double x) {
return x * (2.0 / Math.sqrt(Math.PI));
}
def code(x): return x * (2.0 / math.sqrt(math.pi))
function code(x) return Float64(x * Float64(2.0 / sqrt(pi))) end
function tmp = code(x) tmp = x * (2.0 / sqrt(pi)); end
code[x_] := N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{2}{\sqrt{\pi}}
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in x around 0 66.9%
expm1-log1p-u66.9%
expm1-udef6.7%
div-fabs6.7%
*-commutative6.7%
Applied egg-rr6.7%
expm1-def66.9%
expm1-log1p66.9%
fabs-div66.9%
unpow166.9%
sqr-pow30.0%
fabs-sqr30.0%
sqr-pow31.5%
unpow131.5%
rem-square-sqrt31.7%
fabs-sqr31.7%
rem-square-sqrt31.5%
Simplified31.5%
div-inv31.7%
*-commutative31.7%
*-commutative31.7%
associate-/r*31.7%
metadata-eval31.7%
Applied egg-rr31.7%
Final simplification31.7%
herbie shell --seed 2023322
(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)))))))