
(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 10 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 (* (* x x) (* x x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(fma 2.0 (fabs x) (* 0.6666666666666666 (* (fabs x) (* x x))))
(* 0.2 (* (fabs x) t_0)))
(* 0.047619047619047616 (* (fabs x) (* (* x x) t_0))))))))
double code(double x) {
double t_0 = (x * x) * (x * x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((fma(2.0, fabs(x), (0.6666666666666666 * (fabs(x) * (x * x)))) + (0.2 * (fabs(x) * t_0))) + (0.047619047619047616 * (fabs(x) * ((x * x) * t_0))))));
}
function code(x) t_0 = Float64(Float64(x * x) * Float64(x * x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(fma(2.0, abs(x), Float64(0.6666666666666666 * Float64(abs(x) * Float64(x * x)))) + Float64(0.2 * Float64(abs(x) * t_0))) + Float64(0.047619047619047616 * Float64(abs(x) * Float64(Float64(x * x) * t_0)))))) end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision] + N[(0.6666666666666666 * N[(N[Abs[x], $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\mathsf{fma}\left(2, \left|x\right|, 0.6666666666666666 \cdot \left(\left|x\right| \cdot \left(x \cdot x\right)\right)\right) + 0.2 \cdot \left(\left|x\right| \cdot t_0\right)\right) + 0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(\left(x \cdot x\right) \cdot t_0\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
*-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ x (sqrt PI))
(+
(fma 0.6666666666666666 (* x x) 2.0)
(+ (* 0.2 (pow x 4.0)) (* 0.047619047619047616 (pow x 6.0)))))))
double code(double x) {
return fabs(((x / sqrt(((double) M_PI))) * (fma(0.6666666666666666, (x * x), 2.0) + ((0.2 * pow(x, 4.0)) + (0.047619047619047616 * pow(x, 6.0))))));
}
function code(x) return abs(Float64(Float64(x / sqrt(pi)) * Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(Float64(0.2 * (x ^ 4.0)) + Float64(0.047619047619047616 * (x ^ 6.0)))))) end
code[x_] := N[Abs[N[(N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(0.6666666666666666 * N[(x * x), $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|\frac{x}{\sqrt{\pi}} \cdot \left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + \left(0.2 \cdot {x}^{4} + 0.047619047619047616 \cdot {x}^{6}\right)\right)\right|
\end{array}
Initial program 99.9%
associate-*l/99.4%
Simplified99.4%
expm1-log1p-u99.3%
expm1-udef37.6%
add-sqr-sqrt2.5%
fabs-sqr2.5%
add-sqr-sqrt4.6%
Applied egg-rr4.6%
expm1-def66.2%
expm1-log1p99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (fabs (/ (fma 2.0 x (+ (* 0.2 (pow x 5.0)) (* 0.047619047619047616 (pow x 7.0)))) (sqrt PI))))
double code(double x) {
return fabs((fma(2.0, x, ((0.2 * pow(x, 5.0)) + (0.047619047619047616 * pow(x, 7.0)))) / sqrt(((double) M_PI))));
}
function code(x) return abs(Float64(fma(2.0, x, Float64(Float64(0.2 * (x ^ 5.0)) + Float64(0.047619047619047616 * (x ^ 7.0)))) / sqrt(pi))) end
code[x_] := N[Abs[N[(N[(2.0 * x + N[(N[(0.2 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(2, x, 0.2 \cdot {x}^{5} + 0.047619047619047616 \cdot {x}^{7}\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.4%
Taylor expanded in x around inf 99.0%
Final simplification99.0%
(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%
associate-+l+99.9%
+-commutative99.9%
Simplified99.4%
Taylor expanded in x around inf 98.9%
Final simplification98.9%
(FPCore (x)
:precision binary64
(if (<= x -2.2)
(fabs (/ (pow x 7.0) (/ (sqrt PI) 0.047619047619047616)))
(fabs
(* (sqrt (/ 1.0 PI)) (+ (* 2.0 x) (* 0.6666666666666666 (pow x 3.0)))))))
double code(double x) {
double tmp;
if (x <= -2.2) {
tmp = fabs((pow(x, 7.0) / (sqrt(((double) M_PI)) / 0.047619047619047616)));
} else {
tmp = fabs((sqrt((1.0 / ((double) M_PI))) * ((2.0 * x) + (0.6666666666666666 * pow(x, 3.0)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2.2) {
tmp = Math.abs((Math.pow(x, 7.0) / (Math.sqrt(Math.PI) / 0.047619047619047616)));
} else {
tmp = Math.abs((Math.sqrt((1.0 / Math.PI)) * ((2.0 * x) + (0.6666666666666666 * Math.pow(x, 3.0)))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.2: tmp = math.fabs((math.pow(x, 7.0) / (math.sqrt(math.pi) / 0.047619047619047616))) else: tmp = math.fabs((math.sqrt((1.0 / math.pi)) * ((2.0 * x) + (0.6666666666666666 * math.pow(x, 3.0))))) return tmp
function code(x) tmp = 0.0 if (x <= -2.2) tmp = abs(Float64((x ^ 7.0) / Float64(sqrt(pi) / 0.047619047619047616))); else tmp = abs(Float64(sqrt(Float64(1.0 / pi)) * Float64(Float64(2.0 * x) + Float64(0.6666666666666666 * (x ^ 3.0))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.2) tmp = abs(((x ^ 7.0) / (sqrt(pi) / 0.047619047619047616))); else tmp = abs((sqrt((1.0 / pi)) * ((2.0 * x) + (0.6666666666666666 * (x ^ 3.0))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.2], N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] / N[(N[Sqrt[Pi], $MachinePrecision] / 0.047619047619047616), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * x), $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{{x}^{7}}{\frac{\sqrt{\pi}}{0.047619047619047616}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{\frac{1}{\pi}} \cdot \left(2 \cdot x + 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 98.8%
expm1-log1p-u0.0%
expm1-udef0.0%
sqrt-div0.0%
metadata-eval0.0%
un-div-inv0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p98.8%
associate-*r/98.8%
*-commutative98.8%
associate-/l*98.8%
Simplified98.8%
if -2.2000000000000002 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.1%
Taylor expanded in x around 0 99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x -1.86) (fabs (sqrt (* (/ (pow x 14.0) PI) 0.0022675736961451248))) (fabs (* 2.0 (* x (pow PI -0.5))))))
double code(double x) {
double tmp;
if (x <= -1.86) {
tmp = fabs(sqrt(((pow(x, 14.0) / ((double) M_PI)) * 0.0022675736961451248)));
} else {
tmp = fabs((2.0 * (x * pow(((double) M_PI), -0.5))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.86) {
tmp = Math.abs(Math.sqrt(((Math.pow(x, 14.0) / Math.PI) * 0.0022675736961451248)));
} else {
tmp = Math.abs((2.0 * (x * Math.pow(Math.PI, -0.5))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.86: tmp = math.fabs(math.sqrt(((math.pow(x, 14.0) / math.pi) * 0.0022675736961451248))) else: tmp = math.fabs((2.0 * (x * math.pow(math.pi, -0.5)))) return tmp
function code(x) tmp = 0.0 if (x <= -1.86) tmp = abs(sqrt(Float64(Float64((x ^ 14.0) / pi) * 0.0022675736961451248))); else tmp = abs(Float64(2.0 * Float64(x * (pi ^ -0.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.86) tmp = abs(sqrt((((x ^ 14.0) / pi) * 0.0022675736961451248))); else tmp = abs((2.0 * (x * (pi ^ -0.5)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.86], N[Abs[N[Sqrt[N[(N[(N[Power[x, 14.0], $MachinePrecision] / Pi), $MachinePrecision] * 0.0022675736961451248), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.86:\\
\;\;\;\;\left|\sqrt{\frac{{x}^{14}}{\pi} \cdot 0.0022675736961451248}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \left(x \cdot {\pi}^{-0.5}\right)\right|\\
\end{array}
\end{array}
if x < -1.8600000000000001Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around inf 98.8%
add-sqr-sqrt0.0%
sqrt-unprod93.4%
*-commutative93.4%
*-commutative93.4%
swap-sqr93.4%
*-commutative93.4%
*-commutative93.4%
swap-sqr93.4%
add-sqr-sqrt93.4%
pow-prod-up93.4%
metadata-eval93.4%
metadata-eval93.4%
Applied egg-rr93.4%
associate-*l/93.4%
*-lft-identity93.4%
Simplified93.4%
if -1.8600000000000001 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.1%
Taylor expanded in x around 0 99.7%
associate-*r*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef6.9%
associate-*l*6.9%
sqrt-div6.9%
metadata-eval6.9%
div-inv6.9%
Applied egg-rr6.9%
expm1-def98.9%
expm1-log1p98.9%
Simplified98.9%
div-inv99.7%
pow1/299.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x -1.86) (fabs (/ (pow x 7.0) (/ (sqrt PI) 0.047619047619047616))) (fabs (* 2.0 (* x (pow PI -0.5))))))
double code(double x) {
double tmp;
if (x <= -1.86) {
tmp = fabs((pow(x, 7.0) / (sqrt(((double) M_PI)) / 0.047619047619047616)));
} else {
tmp = fabs((2.0 * (x * pow(((double) M_PI), -0.5))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.86) {
tmp = Math.abs((Math.pow(x, 7.0) / (Math.sqrt(Math.PI) / 0.047619047619047616)));
} else {
tmp = Math.abs((2.0 * (x * Math.pow(Math.PI, -0.5))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.86: tmp = math.fabs((math.pow(x, 7.0) / (math.sqrt(math.pi) / 0.047619047619047616))) else: tmp = math.fabs((2.0 * (x * math.pow(math.pi, -0.5)))) return tmp
function code(x) tmp = 0.0 if (x <= -1.86) tmp = abs(Float64((x ^ 7.0) / Float64(sqrt(pi) / 0.047619047619047616))); else tmp = abs(Float64(2.0 * Float64(x * (pi ^ -0.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.86) tmp = abs(((x ^ 7.0) / (sqrt(pi) / 0.047619047619047616))); else tmp = abs((2.0 * (x * (pi ^ -0.5)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.86], N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] / N[(N[Sqrt[Pi], $MachinePrecision] / 0.047619047619047616), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.86:\\
\;\;\;\;\left|\frac{{x}^{7}}{\frac{\sqrt{\pi}}{0.047619047619047616}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \left(x \cdot {\pi}^{-0.5}\right)\right|\\
\end{array}
\end{array}
if x < -1.8600000000000001Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around inf 98.8%
expm1-log1p-u0.0%
expm1-udef0.0%
sqrt-div0.0%
metadata-eval0.0%
un-div-inv0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p98.8%
associate-*r/98.8%
*-commutative98.8%
associate-/l*98.8%
Simplified98.8%
if -1.8600000000000001 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.1%
Taylor expanded in x around 0 99.7%
associate-*r*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef6.9%
associate-*l*6.9%
sqrt-div6.9%
metadata-eval6.9%
div-inv6.9%
Applied egg-rr6.9%
expm1-def98.9%
expm1-log1p98.9%
Simplified98.9%
div-inv99.7%
pow1/299.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x -2e-12) (fabs (* 2.0 (sqrt (/ (* x x) PI)))) (fabs (* 2.0 (* x (pow PI -0.5))))))
double code(double x) {
double tmp;
if (x <= -2e-12) {
tmp = fabs((2.0 * sqrt(((x * x) / ((double) M_PI)))));
} else {
tmp = fabs((2.0 * (x * pow(((double) M_PI), -0.5))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2e-12) {
tmp = Math.abs((2.0 * Math.sqrt(((x * x) / Math.PI))));
} else {
tmp = Math.abs((2.0 * (x * Math.pow(Math.PI, -0.5))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2e-12: tmp = math.fabs((2.0 * math.sqrt(((x * x) / math.pi)))) else: tmp = math.fabs((2.0 * (x * math.pow(math.pi, -0.5)))) return tmp
function code(x) tmp = 0.0 if (x <= -2e-12) tmp = abs(Float64(2.0 * sqrt(Float64(Float64(x * x) / pi)))); else tmp = abs(Float64(2.0 * Float64(x * (pi ^ -0.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2e-12) tmp = abs((2.0 * sqrt(((x * x) / pi)))); else tmp = abs((2.0 * (x * (pi ^ -0.5)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2e-12], N[Abs[N[(2.0 * N[Sqrt[N[(N[(x * x), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-12}:\\
\;\;\;\;\left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \left(x \cdot {\pi}^{-0.5}\right)\right|\\
\end{array}
\end{array}
if x < -1.99999999999999996e-12Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.9%
Taylor expanded in x around 0 7.1%
associate-*r*7.1%
Simplified7.1%
expm1-log1p-u1.1%
expm1-udef0.5%
associate-*l*0.5%
sqrt-div0.5%
metadata-eval0.5%
div-inv0.5%
Applied egg-rr0.5%
expm1-def1.2%
expm1-log1p7.1%
Simplified7.1%
add-sqr-sqrt0.0%
sqrt-unprod60.0%
frac-times60.0%
add-sqr-sqrt60.0%
Applied egg-rr60.0%
if -1.99999999999999996e-12 < x Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.1%
Taylor expanded in x around 0 99.7%
associate-*r*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef6.7%
associate-*l*6.7%
sqrt-div6.7%
metadata-eval6.7%
div-inv6.7%
Applied egg-rr6.7%
expm1-def98.9%
expm1-log1p98.9%
Simplified98.9%
div-inv99.7%
pow1/299.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification86.4%
(FPCore (x) :precision binary64 (fabs (* 2.0 (* x (pow PI -0.5)))))
double code(double x) {
return fabs((2.0 * (x * pow(((double) M_PI), -0.5))));
}
public static double code(double x) {
return Math.abs((2.0 * (x * Math.pow(Math.PI, -0.5))));
}
def code(x): return math.fabs((2.0 * (x * math.pow(math.pi, -0.5))))
function code(x) return abs(Float64(2.0 * Float64(x * (pi ^ -0.5)))) end
function tmp = code(x) tmp = abs((2.0 * (x * (pi ^ -0.5)))); end
code[x_] := N[Abs[N[(2.0 * N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|2 \cdot \left(x \cdot {\pi}^{-0.5}\right)\right|
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.4%
Taylor expanded in x around 0 68.6%
associate-*r*68.6%
Simplified68.6%
expm1-log1p-u66.6%
expm1-udef4.6%
associate-*l*4.6%
sqrt-div4.6%
metadata-eval4.6%
div-inv4.6%
Applied egg-rr4.6%
expm1-def66.1%
expm1-log1p68.1%
Simplified68.1%
div-inv68.6%
pow1/268.6%
pow-flip68.6%
metadata-eval68.6%
Applied egg-rr68.6%
Final simplification68.6%
(FPCore (x) :precision binary64 (fabs (* 2.0 (/ x (sqrt PI)))))
double code(double x) {
return fabs((2.0 * (x / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((2.0 * (x / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((2.0 * (x / math.sqrt(math.pi))))
function code(x) return abs(Float64(2.0 * Float64(x / sqrt(pi)))) end
function tmp = code(x) tmp = abs((2.0 * (x / sqrt(pi)))); end
code[x_] := N[Abs[N[(2.0 * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|2 \cdot \frac{x}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.4%
Taylor expanded in x around 0 68.6%
associate-*r*68.6%
Simplified68.6%
expm1-log1p-u66.6%
expm1-udef4.6%
associate-*l*4.6%
sqrt-div4.6%
metadata-eval4.6%
div-inv4.6%
Applied egg-rr4.6%
expm1-def66.1%
expm1-log1p68.1%
Simplified68.1%
Final simplification68.1%
herbie shell --seed 2023174
(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)))))))