
(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 11 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
(*
(* (pow PI -0.5) x)
(+
(+ (* 0.6666666666666666 (* x x)) 2.0)
(+ (* 0.2 (pow x 4.0)) (* 0.047619047619047616 (pow x 6.0)))))))
double code(double x) {
return fabs(((pow(((double) M_PI), -0.5) * x) * (((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * pow(x, 4.0)) + (0.047619047619047616 * pow(x, 6.0))))));
}
public static double code(double x) {
return Math.abs(((Math.pow(Math.PI, -0.5) * x) * (((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * Math.pow(x, 4.0)) + (0.047619047619047616 * Math.pow(x, 6.0))))));
}
def code(x): return math.fabs(((math.pow(math.pi, -0.5) * x) * (((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * math.pow(x, 4.0)) + (0.047619047619047616 * math.pow(x, 6.0))))))
function code(x) return abs(Float64(Float64((pi ^ -0.5) * x) * Float64(Float64(Float64(0.6666666666666666 * Float64(x * x)) + 2.0) + Float64(Float64(0.2 * (x ^ 4.0)) + Float64(0.047619047619047616 * (x ^ 6.0)))))) end
function tmp = code(x) tmp = abs((((pi ^ -0.5) * x) * (((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * (x ^ 4.0)) + (0.047619047619047616 * (x ^ 6.0)))))); end
code[x_] := N[Abs[N[(N[(N[Power[Pi, -0.5], $MachinePrecision] * x), $MachinePrecision] * N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] + N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left({\pi}^{-0.5} \cdot x\right) \cdot \left(\left(0.6666666666666666 \cdot \left(x \cdot x\right) + 2\right) + \left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l/99.4%
Simplified99.4%
expm1-log1p-u99.3%
expm1-udef36.6%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
expm1-def67.4%
expm1-log1p99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
clear-num99.4%
associate-/r/99.9%
metadata-eval99.9%
sqrt-div99.9%
inv-pow99.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(+ (* 0.6666666666666666 (* x x)) 2.0)
(+ (* 0.2 (pow x 4.0)) (* 0.047619047619047616 (pow x 6.0))))
(/ x (sqrt PI)))))
double code(double x) {
return fabs(((((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * pow(x, 4.0)) + (0.047619047619047616 * pow(x, 6.0)))) * (x / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs(((((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * Math.pow(x, 4.0)) + (0.047619047619047616 * Math.pow(x, 6.0)))) * (x / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs(((((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * math.pow(x, 4.0)) + (0.047619047619047616 * math.pow(x, 6.0)))) * (x / math.sqrt(math.pi))))
function code(x) return abs(Float64(Float64(Float64(Float64(0.6666666666666666 * Float64(x * x)) + 2.0) + Float64(Float64(0.2 * (x ^ 4.0)) + Float64(0.047619047619047616 * (x ^ 6.0)))) * Float64(x / sqrt(pi)))) end
function tmp = code(x) tmp = abs(((((0.6666666666666666 * (x * x)) + 2.0) + ((0.2 * (x ^ 4.0)) + (0.047619047619047616 * (x ^ 6.0)))) * (x / sqrt(pi)))); end
code[x_] := N[Abs[N[(N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] + N[(N[(0.2 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\left(0.6666666666666666 \cdot \left(x \cdot x\right) + 2\right) + \left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)\right) \cdot \frac{x}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
associate-*l/99.4%
Simplified99.4%
expm1-log1p-u99.3%
expm1-udef36.6%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
expm1-def67.4%
expm1-log1p99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
fma-udef99.9%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(fabs
(*
(/ x (sqrt PI))
(+
(* 0.047619047619047616 (pow x 6.0))
(fma 0.6666666666666666 (* x x) 2.0)))))
double code(double x) {
return fabs(((x / sqrt(((double) M_PI))) * ((0.047619047619047616 * pow(x, 6.0)) + fma(0.6666666666666666, (x * x), 2.0))));
}
function code(x) return abs(Float64(Float64(x / sqrt(pi)) * Float64(Float64(0.047619047619047616 * (x ^ 6.0)) + fma(0.6666666666666666, Float64(x * x), 2.0)))) end
code[x_] := N[Abs[N[(N[(x / N[Sqrt[Pi], $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{x}{\sqrt{\pi}} \cdot \left(0.047619047619047616 \cdot {x}^{6} + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l/99.4%
Simplified99.4%
expm1-log1p-u99.3%
expm1-udef36.6%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
expm1-def67.4%
expm1-log1p99.4%
Simplified99.4%
Taylor expanded in x around inf 98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (fabs (/ (fma 2.0 x (* 0.047619047619047616 (pow x 7.0))) (sqrt PI))))
double code(double x) {
return fabs((fma(2.0, x, (0.047619047619047616 * pow(x, 7.0))) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(fma(2.0, x, Float64(0.047619047619047616 * (x ^ 7.0))) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(2.0 * x + N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(2, x, 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.4%
Taylor expanded in x around inf 98.8%
Final simplification98.8%
(FPCore (x)
:precision binary64
(if (<= x -2.2)
(fabs (/ 0.047619047619047616 (* (sqrt PI) (pow x -7.0))))
(fabs
(* (sqrt (/ 1.0 PI)) (+ (* x 2.0) (* 0.6666666666666666 (pow x 3.0)))))))
double code(double x) {
double tmp;
if (x <= -2.2) {
tmp = fabs((0.047619047619047616 / (sqrt(((double) M_PI)) * pow(x, -7.0))));
} else {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * ((x * 2.0) + (0.6666666666666666 * pow(x, 3.0)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2.2) {
tmp = Math.abs((0.047619047619047616 / (Math.sqrt(Math.PI) * Math.pow(x, -7.0))));
} else {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * ((x * 2.0) + (0.6666666666666666 * Math.pow(x, 3.0)))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.2: tmp = math.fabs((0.047619047619047616 / (math.sqrt(math.pi) * math.pow(x, -7.0)))) else: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * ((x * 2.0) + (0.6666666666666666 * math.pow(x, 3.0))))) return tmp
function code(x) tmp = 0.0 if (x <= -2.2) tmp = abs(Float64(0.047619047619047616 / Float64(sqrt(pi) * (x ^ -7.0)))); else tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64(x * 2.0) + Float64(0.6666666666666666 * (x ^ 3.0))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.2) tmp = abs((0.047619047619047616 / (sqrt(pi) * (x ^ -7.0)))); else tmp = abs((sqrt((1.0 / pi)) * ((x * 2.0) + (0.6666666666666666 * (x ^ 3.0))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.2], N[Abs[N[(0.047619047619047616 / N[(N[Sqrt[Pi], $MachinePrecision] * N[Power[x, -7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(x * 2.0), $MachinePrecision] + N[(0.6666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2:\\
\;\;\;\;\left|\frac{0.047619047619047616}{\sqrt{\pi} \cdot {x}^{-7}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2 + 0.6666666666666666 \cdot {x}^{3}\right)\right|\\
\end{array}
\end{array}
if x < -2.2000000000000002Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around inf 99.0%
expm1-log1p-u0.0%
expm1-udef0.0%
associate-*r*0.0%
sqrt-div0.0%
metadata-eval0.0%
un-div-inv0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p99.0%
associate-/l*99.0%
Simplified99.0%
clear-num99.0%
associate-/r/99.0%
pow-flip99.0%
metadata-eval99.0%
Applied egg-rr99.0%
if -2.2000000000000002 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.2%
Taylor expanded in x around 0 99.5%
+-commutative99.5%
associate-*r*99.5%
associate-*r*99.5%
distribute-rgt-out99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= x -1.9) (fabs (sqrt (* 0.0022675736961451248 (/ (pow x 14.0) PI)))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -1.9) {
tmp = fabs(sqrt((0.0022675736961451248 * (pow(x, 14.0) / ((double) M_PI)))));
} else {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.9) {
tmp = Math.abs(Math.sqrt((0.0022675736961451248 * (Math.pow(x, 14.0) / Math.PI))));
} else {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.9: tmp = math.fabs(math.sqrt((0.0022675736961451248 * (math.pow(x, 14.0) / math.pi)))) else: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= -1.9) tmp = abs(sqrt(Float64(0.0022675736961451248 * Float64((x ^ 14.0) / pi)))); else tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.9) tmp = abs(sqrt((0.0022675736961451248 * ((x ^ 14.0) / pi)))); else tmp = abs((x * (2.0 / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.9], N[Abs[N[Sqrt[N[(0.0022675736961451248 * N[(N[Power[x, 14.0], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9:\\
\;\;\;\;\left|\sqrt{0.0022675736961451248 \cdot \frac{{x}^{14}}{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < -1.8999999999999999Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around inf 99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
add-sqr-sqrt0.0%
sqrt-unprod92.2%
swap-sqr92.1%
add-sqr-sqrt92.2%
*-commutative92.2%
*-commutative92.2%
swap-sqr92.1%
pow-prod-up92.2%
metadata-eval92.2%
metadata-eval92.2%
Applied egg-rr92.2%
metadata-eval92.2%
pow-sqr92.2%
associate-*r*92.2%
*-commutative92.2%
associate-*l/92.2%
*-lft-identity92.2%
pow-sqr92.2%
metadata-eval92.2%
Simplified92.2%
if -1.8999999999999999 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.2%
Taylor expanded in x around 0 99.3%
associate-*r*99.3%
Simplified99.3%
expm1-log1p-u99.3%
expm1-udef6.5%
sqrt-div6.5%
metadata-eval6.5%
un-div-inv6.5%
*-commutative6.5%
Applied egg-rr6.5%
expm1-def98.6%
expm1-log1p98.6%
*-commutative98.6%
associate-*l/99.3%
*-commutative99.3%
Simplified99.3%
Final simplification97.1%
(FPCore (x) :precision binary64 (if (<= x -1.9) (fabs (* (pow x 7.0) (/ 0.047619047619047616 (sqrt PI)))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -1.9) {
tmp = fabs((pow(x, 7.0) * (0.047619047619047616 / sqrt(((double) M_PI)))));
} else {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.9) {
tmp = Math.abs((Math.pow(x, 7.0) * (0.047619047619047616 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.9: tmp = math.fabs((math.pow(x, 7.0) * (0.047619047619047616 / math.sqrt(math.pi)))) else: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= -1.9) tmp = abs(Float64((x ^ 7.0) * Float64(0.047619047619047616 / sqrt(pi)))); else tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.9) tmp = abs(((x ^ 7.0) * (0.047619047619047616 / sqrt(pi)))); else tmp = abs((x * (2.0 / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.9], N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] * N[(0.047619047619047616 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9:\\
\;\;\;\;\left|{x}^{7} \cdot \frac{0.047619047619047616}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < -1.8999999999999999Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around inf 99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
expm1-log1p-u0.0%
expm1-udef0.0%
associate-*r*0.0%
*-commutative0.0%
sqrt-div0.0%
metadata-eval0.0%
associate-*l/0.0%
metadata-eval0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p99.0%
Simplified99.0%
if -1.8999999999999999 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.2%
Taylor expanded in x around 0 99.3%
associate-*r*99.3%
Simplified99.3%
expm1-log1p-u99.3%
expm1-udef6.5%
sqrt-div6.5%
metadata-eval6.5%
un-div-inv6.5%
*-commutative6.5%
Applied egg-rr6.5%
expm1-def98.6%
expm1-log1p98.6%
*-commutative98.6%
associate-*l/99.3%
*-commutative99.3%
Simplified99.3%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= x -1.9) (fabs (/ 0.047619047619047616 (* (sqrt PI) (pow x -7.0)))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -1.9) {
tmp = fabs((0.047619047619047616 / (sqrt(((double) M_PI)) * pow(x, -7.0))));
} else {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.9) {
tmp = Math.abs((0.047619047619047616 / (Math.sqrt(Math.PI) * Math.pow(x, -7.0))));
} else {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.9: tmp = math.fabs((0.047619047619047616 / (math.sqrt(math.pi) * math.pow(x, -7.0)))) else: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= -1.9) tmp = abs(Float64(0.047619047619047616 / Float64(sqrt(pi) * (x ^ -7.0)))); else tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.9) tmp = abs((0.047619047619047616 / (sqrt(pi) * (x ^ -7.0)))); else tmp = abs((x * (2.0 / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.9], N[Abs[N[(0.047619047619047616 / N[(N[Sqrt[Pi], $MachinePrecision] * N[Power[x, -7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9:\\
\;\;\;\;\left|\frac{0.047619047619047616}{\sqrt{\pi} \cdot {x}^{-7}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < -1.8999999999999999Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around inf 99.0%
expm1-log1p-u0.0%
expm1-udef0.0%
associate-*r*0.0%
sqrt-div0.0%
metadata-eval0.0%
un-div-inv0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p99.0%
associate-/l*99.0%
Simplified99.0%
clear-num99.0%
associate-/r/99.0%
pow-flip99.0%
metadata-eval99.0%
Applied egg-rr99.0%
if -1.8999999999999999 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.2%
Taylor expanded in x around 0 99.3%
associate-*r*99.3%
Simplified99.3%
expm1-log1p-u99.3%
expm1-udef6.5%
sqrt-div6.5%
metadata-eval6.5%
un-div-inv6.5%
*-commutative6.5%
Applied egg-rr6.5%
expm1-def98.6%
expm1-log1p98.6%
*-commutative98.6%
associate-*l/99.3%
*-commutative99.3%
Simplified99.3%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= x -2e+25) (fabs (sqrt (* 4.0 (/ (* x x) PI)))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -2e+25) {
tmp = fabs(sqrt((4.0 * ((x * x) / ((double) M_PI)))));
} else {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2e+25) {
tmp = Math.abs(Math.sqrt((4.0 * ((x * x) / Math.PI))));
} else {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2e+25: tmp = math.fabs(math.sqrt((4.0 * ((x * x) / math.pi)))) else: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= -2e+25) tmp = abs(sqrt(Float64(4.0 * Float64(Float64(x * x) / pi)))); else tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2e+25) tmp = abs(sqrt((4.0 * ((x * x) / pi)))); else tmp = abs((x * (2.0 / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2e+25], N[Abs[N[Sqrt[N[(4.0 * N[(N[(x * x), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\left|\sqrt{4 \cdot \frac{x \cdot x}{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < -2.00000000000000018e25Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 6.0%
associate-*r*6.0%
Simplified6.0%
add-sqr-sqrt0.0%
sqrt-unprod64.7%
associate-*l*64.7%
sqrt-div64.7%
metadata-eval64.7%
div-inv64.7%
associate-*l*64.7%
sqrt-div64.7%
metadata-eval64.7%
div-inv64.7%
swap-sqr64.7%
metadata-eval64.7%
frac-times64.7%
add-sqr-sqrt64.7%
Applied egg-rr64.7%
*-commutative64.7%
Simplified64.7%
if -2.00000000000000018e25 < x Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.2%
Taylor expanded in x around 0 96.3%
associate-*r*96.3%
Simplified96.3%
expm1-log1p-u96.0%
expm1-udef6.3%
sqrt-div6.3%
metadata-eval6.3%
un-div-inv6.3%
*-commutative6.3%
Applied egg-rr6.3%
expm1-def95.3%
expm1-log1p95.6%
*-commutative95.6%
associate-*l/96.3%
*-commutative96.3%
Simplified96.3%
Final simplification86.9%
(FPCore (x) :precision binary64 (if (<= x -1e-20) (fabs (sqrt (/ 4.0 (/ PI (* x x))))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -1e-20) {
tmp = fabs(sqrt((4.0 / (((double) M_PI) / (x * x)))));
} else {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1e-20) {
tmp = Math.abs(Math.sqrt((4.0 / (Math.PI / (x * x)))));
} else {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1e-20: tmp = math.fabs(math.sqrt((4.0 / (math.pi / (x * x))))) else: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= -1e-20) tmp = abs(sqrt(Float64(4.0 / Float64(pi / Float64(x * x))))); else tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1e-20) tmp = abs(sqrt((4.0 / (pi / (x * x))))); else tmp = abs((x * (2.0 / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1e-20], N[Abs[N[Sqrt[N[(4.0 / N[(Pi / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-20}:\\
\;\;\;\;\left|\sqrt{\frac{4}{\frac{\pi}{x \cdot x}}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < -9.99999999999999945e-21Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around 0 8.6%
associate-*r*8.6%
Simplified8.6%
add-sqr-sqrt0.0%
sqrt-unprod61.0%
associate-*l*61.0%
sqrt-div61.0%
metadata-eval61.0%
div-inv61.0%
associate-*l*61.0%
sqrt-div61.0%
metadata-eval61.0%
div-inv61.0%
swap-sqr61.0%
metadata-eval61.0%
frac-times61.0%
add-sqr-sqrt61.0%
Applied egg-rr61.0%
*-commutative61.0%
Simplified61.0%
*-commutative61.0%
clear-num61.0%
un-div-inv61.0%
Applied egg-rr61.0%
if -9.99999999999999945e-21 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.2%
Taylor expanded in x around 0 99.8%
associate-*r*99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef6.2%
sqrt-div6.2%
metadata-eval6.2%
un-div-inv6.2%
*-commutative6.2%
Applied egg-rr6.2%
expm1-def99.0%
expm1-log1p99.0%
*-commutative99.0%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Final simplification86.9%
(FPCore (x) :precision binary64 (fabs (* x (/ 2.0 (sqrt PI)))))
double code(double x) {
return fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((x * (2.0 / math.sqrt(math.pi))))
function code(x) return abs(Float64(x * Float64(2.0 / sqrt(pi)))) end
function tmp = code(x) tmp = abs((x * (2.0 / sqrt(pi)))); end
code[x_] := N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|x \cdot \frac{2}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.4%
Taylor expanded in x around 0 69.5%
associate-*r*69.5%
Simplified69.5%
expm1-log1p-u67.5%
expm1-udef4.4%
sqrt-div4.4%
metadata-eval4.4%
un-div-inv4.4%
*-commutative4.4%
Applied egg-rr4.4%
expm1-def67.0%
expm1-log1p69.0%
*-commutative69.0%
associate-*l/69.5%
*-commutative69.5%
Simplified69.5%
Final simplification69.5%
herbie shell --seed 2023172
(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)))))))