
(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
(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.9%
Simplified99.4%
expm1-log1p-u99.2%
expm1-udef40.1%
Applied egg-rr40.1%
expm1-def99.2%
expm1-log1p99.4%
unpow199.4%
sqr-pow35.5%
fabs-sqr35.5%
sqr-pow99.4%
unpow199.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
*-un-lft-identity99.4%
associate-*l/99.9%
pow1/299.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
Applied egg-rr99.9%
Final simplification99.9%
(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.9%
Simplified99.4%
expm1-log1p-u99.2%
expm1-udef40.1%
Applied egg-rr40.1%
expm1-def99.2%
expm1-log1p99.4%
unpow199.4%
sqr-pow35.5%
fabs-sqr35.5%
sqr-pow99.4%
unpow199.4%
Simplified99.4%
Taylor expanded in x around inf 98.5%
Final simplification98.5%
(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.9%
Simplified99.4%
Taylor expanded in x around inf 98.2%
Final simplification98.2%
(FPCore (x)
:precision binary64
(if (<= x -2.15)
(fabs (sqrt (* 0.0022675736961451248 (/ (pow x 14.0) PI))))
(fabs
(* (sqrt (/ 1.0 PI)) (+ (* x 2.0) (* x (* 0.6666666666666666 (* x x))))))))
double code(double x) {
double tmp;
if (x <= -2.15) {
tmp = fabs(sqrt((0.0022675736961451248 * (pow(x, 14.0) / ((double) M_PI)))));
} else {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2.15) {
tmp = Math.abs(Math.sqrt((0.0022675736961451248 * (Math.pow(x, 14.0) / Math.PI))));
} else {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.15: tmp = math.fabs(math.sqrt((0.0022675736961451248 * (math.pow(x, 14.0) / math.pi)))) else: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))) return tmp
function code(x) tmp = 0.0 if (x <= -2.15) tmp = abs(sqrt(Float64(0.0022675736961451248 * Float64((x ^ 14.0) / pi)))); else tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64(x * 2.0) + Float64(x * Float64(0.6666666666666666 * Float64(x * x)))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.15) tmp = abs(sqrt((0.0022675736961451248 * ((x ^ 14.0) / pi)))); else tmp = abs((sqrt((1.0 / pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.15], N[Abs[N[Sqrt[N[(0.0022675736961451248 * N[(N[Power[x, 14.0], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(x * 2.0), $MachinePrecision] + N[(x * N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15:\\
\;\;\;\;\left|\sqrt{0.0022675736961451248 \cdot \frac{{x}^{14}}{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2 + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)\right|\\
\end{array}
\end{array}
if x < -2.14999999999999991Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 99.6%
associate-*r*99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around inf 98.8%
associate-*r*98.8%
Simplified98.8%
add-sqr-sqrt0.0%
sqrt-unprod92.7%
*-commutative92.7%
*-commutative92.7%
swap-sqr92.7%
add-sqr-sqrt92.7%
*-commutative92.7%
*-commutative92.7%
swap-sqr92.7%
pow-prod-up92.7%
metadata-eval92.7%
metadata-eval92.8%
Applied egg-rr92.8%
associate-*r*92.8%
*-commutative92.8%
associate-*l/92.8%
*-lft-identity92.8%
Simplified92.8%
if -2.14999999999999991 < x Initial program 99.9%
Simplified99.2%
Taylor expanded in x around 0 99.0%
+-commutative99.0%
associate-*r*99.0%
associate-*r*99.0%
distribute-rgt-out99.0%
*-commutative99.0%
unpow199.0%
sqr-pow54.2%
fabs-sqr54.2%
sqr-pow98.7%
unpow198.7%
*-commutative98.7%
cube-mult98.7%
associate-*l*98.7%
unpow198.7%
sqr-pow54.5%
fabs-sqr54.5%
sqr-pow99.0%
unpow199.0%
*-commutative99.0%
Simplified99.0%
fma-udef99.0%
distribute-rgt-in99.0%
Applied egg-rr99.0%
Final simplification96.8%
(FPCore (x)
:precision binary64
(if (<= x -2.15)
(fabs (* 0.047619047619047616 (/ (pow x 7.0) (sqrt PI))))
(fabs
(* (sqrt (/ 1.0 PI)) (+ (* x 2.0) (* x (* 0.6666666666666666 (* x x))))))))
double code(double x) {
double tmp;
if (x <= -2.15) {
tmp = fabs((0.047619047619047616 * (pow(x, 7.0) / sqrt(((double) M_PI)))));
} else {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2.15) {
tmp = Math.abs((0.047619047619047616 * (Math.pow(x, 7.0) / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.15: tmp = math.fabs((0.047619047619047616 * (math.pow(x, 7.0) / math.sqrt(math.pi)))) else: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))) return tmp
function code(x) tmp = 0.0 if (x <= -2.15) tmp = abs(Float64(0.047619047619047616 * Float64((x ^ 7.0) / sqrt(pi)))); else tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64(x * 2.0) + Float64(x * Float64(0.6666666666666666 * Float64(x * x)))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.15) tmp = abs((0.047619047619047616 * ((x ^ 7.0) / sqrt(pi)))); else tmp = abs((sqrt((1.0 / pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.15], N[Abs[N[(0.047619047619047616 * N[(N[Power[x, 7.0], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(x * 2.0), $MachinePrecision] + N[(x * N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15:\\
\;\;\;\;\left|0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2 + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)\right|\\
\end{array}
\end{array}
if x < -2.14999999999999991Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 99.6%
associate-*r*99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around inf 98.8%
associate-*r*98.8%
Simplified98.8%
expm1-log1p-u0.0%
expm1-udef0.0%
associate-*l*0.0%
sqrt-div0.0%
metadata-eval0.0%
un-div-inv0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p98.9%
Simplified98.9%
if -2.14999999999999991 < x Initial program 99.9%
Simplified99.2%
Taylor expanded in x around 0 99.0%
+-commutative99.0%
associate-*r*99.0%
associate-*r*99.0%
distribute-rgt-out99.0%
*-commutative99.0%
unpow199.0%
sqr-pow54.2%
fabs-sqr54.2%
sqr-pow98.7%
unpow198.7%
*-commutative98.7%
cube-mult98.7%
associate-*l*98.7%
unpow198.7%
sqr-pow54.5%
fabs-sqr54.5%
sqr-pow99.0%
unpow199.0%
*-commutative99.0%
Simplified99.0%
fma-udef99.0%
distribute-rgt-in99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (x)
:precision binary64
(if (<= x -2.15)
(fabs (/ (* 0.047619047619047616 (pow x 7.0)) (sqrt PI)))
(fabs
(* (sqrt (/ 1.0 PI)) (+ (* x 2.0) (* x (* 0.6666666666666666 (* x x))))))))
double code(double x) {
double tmp;
if (x <= -2.15) {
tmp = fabs(((0.047619047619047616 * pow(x, 7.0)) / sqrt(((double) M_PI))));
} else {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2.15) {
tmp = Math.abs(((0.047619047619047616 * Math.pow(x, 7.0)) / Math.sqrt(Math.PI)));
} else {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.15: tmp = math.fabs(((0.047619047619047616 * math.pow(x, 7.0)) / math.sqrt(math.pi))) else: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))) return tmp
function code(x) tmp = 0.0 if (x <= -2.15) tmp = abs(Float64(Float64(0.047619047619047616 * (x ^ 7.0)) / sqrt(pi))); else tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64(x * 2.0) + Float64(x * Float64(0.6666666666666666 * Float64(x * x)))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.15) tmp = abs(((0.047619047619047616 * (x ^ 7.0)) / sqrt(pi))); else tmp = abs((sqrt((1.0 / pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.15], N[Abs[N[(N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(x * 2.0), $MachinePrecision] + N[(x * N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15:\\
\;\;\;\;\left|\frac{0.047619047619047616 \cdot {x}^{7}}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2 + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)\right|\\
\end{array}
\end{array}
if x < -2.14999999999999991Initial program 99.9%
Simplified99.9%
Taylor expanded in x around inf 99.6%
associate-*r*99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around inf 98.8%
associate-*r*98.8%
Simplified98.8%
sqrt-div98.8%
metadata-eval98.8%
un-div-inv98.9%
Applied egg-rr98.9%
if -2.14999999999999991 < x Initial program 99.9%
Simplified99.2%
Taylor expanded in x around 0 99.0%
+-commutative99.0%
associate-*r*99.0%
associate-*r*99.0%
distribute-rgt-out99.0%
*-commutative99.0%
unpow199.0%
sqr-pow54.2%
fabs-sqr54.2%
sqr-pow98.7%
unpow198.7%
*-commutative98.7%
cube-mult98.7%
associate-*l*98.7%
unpow198.7%
sqr-pow54.5%
fabs-sqr54.5%
sqr-pow99.0%
unpow199.0%
*-commutative99.0%
Simplified99.0%
fma-udef99.0%
distribute-rgt-in99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (* 0.6666666666666666 (* x x))))
(if (<= x -5e+156)
(fabs (sqrt (* 4.0 (/ (* x x) PI))))
(fabs (* (sqrt (/ 1.0 PI)) (* x (/ (- (* t_0 t_0) 4.0) (- t_0 2.0))))))))
double code(double x) {
double t_0 = 0.6666666666666666 * (x * x);
double tmp;
if (x <= -5e+156) {
tmp = fabs(sqrt((4.0 * ((x * x) / ((double) M_PI)))));
} else {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * (x * (((t_0 * t_0) - 4.0) / (t_0 - 2.0)))));
}
return tmp;
}
public static double code(double x) {
double t_0 = 0.6666666666666666 * (x * x);
double tmp;
if (x <= -5e+156) {
tmp = Math.abs(Math.sqrt((4.0 * ((x * x) / Math.PI))));
} else {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * (x * (((t_0 * t_0) - 4.0) / (t_0 - 2.0)))));
}
return tmp;
}
def code(x): t_0 = 0.6666666666666666 * (x * x) tmp = 0 if x <= -5e+156: tmp = math.fabs(math.sqrt((4.0 * ((x * x) / math.pi)))) else: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * (x * (((t_0 * t_0) - 4.0) / (t_0 - 2.0))))) return tmp
function code(x) t_0 = Float64(0.6666666666666666 * Float64(x * x)) tmp = 0.0 if (x <= -5e+156) tmp = abs(sqrt(Float64(4.0 * Float64(Float64(x * x) / pi)))); else tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(x * Float64(Float64(Float64(t_0 * t_0) - 4.0) / Float64(t_0 - 2.0))))); end return tmp end
function tmp_2 = code(x) t_0 = 0.6666666666666666 * (x * x); tmp = 0.0; if (x <= -5e+156) tmp = abs(sqrt((4.0 * ((x * x) / pi)))); else tmp = abs((sqrt((1.0 / pi)) * (x * (((t_0 * t_0) - 4.0) / (t_0 - 2.0))))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e+156], N[Abs[N[Sqrt[N[(4.0 * N[(N[(x * x), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(x * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - 4.0), $MachinePrecision] / N[(t$95$0 - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.6666666666666666 \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{+156}:\\
\;\;\;\;\left|\sqrt{4 \cdot \frac{x \cdot x}{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot \frac{t_0 \cdot t_0 - 4}{t_0 - 2}\right)\right|\\
\end{array}
\end{array}
if x < -4.99999999999999992e156Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 6.6%
*-commutative6.6%
associate-*l*6.6%
Simplified6.6%
add-sqr-sqrt0.0%
sqrt-unprod100.0%
associate-*r*100.0%
sqrt-div100.0%
metadata-eval100.0%
div-inv100.0%
associate-*r*100.0%
sqrt-div100.0%
metadata-eval100.0%
div-inv100.0%
swap-sqr100.0%
frac-times100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -4.99999999999999992e156 < x Initial program 99.8%
Simplified99.3%
Taylor expanded in x around 0 86.1%
+-commutative86.1%
associate-*r*86.1%
associate-*r*86.1%
distribute-rgt-out86.1%
*-commutative86.1%
unpow186.1%
sqr-pow42.1%
fabs-sqr42.1%
sqr-pow85.9%
unpow185.9%
*-commutative85.9%
cube-mult85.9%
associate-*l*85.9%
unpow185.9%
sqr-pow42.4%
fabs-sqr42.4%
sqr-pow86.1%
unpow186.1%
*-commutative86.1%
Simplified86.1%
fma-udef86.1%
flip-+89.6%
metadata-eval89.6%
Applied egg-rr89.6%
Final simplification91.3%
(FPCore (x) :precision binary64 (fabs (* (sqrt (/ 1.0 PI)) (+ (* x 2.0) (* x (* 0.6666666666666666 (* x x)))))))
double code(double x) {
return fabs((sqrt((1.0 / ((double) M_PI))) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
public static double code(double x) {
return Math.abs((Math.sqrt((1.0 / Math.PI)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))));
}
def code(x): return math.fabs((math.sqrt((1.0 / math.pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x))))))
function code(x) return abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64(x * 2.0) + Float64(x * Float64(0.6666666666666666 * Float64(x * x)))))) end
function tmp = code(x) tmp = abs((sqrt((1.0 / pi)) * ((x * 2.0) + (x * (0.6666666666666666 * (x * x)))))); end
code[x_] := N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(x * 2.0), $MachinePrecision] + N[(x * N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot 2 + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 88.4%
+-commutative88.4%
associate-*r*88.4%
associate-*r*88.4%
distribute-rgt-out88.4%
*-commutative88.4%
unpow188.4%
sqr-pow35.4%
fabs-sqr35.4%
sqr-pow88.1%
unpow188.1%
*-commutative88.1%
cube-mult88.1%
associate-*l*88.1%
unpow188.1%
sqr-pow35.6%
fabs-sqr35.6%
sqr-pow88.4%
unpow188.4%
*-commutative88.4%
Simplified88.4%
fma-udef88.4%
distribute-rgt-in88.4%
Applied egg-rr88.4%
Final simplification88.4%
(FPCore (x) :precision binary64 (if (<= x -1.72) (fabs (* (sqrt (/ 1.0 PI)) (* x (* 0.6666666666666666 (* x x))))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -1.72) {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * (x * (0.6666666666666666 * (x * x)))));
} else {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.72) {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * (x * (0.6666666666666666 * (x * x)))));
} else {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.72: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * (x * (0.6666666666666666 * (x * x))))) else: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) return tmp
function code(x) tmp = 0.0 if (x <= -1.72) tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(x * Float64(0.6666666666666666 * 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 <= -1.72) tmp = abs((sqrt((1.0 / pi)) * (x * (0.6666666666666666 * (x * x))))); else tmp = abs((x * (2.0 / sqrt(pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.72], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(x * N[(0.6666666666666666 * 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.72:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < -1.71999999999999997Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 68.4%
+-commutative68.4%
associate-*r*68.4%
associate-*r*68.4%
distribute-rgt-out68.4%
*-commutative68.4%
unpow168.4%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow68.4%
unpow168.4%
*-commutative68.4%
cube-mult68.4%
associate-*l*68.4%
unpow168.4%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow68.4%
unpow168.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in x around inf 68.4%
unpow268.4%
Simplified68.4%
if -1.71999999999999997 < x Initial program 99.9%
Simplified99.2%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
associate-*l*98.5%
Simplified98.5%
expm1-log1p-u98.5%
expm1-udef7.4%
associate-*r*7.4%
sqrt-div7.4%
metadata-eval7.4%
div-inv7.4%
clear-num7.4%
associate-*l/7.4%
metadata-eval7.4%
Applied egg-rr7.4%
expm1-def97.8%
expm1-log1p97.8%
associate-/r/98.5%
Simplified98.5%
Final simplification88.0%
(FPCore (x) :precision binary64 (fabs (* (sqrt (/ 1.0 PI)) (* x (+ (* 0.6666666666666666 (* x x)) 2.0)))))
double code(double x) {
return fabs((sqrt((1.0 / ((double) M_PI))) * (x * ((0.6666666666666666 * (x * x)) + 2.0))));
}
public static double code(double x) {
return Math.abs((Math.sqrt((1.0 / Math.PI)) * (x * ((0.6666666666666666 * (x * x)) + 2.0))));
}
def code(x): return math.fabs((math.sqrt((1.0 / math.pi)) * (x * ((0.6666666666666666 * (x * x)) + 2.0))))
function code(x) return abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(x * Float64(Float64(0.6666666666666666 * Float64(x * x)) + 2.0)))) end
function tmp = code(x) tmp = abs((sqrt((1.0 / pi)) * (x * ((0.6666666666666666 * (x * x)) + 2.0)))); end
code[x_] := N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(x * N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sqrt{\frac{1}{\pi}} \cdot \left(x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right) + 2\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 88.4%
+-commutative88.4%
associate-*r*88.4%
associate-*r*88.4%
distribute-rgt-out88.4%
*-commutative88.4%
unpow188.4%
sqr-pow35.4%
fabs-sqr35.4%
sqr-pow88.1%
unpow188.1%
*-commutative88.1%
cube-mult88.1%
associate-*l*88.1%
unpow188.1%
sqr-pow35.6%
fabs-sqr35.6%
sqr-pow88.4%
unpow188.4%
*-commutative88.4%
Simplified88.4%
fma-udef99.9%
Applied egg-rr88.4%
Final simplification88.4%
(FPCore (x) :precision binary64 (if (<= x -5e-36) (fabs (sqrt (* 4.0 (/ (* x x) PI)))) (fabs (* x (/ 2.0 (sqrt PI))))))
double code(double x) {
double tmp;
if (x <= -5e-36) {
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 <= -5e-36) {
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 <= -5e-36: 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 <= -5e-36) 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 <= -5e-36) 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, -5e-36], 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 -5 \cdot 10^{-36}:\\
\;\;\;\;\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 < -5.00000000000000004e-36Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 16.3%
*-commutative16.3%
associate-*l*16.3%
Simplified16.3%
add-sqr-sqrt0.0%
sqrt-unprod53.8%
associate-*r*53.8%
sqrt-div53.8%
metadata-eval53.8%
div-inv53.9%
associate-*r*53.9%
sqrt-div53.9%
metadata-eval53.9%
div-inv53.9%
swap-sqr53.9%
frac-times53.9%
add-sqr-sqrt53.9%
metadata-eval53.9%
Applied egg-rr53.9%
if -5.00000000000000004e-36 < x Initial program 99.9%
Simplified99.2%
Taylor expanded in x around 0 99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
expm1-log1p-u99.1%
expm1-udef6.4%
associate-*r*6.4%
sqrt-div6.4%
metadata-eval6.4%
div-inv6.4%
clear-num6.4%
associate-*l/6.4%
metadata-eval6.4%
Applied egg-rr6.4%
expm1-def98.4%
expm1-log1p98.4%
associate-/r/99.1%
Simplified99.1%
Final simplification81.1%
(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.9%
Simplified99.4%
Taylor expanded in x around 0 66.1%
*-commutative66.1%
associate-*l*66.1%
Simplified66.1%
expm1-log1p-u64.2%
expm1-udef4.8%
associate-*r*4.8%
sqrt-div4.8%
metadata-eval4.8%
div-inv4.8%
clear-num4.8%
associate-*l/4.8%
metadata-eval4.8%
Applied egg-rr4.8%
expm1-def63.8%
expm1-log1p65.7%
associate-/r/66.1%
Simplified66.1%
Final simplification66.1%
herbie shell --seed 2023181
(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)))))))