
(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 8 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}
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(fma 2.0 (fabs x) (* 0.6666666666666666 (pow x 3.0)))
(* 0.2 (pow x 5.0)))
(* 0.047619047619047616 (* (fabs x) (* (* x x) (* (* x x) (* x x)))))))))x = abs(x);
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * ((fma(2.0, fabs(x), (0.6666666666666666 * pow(x, 3.0))) + (0.2 * pow(x, 5.0))) + (0.047619047619047616 * (fabs(x) * ((x * x) * ((x * x) * (x * x))))))));
}
x = abs(x) function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(fma(2.0, abs(x), Float64(0.6666666666666666 * (x ^ 3.0))) + Float64(0.2 * (x ^ 5.0))) + Float64(0.047619047619047616 * Float64(abs(x) * Float64(Float64(x * x) * Float64(Float64(x * x) * Float64(x * x)))))))) end
NOTE: x should be positive before calling this function code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision] + N[(0.6666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.2 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.047619047619047616 * N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\mathsf{fma}\left(2, \left|x\right|, 0.6666666666666666 \cdot {x}^{3}\right) + 0.2 \cdot {x}^{5}\right) + 0.047619047619047616 \cdot \left(\left|x\right| \cdot \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right|
\end{array}
Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
unpow299.9%
associate-*r*99.9%
rem-square-sqrt38.2%
fabs-sqr38.2%
rem-square-sqrt76.0%
associate-*r*76.0%
cube-mult76.0%
Simplified76.0%
Taylor expanded in x around 0 76.0%
*-commutative76.0%
unpow176.0%
sqr-pow38.2%
fabs-sqr38.2%
sqr-pow72.5%
unpow172.5%
pow-plus72.5%
metadata-eval72.5%
Simplified72.5%
Final simplification72.5%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(fabs
(*
(* x (pow PI -0.5))
(+
(fma 0.6666666666666666 (* x x) 2.0)
(+ (* 0.2 (pow x 4.0)) (* 0.047619047619047616 (pow x 6.0)))))))x = abs(x);
double code(double x) {
return fabs(((x * pow(((double) M_PI), -0.5)) * (fma(0.6666666666666666, (x * x), 2.0) + ((0.2 * pow(x, 4.0)) + (0.047619047619047616 * pow(x, 6.0))))));
}
x = abs(x) function code(x) return abs(Float64(Float64(x * (pi ^ -0.5)) * Float64(fma(0.6666666666666666, Float64(x * x), 2.0) + Float64(Float64(0.2 * (x ^ 4.0)) + Float64(0.047619047619047616 * (x ^ 6.0)))))) end
NOTE: x should be positive before calling this function 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[(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}
x = |x|\\
\\
\left|\left(x \cdot {\pi}^{-0.5}\right) \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%
Simplified99.4%
div-inv99.9%
add-sqr-sqrt38.0%
fabs-sqr38.0%
add-sqr-sqrt99.9%
pow1/299.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(fabs
(*
(* x (pow PI -0.5))
(+
(fma 0.6666666666666666 (* x x) 2.0)
(* 0.047619047619047616 (pow x 6.0))))))x = abs(x);
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)))));
}
x = abs(x) 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
NOTE: x should be positive before calling this function 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}
x = |x|\\
\\
\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%
Simplified99.4%
div-inv99.9%
add-sqr-sqrt38.0%
fabs-sqr38.0%
add-sqr-sqrt99.9%
pow1/299.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 98.5%
Final simplification98.5%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (fabs (/ (fma 2.0 x (* 0.047619047619047616 (pow x 7.0))) (sqrt PI))))
x = abs(x);
double code(double x) {
return fabs((fma(2.0, x, (0.047619047619047616 * pow(x, 7.0))) / sqrt(((double) M_PI))));
}
x = abs(x) function code(x) return abs(Float64(fma(2.0, x, Float64(0.047619047619047616 * (x ^ 7.0))) / sqrt(pi))) end
NOTE: x should be positive before calling this function 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}
x = |x|\\
\\
\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 97.4%
Final simplification97.4%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.2) (fabs (* (pow PI -0.5) (+ (* 0.6666666666666666 (pow x 3.0)) (* 2.0 x)))) (fabs (* 0.047619047619047616 (/ (pow x 7.0) (sqrt PI))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = fabs((pow(((double) M_PI), -0.5) * ((0.6666666666666666 * pow(x, 3.0)) + (2.0 * x))));
} else {
tmp = fabs((0.047619047619047616 * (pow(x, 7.0) / sqrt(((double) M_PI)))));
}
return tmp;
}
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = Math.abs((Math.pow(Math.PI, -0.5) * ((0.6666666666666666 * Math.pow(x, 3.0)) + (2.0 * x))));
} else {
tmp = Math.abs((0.047619047619047616 * (Math.pow(x, 7.0) / Math.sqrt(Math.PI))));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.2: tmp = math.fabs((math.pow(math.pi, -0.5) * ((0.6666666666666666 * math.pow(x, 3.0)) + (2.0 * x)))) else: tmp = math.fabs((0.047619047619047616 * (math.pow(x, 7.0) / math.sqrt(math.pi)))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.2) tmp = abs(Float64((pi ^ -0.5) * Float64(Float64(0.6666666666666666 * (x ^ 3.0)) + Float64(2.0 * x)))); else tmp = abs(Float64(0.047619047619047616 * Float64((x ^ 7.0) / sqrt(pi)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.2) tmp = abs(((pi ^ -0.5) * ((0.6666666666666666 * (x ^ 3.0)) + (2.0 * x)))); else tmp = abs((0.047619047619047616 * ((x ^ 7.0) / sqrt(pi)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.2], N[Abs[N[(N[Power[Pi, -0.5], $MachinePrecision] * N[(N[(0.6666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(0.047619047619047616 * N[(N[Power[x, 7.0], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;\left|{\pi}^{-0.5} \cdot \left(0.6666666666666666 \cdot {x}^{3} + 2 \cdot x\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 91.5%
+-commutative91.5%
associate-*r*91.5%
associate-*r*91.5%
distribute-rgt-out91.5%
*-commutative91.5%
Simplified91.5%
distribute-lft-in91.5%
pow1/291.5%
inv-pow91.5%
pow-pow91.5%
metadata-eval91.5%
pow1/291.5%
inv-pow91.5%
pow-pow91.5%
metadata-eval91.5%
Applied egg-rr91.5%
distribute-lft-out91.5%
Simplified91.5%
if 2.2000000000000002 < x Initial program 99.9%
Simplified99.4%
Taylor expanded in x around inf 34.5%
associate-*r*34.5%
Simplified34.5%
expm1-log1p-u4.0%
expm1-udef3.8%
associate-*l*3.8%
sqrt-div3.8%
metadata-eval3.8%
un-div-inv3.8%
Applied egg-rr3.8%
expm1-def4.0%
expm1-log1p34.5%
Simplified34.5%
Final simplification91.5%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 1.85) (fabs (* x (/ 2.0 (sqrt PI)))) (fabs (* 0.047619047619047616 (/ (pow x 7.0) (sqrt PI))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.85) {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs((0.047619047619047616 * (pow(x, 7.0) / sqrt(((double) M_PI)))));
}
return tmp;
}
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.85) {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs((0.047619047619047616 * (Math.pow(x, 7.0) / Math.sqrt(Math.PI))));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.85: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) else: tmp = math.fabs((0.047619047619047616 * (math.pow(x, 7.0) / math.sqrt(math.pi)))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.85) tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); else tmp = abs(Float64(0.047619047619047616 * Float64((x ^ 7.0) / sqrt(pi)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.85) tmp = abs((x * (2.0 / sqrt(pi)))); else tmp = abs((0.047619047619047616 * ((x ^ 7.0) / sqrt(pi)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.85], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(0.047619047619047616 * N[(N[Power[x, 7.0], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.85:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|0.047619047619047616 \cdot \frac{{x}^{7}}{\sqrt{\pi}}\right|\\
\end{array}
\end{array}
if x < 1.8500000000000001Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 69.1%
associate-*r*69.1%
Simplified69.1%
expm1-log1p-u67.4%
expm1-udef5.4%
*-commutative5.4%
*-commutative5.4%
pow1/25.4%
inv-pow5.4%
pow-pow5.4%
metadata-eval5.4%
Applied egg-rr5.4%
expm1-def67.4%
expm1-log1p69.1%
Simplified69.1%
expm1-log1p-u67.4%
expm1-udef5.4%
associate-*r*5.4%
metadata-eval5.4%
pow-flip5.4%
pow1/25.4%
associate-/r/5.4%
clear-num5.4%
*-commutative5.4%
Applied egg-rr5.4%
expm1-def66.9%
expm1-log1p68.6%
associate-*r/68.6%
associate-/l*68.7%
Simplified68.7%
associate-/r/69.1%
Applied egg-rr69.1%
if 1.8500000000000001 < x Initial program 99.9%
Simplified99.4%
Taylor expanded in x around inf 34.5%
associate-*r*34.5%
Simplified34.5%
expm1-log1p-u4.0%
expm1-udef3.8%
associate-*l*3.8%
sqrt-div3.8%
metadata-eval3.8%
un-div-inv3.8%
Applied egg-rr3.8%
expm1-def4.0%
expm1-log1p34.5%
Simplified34.5%
Final simplification69.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.05) (fabs (* x (/ 2.0 (sqrt PI)))) (fabs (sqrt (* 4.0 (/ (* x x) PI))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.05) {
tmp = fabs((x * (2.0 / sqrt(((double) M_PI)))));
} else {
tmp = fabs(sqrt((4.0 * ((x * x) / ((double) M_PI)))));
}
return tmp;
}
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 0.05) {
tmp = Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
} else {
tmp = Math.abs(Math.sqrt((4.0 * ((x * x) / Math.PI))));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 0.05: tmp = math.fabs((x * (2.0 / math.sqrt(math.pi)))) else: tmp = math.fabs(math.sqrt((4.0 * ((x * x) / math.pi)))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 0.05) tmp = abs(Float64(x * Float64(2.0 / sqrt(pi)))); else tmp = abs(sqrt(Float64(4.0 * Float64(Float64(x * x) / pi)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 0.05) tmp = abs((x * (2.0 / sqrt(pi)))); else tmp = abs(sqrt((4.0 * ((x * x) / pi)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 0.05], N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[Sqrt[N[(4.0 * N[(N[(x * x), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.05:\\
\;\;\;\;\left|x \cdot \frac{2}{\sqrt{\pi}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt{4 \cdot \frac{x \cdot x}{\pi}}\right|\\
\end{array}
\end{array}
if x < 0.050000000000000003Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 69.3%
associate-*r*69.3%
Simplified69.3%
expm1-log1p-u67.5%
expm1-udef5.3%
*-commutative5.3%
*-commutative5.3%
pow1/25.3%
inv-pow5.3%
pow-pow5.3%
metadata-eval5.3%
Applied egg-rr5.3%
expm1-def67.5%
expm1-log1p69.3%
Simplified69.3%
expm1-log1p-u67.5%
expm1-udef5.3%
associate-*r*5.3%
metadata-eval5.3%
pow-flip5.3%
pow1/25.3%
associate-/r/5.3%
clear-num5.3%
*-commutative5.3%
Applied egg-rr5.3%
expm1-def67.1%
expm1-log1p68.8%
associate-*r/68.8%
associate-/l*68.8%
Simplified68.8%
associate-/r/69.3%
Applied egg-rr69.3%
if 0.050000000000000003 < x Initial program 98.4%
Simplified97.5%
Taylor expanded in x around 0 26.6%
associate-*r*26.6%
Simplified26.6%
expm1-log1p-u26.6%
expm1-udef26.6%
*-commutative26.6%
*-commutative26.6%
pow1/226.6%
inv-pow26.6%
pow-pow26.6%
metadata-eval26.6%
Applied egg-rr26.6%
expm1-def26.6%
expm1-log1p26.6%
Simplified26.6%
add-sqr-sqrt26.6%
pow1/226.6%
pow1/226.6%
pow-prod-down26.6%
Applied egg-rr26.6%
unpow1/226.6%
Simplified26.6%
Final simplification69.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (fabs (* x (/ 2.0 (sqrt PI)))))
x = abs(x);
double code(double x) {
return fabs((x * (2.0 / sqrt(((double) M_PI)))));
}
x = Math.abs(x);
public static double code(double x) {
return Math.abs((x * (2.0 / Math.sqrt(Math.PI))));
}
x = abs(x) def code(x): return math.fabs((x * (2.0 / math.sqrt(math.pi))))
x = abs(x) function code(x) return abs(Float64(x * Float64(2.0 / sqrt(pi)))) end
x = abs(x) function tmp = code(x) tmp = abs((x * (2.0 / sqrt(pi)))); end
NOTE: x should be positive before calling this function code[x_] := N[Abs[N[(x * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\left|x \cdot \frac{2}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.9%
Simplified99.4%
Taylor expanded in x around 0 69.1%
associate-*r*69.1%
Simplified69.1%
expm1-log1p-u67.4%
expm1-udef5.4%
*-commutative5.4%
*-commutative5.4%
pow1/25.4%
inv-pow5.4%
pow-pow5.4%
metadata-eval5.4%
Applied egg-rr5.4%
expm1-def67.4%
expm1-log1p69.1%
Simplified69.1%
expm1-log1p-u67.4%
expm1-udef5.4%
associate-*r*5.4%
metadata-eval5.4%
pow-flip5.4%
pow1/25.4%
associate-/r/5.4%
clear-num5.4%
*-commutative5.4%
Applied egg-rr5.4%
expm1-def66.9%
expm1-log1p68.6%
associate-*r/68.6%
associate-/l*68.7%
Simplified68.7%
associate-/r/69.1%
Applied egg-rr69.1%
Final simplification69.1%
herbie shell --seed 2023213
(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)))))))