
(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 7 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 (* (fabs x) (* x x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0))
(* (/ 1.0 5.0) (* (fabs x) (* (fabs x) t_0))))
(* (/ 1.0 21.0) (* (fabs x) (* (fabs x) (* (fabs x) (pow x 4.0))))))))))
double code(double x) {
double t_0 = fabs(x) * (x * x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * (fabs(x) * (fabs(x) * t_0)))) + ((1.0 / 21.0) * (fabs(x) * (fabs(x) * (fabs(x) * pow(x, 4.0))))))));
}
public static double code(double x) {
double t_0 = Math.abs(x) * (x * 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) * (Math.abs(x) * (Math.abs(x) * t_0)))) + ((1.0 / 21.0) * (Math.abs(x) * (Math.abs(x) * (Math.abs(x) * Math.pow(x, 4.0))))))));
}
def code(x): t_0 = math.fabs(x) * (x * 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) * (math.fabs(x) * (math.fabs(x) * t_0)))) + ((1.0 / 21.0) * (math.fabs(x) * (math.fabs(x) * (math.fabs(x) * math.pow(x, 4.0))))))))
function code(x) t_0 = Float64(abs(x) * Float64(x * 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) * Float64(abs(x) * Float64(abs(x) * t_0)))) + Float64(Float64(1.0 / 21.0) * Float64(abs(x) * Float64(abs(x) * Float64(abs(x) * (x ^ 4.0)))))))) end
function tmp = code(x) t_0 = abs(x) * (x * x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * (abs(x) * (abs(x) * t_0)))) + ((1.0 / 21.0) * (abs(x) * (abs(x) * (abs(x) * (x ^ 4.0)))))))); end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[(x * 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] * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|x\right| \cdot \left(x \cdot 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 \left(\left|x\right| \cdot \left(\left|x\right| \cdot t\_0\right)\right)\right) + \frac{1}{21} \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot {x}^{4}\right)\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-*l*N/A
pow2N/A
sqr-absN/A
unpow-prod-downN/A
pow-prod-upN/A
pow-lowering-pow.f64N/A
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (fabs x) (* x x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0))
(* (/ 1.0 5.0) (* (fabs x) (* (fabs x) t_0))))
(*
(/ 1.0 21.0)
(* (fabs x) (* (fabs x) (* (fabs x) (* (* x x) (* x x)))))))))))
double code(double x) {
double t_0 = fabs(x) * (x * x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * (fabs(x) * (fabs(x) * t_0)))) + ((1.0 / 21.0) * (fabs(x) * (fabs(x) * (fabs(x) * ((x * x) * (x * x)))))))));
}
public static double code(double x) {
double t_0 = Math.abs(x) * (x * 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) * (Math.abs(x) * (Math.abs(x) * t_0)))) + ((1.0 / 21.0) * (Math.abs(x) * (Math.abs(x) * (Math.abs(x) * ((x * x) * (x * x)))))))));
}
def code(x): t_0 = math.fabs(x) * (x * 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) * (math.fabs(x) * (math.fabs(x) * t_0)))) + ((1.0 / 21.0) * (math.fabs(x) * (math.fabs(x) * (math.fabs(x) * ((x * x) * (x * x)))))))))
function code(x) t_0 = Float64(abs(x) * Float64(x * 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) * Float64(abs(x) * Float64(abs(x) * t_0)))) + Float64(Float64(1.0 / 21.0) * Float64(abs(x) * Float64(abs(x) * Float64(abs(x) * Float64(Float64(x * x) * Float64(x * x))))))))) end
function tmp = code(x) t_0 = abs(x) * (x * x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * (abs(x) * (abs(x) * t_0)))) + ((1.0 / 21.0) * (abs(x) * (abs(x) * (abs(x) * ((x * x) * (x * x))))))))); end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[(x * 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] * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|x\right| \cdot \left(x \cdot 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 \left(\left|x\right| \cdot \left(\left|x\right| \cdot t\_0\right)\right)\right) + \frac{1}{21} \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot \left(\left|x\right| \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-*l*N/A
*-lowering-*.f64N/A
sqr-absN/A
*-lowering-*.f64N/A
sqr-absN/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 5e-9)
(* (fabs x) (/ 2.0 (sqrt PI)))
(/
(fabs
(/
(* (* x x) (+ 2.0 (* x (* x (+ 0.6666666666666666 (* x (* x 0.2)))))))
x))
(sqrt PI))))
double code(double x) {
double tmp;
if (fabs(x) <= 5e-9) {
tmp = fabs(x) * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = fabs((((x * x) * (2.0 + (x * (x * (0.6666666666666666 + (x * (x * 0.2))))))) / x)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 5e-9) {
tmp = Math.abs(x) * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = Math.abs((((x * x) * (2.0 + (x * (x * (0.6666666666666666 + (x * (x * 0.2))))))) / x)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 5e-9: tmp = math.fabs(x) * (2.0 / math.sqrt(math.pi)) else: tmp = math.fabs((((x * x) * (2.0 + (x * (x * (0.6666666666666666 + (x * (x * 0.2))))))) / x)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 5e-9) tmp = Float64(abs(x) * Float64(2.0 / sqrt(pi))); else tmp = Float64(abs(Float64(Float64(Float64(x * x) * Float64(2.0 + Float64(x * Float64(x * Float64(0.6666666666666666 + Float64(x * Float64(x * 0.2))))))) / x)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 5e-9) tmp = abs(x) * (2.0 / sqrt(pi)); else tmp = abs((((x * x) * (2.0 + (x * (x * (0.6666666666666666 + (x * (x * 0.2))))))) / x)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 5e-9], N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * N[(2.0 + N[(x * N[(x * N[(0.6666666666666666 + N[(x * N[(x * 0.2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\left|x\right| \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\frac{\left(x \cdot x\right) \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.2\right)\right)\right)\right)}{x}\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-9Initial program 99.9%
associate-+l+N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
associate-*r*N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified99.9%
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
fabs-mulN/A
fabs-fabsN/A
metadata-evalN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6499.2%
Applied egg-rr99.2%
div-invN/A
metadata-evalN/A
sqrt-divN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-divN/A
metadata-evalN/A
div-invN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
fabs-lowering-fabs.f6499.9%
Applied egg-rr99.9%
if 5.0000000000000001e-9 < (fabs.f64 x) Initial program 99.8%
Applied egg-rr13.0%
associate-*l/N/A
Applied egg-rr99.8%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6476.9%
Simplified76.9%
fabs-divN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
/-lowering-/.f64N/A
Applied egg-rr80.8%
Final simplification92.7%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 5e-9)
(* (fabs x) (/ 2.0 (sqrt PI)))
(*
(* x x)
(*
(/ (sqrt (/ 1.0 PI)) (fabs x))
(+ 2.0 (* (* x x) 0.6666666666666666))))))
double code(double x) {
double tmp;
if (fabs(x) <= 5e-9) {
tmp = fabs(x) * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = (x * x) * ((sqrt((1.0 / ((double) M_PI))) / fabs(x)) * (2.0 + ((x * x) * 0.6666666666666666)));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 5e-9) {
tmp = Math.abs(x) * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = (x * x) * ((Math.sqrt((1.0 / Math.PI)) / Math.abs(x)) * (2.0 + ((x * x) * 0.6666666666666666)));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 5e-9: tmp = math.fabs(x) * (2.0 / math.sqrt(math.pi)) else: tmp = (x * x) * ((math.sqrt((1.0 / math.pi)) / math.fabs(x)) * (2.0 + ((x * x) * 0.6666666666666666))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 5e-9) tmp = Float64(abs(x) * Float64(2.0 / sqrt(pi))); else tmp = Float64(Float64(x * x) * Float64(Float64(sqrt(Float64(1.0 / pi)) / abs(x)) * Float64(2.0 + Float64(Float64(x * x) * 0.6666666666666666)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 5e-9) tmp = abs(x) * (2.0 / sqrt(pi)); else tmp = (x * x) * ((sqrt((1.0 / pi)) / abs(x)) * (2.0 + ((x * x) * 0.6666666666666666))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 5e-9], N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(N[Sqrt[N[(1.0 / Pi), $MachinePrecision]], $MachinePrecision] / N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\left|x\right| \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\frac{\sqrt{\frac{1}{\pi}}}{\left|x\right|} \cdot \left(2 + \left(x \cdot x\right) \cdot 0.6666666666666666\right)\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-9Initial program 99.9%
associate-+l+N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
associate-*r*N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified99.9%
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
fabs-mulN/A
fabs-fabsN/A
metadata-evalN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6499.2%
Applied egg-rr99.2%
div-invN/A
metadata-evalN/A
sqrt-divN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-divN/A
metadata-evalN/A
div-invN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
fabs-lowering-fabs.f6499.9%
Applied egg-rr99.9%
if 5.0000000000000001e-9 < (fabs.f64 x) Initial program 99.8%
Applied egg-rr13.0%
Taylor expanded in x around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-out--N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f643.4%
Simplified3.4%
associate-*l/N/A
div-invN/A
fabs-divN/A
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
Applied egg-rr2.3%
Taylor expanded in x around 0
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*r*N/A
*-commutativeN/A
Simplified67.6%
Final simplification87.8%
(FPCore (x) :precision binary64 (if (<= (fabs x) 5e+25) (* (fabs x) (/ 2.0 (sqrt PI))) (/ (pow PI -0.5) (/ (* (fabs x) 0.5) (* x x)))))
double code(double x) {
double tmp;
if (fabs(x) <= 5e+25) {
tmp = fabs(x) * (2.0 / sqrt(((double) M_PI)));
} else {
tmp = pow(((double) M_PI), -0.5) / ((fabs(x) * 0.5) / (x * x));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 5e+25) {
tmp = Math.abs(x) * (2.0 / Math.sqrt(Math.PI));
} else {
tmp = Math.pow(Math.PI, -0.5) / ((Math.abs(x) * 0.5) / (x * x));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 5e+25: tmp = math.fabs(x) * (2.0 / math.sqrt(math.pi)) else: tmp = math.pow(math.pi, -0.5) / ((math.fabs(x) * 0.5) / (x * x)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 5e+25) tmp = Float64(abs(x) * Float64(2.0 / sqrt(pi))); else tmp = Float64((pi ^ -0.5) / Float64(Float64(abs(x) * 0.5) / Float64(x * x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 5e+25) tmp = abs(x) * (2.0 / sqrt(pi)); else tmp = (pi ^ -0.5) / ((abs(x) * 0.5) / (x * x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 5e+25], N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[Pi, -0.5], $MachinePrecision] / N[(N[(N[Abs[x], $MachinePrecision] * 0.5), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\left|x\right| \cdot \frac{2}{\sqrt{\pi}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\pi}^{-0.5}}{\frac{\left|x\right| \cdot 0.5}{x \cdot x}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.00000000000000024e25Initial program 99.8%
associate-+l+N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
associate-*r*N/A
Applied egg-rr99.8%
Taylor expanded in x around 0
Simplified93.1%
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
fabs-mulN/A
fabs-fabsN/A
metadata-evalN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6492.4%
Applied egg-rr92.4%
div-invN/A
metadata-evalN/A
sqrt-divN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-divN/A
metadata-evalN/A
div-invN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
fabs-lowering-fabs.f6493.1%
Applied egg-rr93.1%
if 5.00000000000000024e25 < (fabs.f64 x) Initial program 99.9%
Applied egg-rr0.7%
Taylor expanded in x around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-out--N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f641.0%
Simplified1.0%
associate-*l/N/A
div-invN/A
fabs-divN/A
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
Applied egg-rr0.4%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
unpow2N/A
*-lowering-*.f6460.2%
Simplified60.2%
Final simplification82.5%
(FPCore (x)
:precision binary64
(fabs
(*
x
(/
(+
2.0
(*
(* x x)
(+
0.6666666666666666
(* x (* x (+ 0.2 (* (* x x) 0.047619047619047616)))))))
(sqrt PI)))))
double code(double x) {
return fabs((x * ((2.0 + ((x * x) * (0.6666666666666666 + (x * (x * (0.2 + ((x * x) * 0.047619047619047616))))))) / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((x * ((2.0 + ((x * x) * (0.6666666666666666 + (x * (x * (0.2 + ((x * x) * 0.047619047619047616))))))) / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((x * ((2.0 + ((x * x) * (0.6666666666666666 + (x * (x * (0.2 + ((x * x) * 0.047619047619047616))))))) / math.sqrt(math.pi))))
function code(x) return abs(Float64(x * Float64(Float64(2.0 + Float64(Float64(x * x) * Float64(0.6666666666666666 + Float64(x * Float64(x * Float64(0.2 + Float64(Float64(x * x) * 0.047619047619047616))))))) / sqrt(pi)))) end
function tmp = code(x) tmp = abs((x * ((2.0 + ((x * x) * (0.6666666666666666 + (x * (x * (0.2 + ((x * x) * 0.047619047619047616))))))) / sqrt(pi)))); end
code[x_] := N[Abs[N[(x * N[(N[(2.0 + N[(N[(x * x), $MachinePrecision] * N[(0.6666666666666666 + N[(x * N[(x * N[(0.2 + N[(N[(x * x), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|x \cdot \frac{2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.2 + \left(x \cdot x\right) \cdot 0.047619047619047616\right)\right)\right)}{\sqrt{\pi}}\right|
\end{array}
Initial program 99.8%
associate-+l+N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
associate-*r*N/A
Applied egg-rr99.8%
Taylor expanded in x around 0
fabs-lowering-fabs.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
*-lowering-*.f64N/A
Simplified99.8%
*-commutativeN/A
fabs-mulN/A
fabs-fabsN/A
mul-fabsN/A
fabs-lowering-fabs.f64N/A
*-lowering-*.f64N/A
Applied egg-rr99.8%
Final simplification99.8%
(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 Float64(abs(x) * Float64(2.0 / sqrt(pi))) end
function tmp = code(x) tmp = abs(x) * (2.0 / sqrt(pi)); end
code[x_] := N[(N[Abs[x], $MachinePrecision] * N[(2.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left|x\right| \cdot \frac{2}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
associate-+l+N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
associate-*r*N/A
Applied egg-rr99.8%
Taylor expanded in x around 0
Simplified65.2%
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
fabs-mulN/A
fabs-fabsN/A
metadata-evalN/A
rem-sqrt-squareN/A
add-sqr-sqrtN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
fabs-lowering-fabs.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6464.7%
Applied egg-rr64.7%
div-invN/A
metadata-evalN/A
sqrt-divN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-divN/A
metadata-evalN/A
div-invN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
fabs-lowering-fabs.f6465.2%
Applied egg-rr65.2%
Final simplification65.2%
herbie shell --seed 2024191
(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)))))))