
(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
(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 (pow PI -0.5))
(+
(fma 0.6666666666666666 (* x x) 2.0)
(* 0.047619047619047616 (pow x 6.0))))))
double code(double x) {
return fabs(((x * pow(((double) M_PI), -0.5)) * (fma(0.6666666666666666, (x * x), 2.0) + (0.047619047619047616 * pow(x, 6.0)))));
}
function code(x) return abs(Float64(Float64(x * (pi ^ -0.5)) * Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(0.047619047619047616 * (x ^ 6.0))))) end
code[x_] := N[Abs[N[(N[(x * N[Power[Pi, -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(x \cdot {\pi}^{-0.5}\right) \cdot \left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + 0.047619047619047616 \cdot {x}^{6}\right)\right|
\end{array}
Initial program 99.9%
associate-*l/99.4%
Simplified99.4%
Taylor expanded in x around inf 99.3%
div-inv99.8%
add-sqr-sqrt37.6%
fabs-sqr37.6%
add-sqr-sqrt99.8%
pow1/299.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(fma 0.6666666666666666 (* x x) 2.0)
(* 0.047619047619047616 (pow x 6.0)))
(/ x (sqrt PI)))))
double code(double x) {
return fabs(((fma(0.6666666666666666, (x * x), 2.0) + (0.047619047619047616 * pow(x, 6.0))) * (x / sqrt(((double) M_PI)))));
}
function code(x) return abs(Float64(Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(0.047619047619047616 * (x ^ 6.0))) * Float64(x / sqrt(pi)))) end
code[x_] := N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) + 0.047619047619047616 \cdot {x}^{6}\right) \cdot \frac{x}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
associate-*l/99.4%
Simplified99.4%
Taylor expanded in x around inf 99.3%
expm1-log1p-u99.1%
expm1-udef38.1%
add-sqr-sqrt2.8%
fabs-sqr2.8%
add-sqr-sqrt5.6%
Applied egg-rr5.6%
expm1-def66.5%
expm1-log1p99.1%
Simplified99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (fabs (* (/ x (sqrt PI)) (+ 2.0 (* 0.047619047619047616 (pow x 6.0))))))
double code(double x) {
return fabs(((x / sqrt(((double) M_PI))) * (2.0 + (0.047619047619047616 * pow(x, 6.0)))));
}
public static double code(double x) {
return Math.abs(((x / Math.sqrt(Math.PI)) * (2.0 + (0.047619047619047616 * Math.pow(x, 6.0)))));
}
def code(x): return math.fabs(((x / math.sqrt(math.pi)) * (2.0 + (0.047619047619047616 * math.pow(x, 6.0)))))
function code(x) return abs(Float64(Float64(x / sqrt(pi)) * Float64(2.0 + Float64(0.047619047619047616 * (x ^ 6.0))))) end
function tmp = code(x) tmp = abs(((x / sqrt(pi)) * (2.0 + (0.047619047619047616 * (x ^ 6.0))))); end
code[x_] := N[Abs[N[(N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(0.047619047619047616 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x}{\sqrt{\pi}} \cdot \left(2 + 0.047619047619047616 \cdot {x}^{6}\right)\right|
\end{array}
Initial program 99.9%
associate-*l/99.4%
Simplified99.4%
Taylor expanded in x around inf 99.3%
Taylor expanded in x around 0 99.1%
expm1-log1p-u99.1%
expm1-udef38.1%
add-sqr-sqrt2.8%
fabs-sqr2.8%
add-sqr-sqrt5.6%
Applied egg-rr5.6%
expm1-def66.5%
expm1-log1p99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x -1.85) (fabs (* 0.047619047619047616 (* (pow PI -0.5) (pow x 7.0)))) (fabs (* (pow PI -0.5) (+ x x)))))
double code(double x) {
double tmp;
if (x <= -1.85) {
tmp = fabs((0.047619047619047616 * (pow(((double) M_PI), -0.5) * pow(x, 7.0))));
} else {
tmp = fabs((pow(((double) M_PI), -0.5) * (x + x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.85) {
tmp = Math.abs((0.047619047619047616 * (Math.pow(Math.PI, -0.5) * Math.pow(x, 7.0))));
} else {
tmp = Math.abs((Math.pow(Math.PI, -0.5) * (x + x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.85: tmp = math.fabs((0.047619047619047616 * (math.pow(math.pi, -0.5) * math.pow(x, 7.0)))) else: tmp = math.fabs((math.pow(math.pi, -0.5) * (x + x))) return tmp
function code(x) tmp = 0.0 if (x <= -1.85) tmp = abs(Float64(0.047619047619047616 * Float64((pi ^ -0.5) * (x ^ 7.0)))); else tmp = abs(Float64((pi ^ -0.5) * Float64(x + x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.85) tmp = abs((0.047619047619047616 * ((pi ^ -0.5) * (x ^ 7.0)))); else tmp = abs(((pi ^ -0.5) * (x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.85], N[Abs[N[(0.047619047619047616 * N[(N[Power[Pi, -0.5], $MachinePrecision] * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85:\\
\;\;\;\;\left|0.047619047619047616 \cdot \left({\pi}^{-0.5} \cdot {x}^{7}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|{\pi}^{-0.5} \cdot \left(x + x\right)\right|\\
\end{array}
\end{array}
if x < -1.8500000000000001Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
associate-*l*99.9%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt99.9%
*-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
*-commutative99.9%
fma-def99.9%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around inf 99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
expm1-log1p-u0.0%
expm1-udef0.0%
pow1/20.0%
inv-pow0.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
if -1.8500000000000001 < x Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.2%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
associate-*l*99.6%
rem-square-sqrt56.0%
fabs-sqr56.0%
rem-square-sqrt99.6%
*-commutative99.6%
+-commutative99.6%
associate-+l+99.6%
*-commutative99.6%
fma-def99.6%
rem-square-sqrt56.3%
fabs-sqr56.3%
rem-square-sqrt99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
expm1-udef8.4%
pow1/28.4%
inv-pow8.4%
pow-pow8.4%
metadata-eval8.4%
*-commutative8.4%
Applied egg-rr8.4%
expm1-def99.6%
expm1-log1p99.6%
*-commutative99.6%
rem-log-exp8.4%
log-pow8.3%
exp-prod8.4%
exp-lft-sqr8.3%
log-prod8.4%
rem-log-exp20.8%
rem-log-exp99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (<= x -1.72) (fabs (* 0.6666666666666666 (sqrt (/ (pow x 6.0) PI)))) (fabs (* (pow PI -0.5) (+ x x)))))
double code(double x) {
double tmp;
if (x <= -1.72) {
tmp = fabs((0.6666666666666666 * sqrt((pow(x, 6.0) / ((double) M_PI)))));
} else {
tmp = fabs((pow(((double) M_PI), -0.5) * (x + x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.72) {
tmp = Math.abs((0.6666666666666666 * Math.sqrt((Math.pow(x, 6.0) / Math.PI))));
} else {
tmp = Math.abs((Math.pow(Math.PI, -0.5) * (x + x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.72: tmp = math.fabs((0.6666666666666666 * math.sqrt((math.pow(x, 6.0) / math.pi)))) else: tmp = math.fabs((math.pow(math.pi, -0.5) * (x + x))) return tmp
function code(x) tmp = 0.0 if (x <= -1.72) tmp = abs(Float64(0.6666666666666666 * sqrt(Float64((x ^ 6.0) / pi)))); else tmp = abs(Float64((pi ^ -0.5) * Float64(x + x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.72) tmp = abs((0.6666666666666666 * sqrt(((x ^ 6.0) / pi)))); else tmp = abs(((pi ^ -0.5) * (x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.72], N[Abs[N[(0.6666666666666666 * N[Sqrt[N[(N[Power[x, 6.0], $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72:\\
\;\;\;\;\left|0.6666666666666666 \cdot \sqrt{\frac{{x}^{6}}{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|{\pi}^{-0.5} \cdot \left(x + x\right)\right|\\
\end{array}
\end{array}
if x < -1.71999999999999997Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified100.0%
Taylor expanded in x around inf 75.5%
unpow275.5%
Simplified75.5%
add-sqr-sqrt75.5%
sqrt-unprod92.1%
*-commutative92.1%
*-commutative92.1%
swap-sqr92.1%
add-sqr-sqrt92.1%
pow292.1%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt92.1%
cube-mult92.1%
pow292.1%
pow-sqr92.1%
metadata-eval92.1%
Applied egg-rr92.1%
associate-*l/92.1%
*-lft-identity92.1%
Simplified92.1%
if -1.71999999999999997 < x Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.2%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
associate-*l*99.6%
rem-square-sqrt56.0%
fabs-sqr56.0%
rem-square-sqrt99.6%
*-commutative99.6%
+-commutative99.6%
associate-+l+99.6%
*-commutative99.6%
fma-def99.6%
rem-square-sqrt56.3%
fabs-sqr56.3%
rem-square-sqrt99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
expm1-udef8.4%
pow1/28.4%
inv-pow8.4%
pow-pow8.4%
metadata-eval8.4%
*-commutative8.4%
Applied egg-rr8.4%
expm1-def99.6%
expm1-log1p99.6%
*-commutative99.6%
rem-log-exp8.4%
log-pow8.3%
exp-prod8.4%
exp-lft-sqr8.3%
log-prod8.4%
rem-log-exp20.8%
rem-log-exp99.6%
Simplified99.6%
Final simplification97.1%
(FPCore (x) :precision binary64 (if (<= x -9.2e+23) (fabs (/ 1.0 (* (sqrt PI) 0.0))) (fabs (* (pow PI -0.5) (+ x x)))))
double code(double x) {
double tmp;
if (x <= -9.2e+23) {
tmp = fabs((1.0 / (sqrt(((double) M_PI)) * 0.0)));
} else {
tmp = fabs((pow(((double) M_PI), -0.5) * (x + x)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -9.2e+23) {
tmp = Math.abs((1.0 / (Math.sqrt(Math.PI) * 0.0)));
} else {
tmp = Math.abs((Math.pow(Math.PI, -0.5) * (x + x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -9.2e+23: tmp = math.fabs((1.0 / (math.sqrt(math.pi) * 0.0))) else: tmp = math.fabs((math.pow(math.pi, -0.5) * (x + x))) return tmp
function code(x) tmp = 0.0 if (x <= -9.2e+23) tmp = abs(Float64(1.0 / Float64(sqrt(pi) * 0.0))); else tmp = abs(Float64((pi ^ -0.5) * Float64(x + x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -9.2e+23) tmp = abs((1.0 / (sqrt(pi) * 0.0))); else tmp = abs(((pi ^ -0.5) * (x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -9.2e+23], N[Abs[N[(1.0 / N[(N[Sqrt[Pi], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+23}:\\
\;\;\;\;\left|\frac{1}{\sqrt{\pi} \cdot 0}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|{\pi}^{-0.5} \cdot \left(x + x\right)\right|\\
\end{array}
\end{array}
if x < -9.2000000000000002e23Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified100.0%
Taylor expanded in x around inf 76.3%
associate-*r*76.3%
*-commutative76.3%
unpow276.3%
*-commutative76.3%
associate-*r*76.3%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt76.3%
associate-*r*76.3%
unpow376.3%
Simplified76.3%
*-commutative76.3%
cube-mult76.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt76.3%
associate-*l*76.3%
*-commutative76.3%
*-commutative76.3%
expm1-log1p-u76.3%
expm1-udef76.3%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p76.3%
associate-*r/76.3%
Simplified76.3%
expm1-log1p-u0.0%
expm1-udef0.0%
associate-/l*0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p76.3%
associate-/r/76.3%
*-commutative76.3%
Simplified76.3%
expm1-log1p-u0.0%
expm1-udef0.0%
clear-num0.0%
un-div-inv0.0%
div-inv0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Simplified95.5%
if -9.2000000000000002e23 < x Initial program 99.8%
associate-+l+99.8%
+-commutative99.8%
Simplified99.2%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
associate-*l*99.6%
rem-square-sqrt55.7%
fabs-sqr55.7%
rem-square-sqrt99.6%
*-commutative99.6%
+-commutative99.6%
associate-+l+99.6%
*-commutative99.6%
fma-def99.6%
rem-square-sqrt56.0%
fabs-sqr56.0%
rem-square-sqrt99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around 0 99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef8.3%
pow1/28.3%
inv-pow8.3%
pow-pow8.3%
metadata-eval8.3%
*-commutative8.3%
Applied egg-rr8.3%
expm1-def99.0%
expm1-log1p99.0%
*-commutative99.0%
rem-log-exp8.3%
log-pow8.3%
exp-prod8.4%
exp-lft-sqr8.3%
log-prod8.3%
rem-log-exp20.7%
rem-log-exp99.0%
Simplified99.0%
Final simplification97.9%
(FPCore (x) :precision binary64 (fabs (* (pow PI -0.5) (+ x x))))
double code(double x) {
return fabs((pow(((double) M_PI), -0.5) * (x + x)));
}
public static double code(double x) {
return Math.abs((Math.pow(Math.PI, -0.5) * (x + x)));
}
def code(x): return math.fabs((math.pow(math.pi, -0.5) * (x + x)))
function code(x) return abs(Float64((pi ^ -0.5) * Float64(x + x))) end
function tmp = code(x) tmp = abs(((pi ^ -0.5) * (x + x))); end
code[x_] := N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|{\pi}^{-0.5} \cdot \left(x + x\right)\right|
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.5%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
associate-*l*99.7%
rem-square-sqrt37.6%
fabs-sqr37.6%
rem-square-sqrt99.7%
*-commutative99.7%
+-commutative99.7%
associate-+l+99.7%
*-commutative99.7%
fma-def99.7%
rem-square-sqrt37.8%
fabs-sqr37.8%
rem-square-sqrt99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around 0 68.8%
associate-*r*68.8%
*-commutative68.8%
Simplified68.8%
expm1-log1p-u66.9%
expm1-udef5.6%
pow1/25.6%
inv-pow5.6%
pow-pow5.6%
metadata-eval5.6%
*-commutative5.6%
Applied egg-rr5.6%
expm1-def66.9%
expm1-log1p68.8%
*-commutative68.8%
rem-log-exp36.6%
log-pow36.6%
exp-prod36.6%
exp-lft-sqr36.6%
log-prod36.6%
rem-log-exp45.0%
rem-log-exp68.8%
Simplified68.8%
Final simplification68.8%
(FPCore (x) :precision binary64 (fabs (/ 2.0 (/ (sqrt PI) x))))
double code(double x) {
return fabs((2.0 / (sqrt(((double) M_PI)) / x)));
}
public static double code(double x) {
return Math.abs((2.0 / (Math.sqrt(Math.PI) / x)));
}
def code(x): return math.fabs((2.0 / (math.sqrt(math.pi) / x)))
function code(x) return abs(Float64(2.0 / Float64(sqrt(pi) / x))) end
function tmp = code(x) tmp = abs((2.0 / (sqrt(pi) / x))); end
code[x_] := N[Abs[N[(2.0 / N[(N[Sqrt[Pi], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{2}{\frac{\sqrt{\pi}}{x}}\right|
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.5%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
associate-*l*99.7%
rem-square-sqrt37.6%
fabs-sqr37.6%
rem-square-sqrt99.7%
*-commutative99.7%
+-commutative99.7%
associate-+l+99.7%
*-commutative99.7%
fma-def99.7%
rem-square-sqrt37.8%
fabs-sqr37.8%
rem-square-sqrt99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around 0 68.8%
associate-*r*68.8%
*-commutative68.8%
Simplified68.8%
expm1-log1p-u66.9%
expm1-udef5.6%
pow1/25.6%
inv-pow5.6%
pow-pow5.6%
metadata-eval5.6%
*-commutative5.6%
Applied egg-rr5.6%
expm1-def66.9%
expm1-log1p68.8%
*-commutative68.8%
rem-log-exp36.6%
log-pow36.6%
exp-prod36.6%
exp-lft-sqr36.6%
log-prod36.6%
rem-log-exp45.0%
rem-log-exp68.8%
Simplified68.8%
*-commutative68.8%
count-268.8%
associate-*r*68.8%
metadata-eval68.8%
pow-flip68.8%
pow1/268.8%
div-inv68.4%
add-sqr-sqrt37.4%
fabs-sqr37.4%
add-sqr-sqrt68.4%
clear-num68.3%
un-div-inv68.3%
add-sqr-sqrt37.5%
fabs-sqr37.5%
add-sqr-sqrt68.3%
Applied egg-rr68.3%
Final simplification68.3%
(FPCore (x) :precision binary64 (fabs (/ x (sqrt PI))))
double code(double x) {
return fabs((x / sqrt(((double) M_PI))));
}
public static double code(double x) {
return Math.abs((x / Math.sqrt(Math.PI)));
}
def code(x): return math.fabs((x / math.sqrt(math.pi)))
function code(x) return abs(Float64(x / sqrt(pi))) end
function tmp = code(x) tmp = abs((x / sqrt(pi))); end
code[x_] := N[Abs[N[(x / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.5%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
associate-*l*99.7%
rem-square-sqrt37.6%
fabs-sqr37.6%
rem-square-sqrt99.7%
*-commutative99.7%
+-commutative99.7%
associate-+l+99.7%
*-commutative99.7%
fma-def99.7%
rem-square-sqrt37.8%
fabs-sqr37.8%
rem-square-sqrt99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around 0 68.8%
associate-*r*68.8%
*-commutative68.8%
Simplified68.8%
expm1-log1p-u66.9%
expm1-udef5.6%
pow1/25.6%
inv-pow5.6%
pow-pow5.6%
metadata-eval5.6%
*-commutative5.6%
Applied egg-rr5.6%
expm1-def66.9%
expm1-log1p68.8%
*-commutative68.8%
rem-log-exp36.6%
log-pow36.6%
exp-prod36.6%
exp-lft-sqr36.6%
log-prod36.6%
rem-log-exp45.0%
rem-log-exp68.8%
Simplified68.8%
distribute-rgt-in68.8%
metadata-eval68.8%
pow-flip68.8%
pow1/268.8%
div-inv68.5%
metadata-eval68.5%
pow-flip68.5%
pow1/268.5%
div-inv68.4%
Applied egg-rr68.4%
Simplified14.5%
Final simplification14.5%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
Simplified99.5%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
associate-*l*99.7%
rem-square-sqrt37.6%
fabs-sqr37.6%
rem-square-sqrt99.7%
*-commutative99.7%
+-commutative99.7%
associate-+l+99.7%
*-commutative99.7%
fma-def99.7%
rem-square-sqrt37.8%
fabs-sqr37.8%
rem-square-sqrt99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around 0 68.8%
associate-*r*68.8%
*-commutative68.8%
Simplified68.8%
expm1-log1p-u66.9%
expm1-udef5.6%
pow1/25.6%
inv-pow5.6%
pow-pow5.6%
metadata-eval5.6%
*-commutative5.6%
Applied egg-rr5.6%
expm1-def66.9%
expm1-log1p68.8%
*-commutative68.8%
rem-log-exp36.6%
log-pow36.6%
exp-prod36.6%
exp-lft-sqr36.6%
log-prod36.6%
rem-log-exp45.0%
rem-log-exp68.8%
Simplified68.8%
distribute-lft-in68.8%
Applied egg-rr68.8%
Simplified4.2%
Final simplification4.2%
herbie shell --seed 2023175
(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)))))))