
(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 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.2 (pow x 4.0) (* 0.047619047619047616 (pow x 6.0)))
(fma 0.6666666666666666 (* x x) 2.0))
(sqrt PI)))))
double code(double x) {
return fabs(x) * fabs(((fma(0.2, pow(x, 4.0), (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(fma(0.2, (x ^ 4.0), 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.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] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{\mathsf{fma}\left(0.2, {x}^{4}, 0.047619047619047616 \cdot {x}^{6}\right) + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Simplified99.9%
(FPCore (x)
:precision binary64
(fabs
(/
(*
(fabs x)
(+
(fma 0.6666666666666666 (* x x) 2.0)
(+ (* 0.047619047619047616 (pow x 6.0)) (* 0.2 (pow x 4.0)))))
(sqrt PI))))
double code(double x) {
return fabs(((fabs(x) * (fma(0.6666666666666666, (x * x), 2.0) + ((0.047619047619047616 * pow(x, 6.0)) + (0.2 * pow(x, 4.0))))) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(Float64(abs(x) * Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + Float64(0.2 * (x ^ 4.0))))) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(N[Abs[x], $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] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\left|x\right| \cdot \left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + \left(0.047619047619047616 \cdot {x}^{6} + 0.2 \cdot {x}^{4}\right)\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Simplified99.5%
metadata-eval99.5%
metadata-eval99.5%
pow-prod-up99.5%
pow-prod-down99.5%
sqr-abs99.5%
pow-prod-down99.5%
pow-prod-up99.5%
metadata-eval99.5%
metadata-eval99.5%
pow-prod-up99.4%
pow-prod-down99.4%
sqr-abs99.4%
pow-prod-down99.4%
pow-prod-up99.5%
metadata-eval99.5%
fma-undefine99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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.8%
Simplified99.9%
Taylor expanded in x around inf 98.6%
(FPCore (x) :precision binary64 (if (<= (fabs x) 2.0) (* x (sqrt (/ 4.0 PI))) (fabs (* (pow PI -0.5) (* 0.047619047619047616 (pow x 7.0))))))
double code(double x) {
double tmp;
if (fabs(x) <= 2.0) {
tmp = x * sqrt((4.0 / ((double) M_PI)));
} else {
tmp = fabs((pow(((double) M_PI), -0.5) * (0.047619047619047616 * pow(x, 7.0))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 2.0) {
tmp = x * Math.sqrt((4.0 / Math.PI));
} else {
tmp = Math.abs((Math.pow(Math.PI, -0.5) * (0.047619047619047616 * Math.pow(x, 7.0))));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 2.0: tmp = x * math.sqrt((4.0 / math.pi)) else: tmp = math.fabs((math.pow(math.pi, -0.5) * (0.047619047619047616 * math.pow(x, 7.0)))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 2.0) tmp = Float64(x * sqrt(Float64(4.0 / pi))); else tmp = abs(Float64((pi ^ -0.5) * Float64(0.047619047619047616 * (x ^ 7.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 2.0) tmp = x * sqrt((4.0 / pi)); else tmp = abs(((pi ^ -0.5) * (0.047619047619047616 * (x ^ 7.0)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2.0], N[(x * N[Sqrt[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2:\\
\;\;\;\;x \cdot \sqrt{\frac{4}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\left|{\pi}^{-0.5} \cdot \left(0.047619047619047616 \cdot {x}^{7}\right)\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 2Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 98.5%
associate-*r*98.5%
Simplified98.5%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
associate-*r*98.5%
rem-exp-log98.5%
rec-exp98.5%
unpow1/298.5%
exp-prod98.5%
distribute-lft-neg-out98.5%
distribute-rgt-neg-in98.5%
metadata-eval98.5%
exp-to-pow98.5%
*-commutative98.5%
associate-*l*98.5%
fabs-mul98.5%
fabs-fabs98.5%
rem-square-sqrt96.8%
Simplified98.5%
Taylor expanded in x around 0 98.5%
associate-*r*98.5%
*-commutative98.5%
rem-square-sqrt50.4%
fabs-sqr50.4%
rem-square-sqrt52.7%
metadata-eval52.7%
unpow-152.7%
metadata-eval52.7%
pow-sqr52.7%
rem-sqrt-square52.7%
fabs-mul52.7%
rem-sqrt-square52.7%
swap-sqr52.7%
metadata-eval52.7%
pow-sqr52.7%
metadata-eval52.7%
unpow-152.7%
associate-*r/52.7%
metadata-eval52.7%
Simplified52.7%
if 2 < (fabs.f64 x) Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
*-commutative98.5%
*-commutative98.5%
*-commutative98.5%
associate-*r*98.4%
associate-*l*98.4%
*-commutative98.4%
associate-*l*98.5%
distribute-lft-out98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
associate-*r*98.4%
*-commutative98.4%
unpow-198.4%
metadata-eval98.4%
pow-sqr98.4%
rem-sqrt-square98.4%
metadata-eval98.4%
pow-sqr98.4%
fabs-sqr98.4%
pow-sqr98.4%
metadata-eval98.4%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt98.4%
pow-plus98.4%
metadata-eval98.4%
Simplified98.4%
(FPCore (x) :precision binary64 (* (fabs x) (fabs (/ (+ (* 0.047619047619047616 (pow x 6.0)) 2.0) (sqrt PI)))))
double code(double x) {
return fabs(x) * fabs((((0.047619047619047616 * pow(x, 6.0)) + 2.0) / sqrt(((double) M_PI))));
}
public static double code(double x) {
return Math.abs(x) * Math.abs((((0.047619047619047616 * Math.pow(x, 6.0)) + 2.0) / Math.sqrt(Math.PI)));
}
def code(x): return math.fabs(x) * math.fabs((((0.047619047619047616 * math.pow(x, 6.0)) + 2.0) / math.sqrt(math.pi)))
function code(x) return Float64(abs(x) * abs(Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + 2.0) / sqrt(pi)))) end
function tmp = code(x) tmp = abs(x) * abs((((0.047619047619047616 * (x ^ 6.0)) + 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] + 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{0.047619047619047616 \cdot {x}^{6} + 2}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
Simplified99.9%
Taylor expanded in x around inf 98.6%
Taylor expanded in x around 0 98.5%
(FPCore (x) :precision binary64 (if (<= (fabs x) 2.0) (* x (sqrt (/ 4.0 PI))) (* (* 0.2 (pow x 4.0)) (/ x (sqrt PI)))))
double code(double x) {
double tmp;
if (fabs(x) <= 2.0) {
tmp = x * sqrt((4.0 / ((double) M_PI)));
} else {
tmp = (0.2 * pow(x, 4.0)) * (x / sqrt(((double) M_PI)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 2.0) {
tmp = x * Math.sqrt((4.0 / Math.PI));
} else {
tmp = (0.2 * Math.pow(x, 4.0)) * (x / Math.sqrt(Math.PI));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 2.0: tmp = x * math.sqrt((4.0 / math.pi)) else: tmp = (0.2 * math.pow(x, 4.0)) * (x / math.sqrt(math.pi)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 2.0) tmp = Float64(x * sqrt(Float64(4.0 / pi))); else tmp = Float64(Float64(0.2 * (x ^ 4.0)) * Float64(x / sqrt(pi))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 2.0) tmp = x * sqrt((4.0 / pi)); else tmp = (0.2 * (x ^ 4.0)) * (x / sqrt(pi)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2.0], N[(x * N[Sqrt[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2:\\
\;\;\;\;x \cdot \sqrt{\frac{4}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\left(0.2 \cdot {x}^{4}\right) \cdot \frac{x}{\sqrt{\pi}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 2Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 98.5%
associate-*r*98.5%
Simplified98.5%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
associate-*r*98.5%
rem-exp-log98.5%
rec-exp98.5%
unpow1/298.5%
exp-prod98.5%
distribute-lft-neg-out98.5%
distribute-rgt-neg-in98.5%
metadata-eval98.5%
exp-to-pow98.5%
*-commutative98.5%
associate-*l*98.5%
fabs-mul98.5%
fabs-fabs98.5%
rem-square-sqrt96.8%
Simplified98.5%
Taylor expanded in x around 0 98.5%
associate-*r*98.5%
*-commutative98.5%
rem-square-sqrt50.4%
fabs-sqr50.4%
rem-square-sqrt52.7%
metadata-eval52.7%
unpow-152.7%
metadata-eval52.7%
pow-sqr52.7%
rem-sqrt-square52.7%
fabs-mul52.7%
rem-sqrt-square52.7%
swap-sqr52.7%
metadata-eval52.7%
pow-sqr52.7%
metadata-eval52.7%
unpow-152.7%
associate-*r/52.7%
metadata-eval52.7%
Simplified52.7%
if 2 < (fabs.f64 x) Initial program 99.9%
Simplified100.0%
Taylor expanded in x around 0 87.4%
pow187.4%
mul-fabs87.4%
fma-define87.4%
pow287.4%
Applied egg-rr87.4%
unpow187.4%
associate-*r/87.4%
fabs-div87.4%
fma-undefine87.4%
+-commutative87.4%
fma-undefine87.4%
associate-+r+87.4%
fma-define87.4%
+-commutative87.4%
fma-define87.4%
rem-sqrt-square87.4%
rem-square-sqrt87.4%
Simplified87.4%
*-un-lft-identity87.4%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.1%
Applied egg-rr0.1%
*-lft-identity0.1%
*-commutative0.1%
associate-/l*0.1%
Simplified0.1%
Taylor expanded in x around inf 0.1%
(FPCore (x) :precision binary64 (if (<= (fabs x) 2e-22) (* x (sqrt (/ 4.0 PI))) (sqrt (* (/ 4.0 PI) (pow x 2.0)))))
double code(double x) {
double tmp;
if (fabs(x) <= 2e-22) {
tmp = x * sqrt((4.0 / ((double) M_PI)));
} else {
tmp = sqrt(((4.0 / ((double) M_PI)) * pow(x, 2.0)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 2e-22) {
tmp = x * Math.sqrt((4.0 / Math.PI));
} else {
tmp = Math.sqrt(((4.0 / Math.PI) * Math.pow(x, 2.0)));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 2e-22: tmp = x * math.sqrt((4.0 / math.pi)) else: tmp = math.sqrt(((4.0 / math.pi) * math.pow(x, 2.0))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 2e-22) tmp = Float64(x * sqrt(Float64(4.0 / pi))); else tmp = sqrt(Float64(Float64(4.0 / pi) * (x ^ 2.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 2e-22) tmp = x * sqrt((4.0 / pi)); else tmp = sqrt(((4.0 / pi) * (x ^ 2.0))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2e-22], N[(x * N[Sqrt[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(4.0 / Pi), $MachinePrecision] * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2 \cdot 10^{-22}:\\
\;\;\;\;x \cdot \sqrt{\frac{4}{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{4}{\pi} \cdot {x}^{2}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 2.0000000000000001e-22Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-*r*99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.8%
rem-exp-log99.8%
rec-exp99.8%
unpow1/299.8%
exp-prod99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
exp-to-pow99.8%
*-commutative99.8%
associate-*l*99.8%
fabs-mul99.8%
fabs-fabs99.8%
rem-square-sqrt98.1%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
rem-square-sqrt50.9%
fabs-sqr50.9%
rem-square-sqrt53.2%
metadata-eval53.2%
unpow-153.2%
metadata-eval53.2%
pow-sqr53.2%
rem-sqrt-square53.2%
fabs-mul53.2%
rem-sqrt-square53.2%
swap-sqr53.2%
metadata-eval53.2%
pow-sqr53.2%
metadata-eval53.2%
unpow-153.2%
associate-*r/53.2%
metadata-eval53.2%
Simplified53.2%
if 2.0000000000000001e-22 < (fabs.f64 x) Initial program 99.9%
Simplified99.8%
Taylor expanded in x around 0 12.7%
associate-*r*12.7%
Simplified12.7%
Taylor expanded in x around 0 12.7%
*-commutative12.7%
associate-*r*12.7%
rem-exp-log12.7%
rec-exp12.7%
unpow1/212.7%
exp-prod12.7%
distribute-lft-neg-out12.7%
distribute-rgt-neg-in12.7%
metadata-eval12.7%
exp-to-pow12.7%
*-commutative12.7%
associate-*l*12.7%
fabs-mul12.7%
fabs-fabs12.7%
rem-square-sqrt12.6%
Simplified12.7%
Taylor expanded in x around 0 12.7%
associate-*r*12.7%
*-commutative12.7%
rem-square-sqrt4.2%
fabs-sqr4.2%
rem-square-sqrt4.6%
metadata-eval4.6%
unpow-14.6%
metadata-eval4.6%
pow-sqr4.6%
rem-sqrt-square4.6%
fabs-mul4.6%
rem-sqrt-square4.6%
swap-sqr4.6%
metadata-eval4.6%
pow-sqr4.6%
metadata-eval4.6%
unpow-14.6%
associate-*r/4.6%
metadata-eval4.6%
Simplified4.6%
add-sqr-sqrt4.3%
sqrt-unprod57.6%
*-commutative57.6%
*-commutative57.6%
swap-sqr57.5%
add-sqr-sqrt57.6%
unpow257.6%
Applied egg-rr57.6%
*-commutative57.6%
Simplified57.6%
Final simplification55.0%
(FPCore (x) :precision binary64 (fabs (* (+ (* 0.047619047619047616 (pow x 6.0)) 2.0) (* x (pow PI -0.5)))))
double code(double x) {
return fabs((((0.047619047619047616 * pow(x, 6.0)) + 2.0) * (x * pow(((double) M_PI), -0.5))));
}
public static double code(double x) {
return Math.abs((((0.047619047619047616 * Math.pow(x, 6.0)) + 2.0) * (x * Math.pow(Math.PI, -0.5))));
}
def code(x): return math.fabs((((0.047619047619047616 * math.pow(x, 6.0)) + 2.0) * (x * math.pow(math.pi, -0.5))))
function code(x) return abs(Float64(Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + 2.0) * Float64(x * (pi ^ -0.5)))) end
function tmp = code(x) tmp = abs((((0.047619047619047616 * (x ^ 6.0)) + 2.0) * (x * (pi ^ -0.5)))); end
code[x_] := N[Abs[N[(N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(0.047619047619047616 \cdot {x}^{6} + 2\right) \cdot \left(x \cdot {\pi}^{-0.5}\right)\right|
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
*-commutative98.5%
*-commutative98.5%
*-commutative98.5%
associate-*r*98.5%
associate-*l*98.5%
*-commutative98.5%
associate-*l*98.5%
distribute-lft-out98.5%
Simplified98.5%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
rem-square-sqrt31.9%
fabs-sqr31.9%
rem-square-sqrt98.5%
unpow-198.5%
metadata-eval98.5%
pow-sqr98.5%
rem-sqrt-square98.5%
metadata-eval98.5%
pow-sqr98.5%
fabs-sqr98.5%
pow-sqr98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (/ (* x (fma 0.047619047619047616 (pow x 6.0) 2.0)) (sqrt PI)))
double code(double x) {
return (x * fma(0.047619047619047616, pow(x, 6.0), 2.0)) / sqrt(((double) M_PI));
}
function code(x) return Float64(Float64(x * fma(0.047619047619047616, (x ^ 6.0), 2.0)) / sqrt(pi)) end
code[x_] := N[(N[(x * N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \mathsf{fma}\left(0.047619047619047616, {x}^{6}, 2\right)}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Simplified99.9%
Taylor expanded in x around inf 98.6%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
add-sqr-sqrt97.4%
fabs-sqr97.4%
add-sqr-sqrt98.5%
add-sqr-sqrt31.9%
fabs-sqr31.9%
add-sqr-sqrt33.4%
associate-*l/33.1%
fma-define33.1%
Applied egg-rr33.1%
Final simplification33.1%
(FPCore (x) :precision binary64 (* (fma 0.047619047619047616 (pow x 6.0) 2.0) (/ x (sqrt PI))))
double code(double x) {
return fma(0.047619047619047616, pow(x, 6.0), 2.0) * (x / sqrt(((double) M_PI)));
}
function code(x) return Float64(fma(0.047619047619047616, (x ^ 6.0), 2.0) * Float64(x / sqrt(pi))) end
code[x_] := N[(N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision] + 2.0), $MachinePrecision] * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.047619047619047616, {x}^{6}, 2\right) \cdot \frac{x}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Simplified99.9%
Taylor expanded in x around inf 98.6%
Taylor expanded in x around 0 98.5%
add-sqr-sqrt31.9%
fabs-sqr31.9%
add-sqr-sqrt33.4%
add-sqr-sqrt32.8%
fabs-sqr32.8%
add-sqr-sqrt33.4%
clear-num33.4%
associate-/r/33.4%
pow1/233.4%
pow-flip33.4%
metadata-eval33.4%
+-commutative33.4%
associate-*l*33.4%
distribute-rgt-in33.4%
Applied egg-rr33.1%
associate-*r*33.1%
distribute-rgt-in33.1%
+-commutative33.1%
fma-undefine33.1%
Simplified33.1%
Final simplification33.1%
(FPCore (x) :precision binary64 (log1p (expm1 (* (pow PI -0.5) (* x 2.0)))))
double code(double x) {
return log1p(expm1((pow(((double) M_PI), -0.5) * (x * 2.0))));
}
public static double code(double x) {
return Math.log1p(Math.expm1((Math.pow(Math.PI, -0.5) * (x * 2.0))));
}
def code(x): return math.log1p(math.expm1((math.pow(math.pi, -0.5) * (x * 2.0))))
function code(x) return log1p(expm1(Float64((pi ^ -0.5) * Float64(x * 2.0)))) end
code[x_] := N[Log[1 + N[(Exp[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left({\pi}^{-0.5} \cdot \left(x \cdot 2\right)\right)\right)
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 64.4%
associate-*r*64.4%
Simplified64.4%
Taylor expanded in x around 0 64.4%
*-commutative64.4%
associate-*r*64.4%
rem-exp-log64.4%
rec-exp64.4%
unpow1/264.4%
exp-prod64.4%
distribute-lft-neg-out64.4%
distribute-rgt-neg-in64.4%
metadata-eval64.4%
exp-to-pow64.4%
*-commutative64.4%
associate-*l*64.4%
fabs-mul64.4%
fabs-fabs64.4%
rem-square-sqrt63.4%
Simplified64.4%
*-commutative64.4%
associate-*r*64.4%
add-sqr-sqrt63.9%
fabs-sqr63.9%
add-sqr-sqrt64.4%
log1p-expm1-u94.7%
add-sqr-sqrt94.2%
fabs-sqr94.2%
add-sqr-sqrt94.7%
*-commutative94.7%
add-sqr-sqrt31.9%
fabs-sqr31.9%
add-sqr-sqrt33.4%
associate-*l*33.4%
Applied egg-rr33.4%
(FPCore (x) :precision binary64 (log1p (expm1 (/ (* x 2.0) (sqrt PI)))))
double code(double x) {
return log1p(expm1(((x * 2.0) / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.log1p(Math.expm1(((x * 2.0) / Math.sqrt(Math.PI))));
}
def code(x): return math.log1p(math.expm1(((x * 2.0) / math.sqrt(math.pi))))
function code(x) return log1p(expm1(Float64(Float64(x * 2.0) / sqrt(pi)))) end
code[x_] := N[Log[1 + N[(Exp[N[(N[(x * 2.0), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x \cdot 2}{\sqrt{\pi}}\right)\right)
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 64.4%
associate-*r*64.4%
Simplified64.4%
Taylor expanded in x around 0 64.4%
*-commutative64.4%
associate-*r*64.4%
rem-exp-log64.4%
rec-exp64.4%
unpow1/264.4%
exp-prod64.4%
distribute-lft-neg-out64.4%
distribute-rgt-neg-in64.4%
metadata-eval64.4%
exp-to-pow64.4%
*-commutative64.4%
associate-*l*64.4%
fabs-mul64.4%
fabs-fabs64.4%
rem-square-sqrt63.4%
Simplified64.4%
*-commutative64.4%
associate-*r*64.4%
add-sqr-sqrt63.9%
fabs-sqr63.9%
add-sqr-sqrt64.4%
log1p-expm1-u94.7%
add-sqr-sqrt94.2%
fabs-sqr94.2%
add-sqr-sqrt94.7%
*-commutative94.7%
add-sqr-sqrt31.9%
fabs-sqr31.9%
add-sqr-sqrt33.4%
associate-*l*33.4%
Applied egg-rr33.4%
expm1-undefine3.9%
sub-neg3.9%
*-commutative3.9%
*-commutative3.9%
associate-*r*3.9%
*-commutative3.9%
associate-*r*3.9%
metadata-eval3.9%
pow-flip3.9%
pow1/23.9%
div-inv3.9%
metadata-eval3.9%
sqrt-div3.9%
exp-prod3.9%
sqrt-div3.9%
metadata-eval3.9%
metadata-eval3.9%
Applied egg-rr3.9%
metadata-eval3.9%
sub-neg3.9%
exp-prod3.9%
associate-*l/3.9%
associate-*r/3.9%
expm1-undefine33.1%
associate-*r/33.1%
Simplified33.1%
Final simplification33.1%
(FPCore (x) :precision binary64 (* x (sqrt (/ 4.0 PI))))
double code(double x) {
return x * sqrt((4.0 / ((double) M_PI)));
}
public static double code(double x) {
return x * Math.sqrt((4.0 / Math.PI));
}
def code(x): return x * math.sqrt((4.0 / math.pi))
function code(x) return Float64(x * sqrt(Float64(4.0 / pi))) end
function tmp = code(x) tmp = x * sqrt((4.0 / pi)); end
code[x_] := N[(x * N[Sqrt[N[(4.0 / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sqrt{\frac{4}{\pi}}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 64.4%
associate-*r*64.4%
Simplified64.4%
Taylor expanded in x around 0 64.4%
*-commutative64.4%
associate-*r*64.4%
rem-exp-log64.4%
rec-exp64.4%
unpow1/264.4%
exp-prod64.4%
distribute-lft-neg-out64.4%
distribute-rgt-neg-in64.4%
metadata-eval64.4%
exp-to-pow64.4%
*-commutative64.4%
associate-*l*64.4%
fabs-mul64.4%
fabs-fabs64.4%
rem-square-sqrt63.4%
Simplified64.4%
Taylor expanded in x around 0 64.4%
associate-*r*64.4%
*-commutative64.4%
rem-square-sqrt31.9%
fabs-sqr31.9%
rem-square-sqrt33.5%
metadata-eval33.5%
unpow-133.5%
metadata-eval33.5%
pow-sqr33.5%
rem-sqrt-square33.5%
fabs-mul33.5%
rem-sqrt-square33.5%
swap-sqr33.5%
metadata-eval33.5%
pow-sqr33.5%
metadata-eval33.5%
unpow-133.5%
associate-*r/33.5%
metadata-eval33.5%
Simplified33.5%
herbie shell --seed 2024166
(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)))))))