
(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}
Herbie found 13 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
(*
(/ 1.0 (sqrt PI))
(fabs
(*
x
(+
(* (* (fma 0.047619047619047616 (* x x) 0.2) (* (* x x) x)) x)
(fma 0.6666666666666666 (* x x) 2.0))))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((x * (((fma(0.047619047619047616, (x * x), 0.2) * ((x * x) * x)) * x) + fma(0.6666666666666666, (x * x), 2.0))));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(x * Float64(Float64(Float64(fma(0.047619047619047616, Float64(x * x), 0.2) * Float64(Float64(x * x) * x)) * x) + fma(0.6666666666666666, Float64(x * x), 2.0))))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x * N[(N[(N[(N[(0.047619047619047616 * N[(x * x), $MachinePrecision] + 0.2), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|x \cdot \left(\left(\mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot x + \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow177.5
Applied rewrites77.5%
Taylor expanded in x around 0
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow199.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
distribute-lft-outN/A
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(/
(fabs
(fma
(fma
(* x x)
(fma (* (* x x) x) 0.047619047619047616 (* 0.2 x))
(* 0.6666666666666666 x))
(* x x)
(+ x x)))
(sqrt PI)))
double code(double x) {
return fabs(fma(fma((x * x), fma(((x * x) * x), 0.047619047619047616, (0.2 * x)), (0.6666666666666666 * x)), (x * x), (x + x))) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(fma(fma(Float64(x * x), fma(Float64(Float64(x * x) * x), 0.047619047619047616, Float64(0.2 * x)), Float64(0.6666666666666666 * x)), Float64(x * x), Float64(x + x))) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * 0.047619047619047616 + N[(0.2 * x), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, 0.047619047619047616, 0.2 \cdot x\right), 0.6666666666666666 \cdot x\right), x \cdot x, x + x\right)\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites99.4%
(FPCore (x) :precision binary64 (if (<= x 2.2) (* (/ 1.0 (sqrt PI)) (fabs (* (fma (* x x) 0.6666666666666666 2.0) x))) (/ (fabs (* (pow x 7.0) 0.047619047619047616)) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fma((x * x), 0.6666666666666666, 2.0) * x));
} else {
tmp = fabs((pow(x, 7.0) * 0.047619047619047616)) / sqrt(((double) M_PI));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 2.2) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x))); else tmp = Float64(abs(Float64((x ^ 7.0) * 0.047619047619047616)) / sqrt(pi)); end return tmp end
code[x_] := If[LessEqual[x, 2.2], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[Power[x, 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|{x}^{7} \cdot 0.047619047619047616\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2N/A
sqr-abs-revN/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.0%
if 2.2000000000000002 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
pow-prod-upN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
metadata-evalN/A
pow-plusN/A
pow3N/A
pow2N/A
sqr-abs-revN/A
associate-*l*N/A
Applied rewrites36.6%
(FPCore (x)
:precision binary64
(*
(/ 1.0 (sqrt PI))
(fabs
(fma
x
(* (fma (* x x) 0.047619047619047616 0.2) (* (* (* x x) x) x))
(* x 2.0)))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs(fma(x, (fma((x * x), 0.047619047619047616, 0.2) * (((x * x) * x) * x)), (x * 2.0)));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(fma(x, Float64(fma(Float64(x * x), 0.047619047619047616, 0.2) * Float64(Float64(Float64(x * x) * x) * x)), Float64(x * 2.0)))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x * N[(N[(N[(x * x), $MachinePrecision] * 0.047619047619047616 + 0.2), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(x, \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right) \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right), x \cdot 2\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow177.5
Applied rewrites77.5%
Taylor expanded in x around 0
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow199.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.0%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt PI)) (fma (pow x 7.0) 0.047619047619047616 (+ x x)))))
double code(double x) {
return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(x, 7.0), 0.047619047619047616, (x + x))));
}
function code(x) return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((x ^ 7.0), 0.047619047619047616, Float64(x + x)))) end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Power[x, 7.0], $MachinePrecision] * 0.047619047619047616 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({x}^{7}, 0.047619047619047616, x + x\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites98.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(if (<= x 1.85)
(* (/ 1.0 (sqrt PI)) (fabs (* (fma (* x x) 0.6666666666666666 2.0) x)))
(/ (fabs (* 0.2 (* t_0 t_0))) (sqrt PI)))))
double code(double x) {
double t_0 = (x * x) * x;
double tmp;
if (x <= 1.85) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((fma((x * x), 0.6666666666666666, 2.0) * x));
} else {
tmp = fabs((0.2 * (t_0 * t_0))) / sqrt(((double) M_PI));
}
return tmp;
}
function code(x) t_0 = Float64(Float64(x * x) * x) tmp = 0.0 if (x <= 1.85) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x))); else tmp = Float64(abs(Float64(0.2 * Float64(t_0 * t_0))) / sqrt(pi)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, 1.85], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(0.2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\mathbf{if}\;x \leq 1.85:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|0.2 \cdot \left(t\_0 \cdot t\_0\right)\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 1.8500000000000001Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2N/A
sqr-abs-revN/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.0%
if 1.8500000000000001 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.6%
Taylor expanded in x around 0
metadata-evalN/A
associate-*l/N/A
metadata-evalN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
associate-/l/N/A
metadata-evalN/A
associate-/r*N/A
pow2N/A
*-commutativeN/A
pow2N/A
metadata-evalN/A
pow2N/A
associate-*l*N/A
Applied rewrites31.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
swap-sqrN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6431.8
Applied rewrites31.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt PI))))
(if (<= x 2.3)
(* t_0 (fabs (* (fma (* x x) 0.6666666666666666 2.0) x)))
(fabs (* t_0 (* (* (* (* (* x x) x) x) 0.2) x))))))
double code(double x) {
double t_0 = 1.0 / sqrt(((double) M_PI));
double tmp;
if (x <= 2.3) {
tmp = t_0 * fabs((fma((x * x), 0.6666666666666666, 2.0) * x));
} else {
tmp = fabs((t_0 * (((((x * x) * x) * x) * 0.2) * x)));
}
return tmp;
}
function code(x) t_0 = Float64(1.0 / sqrt(pi)) tmp = 0.0 if (x <= 2.3) tmp = Float64(t_0 * abs(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x))); else tmp = abs(Float64(t_0 * Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * 0.2) * x))); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3], N[(t$95$0 * N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(t$95$0 * N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 0.2), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\pi}}\\
\mathbf{if}\;x \leq 2.3:\\
\;\;\;\;t\_0 \cdot \left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_0 \cdot \left(\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot 0.2\right) \cdot x\right)\right|\\
\end{array}
\end{array}
if x < 2.2999999999999998Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2N/A
sqr-abs-revN/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.0%
if 2.2999999999999998 < x Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites30.8%
(FPCore (x) :precision binary64 (* (/ 1.0 (sqrt PI)) (fabs (* (fma (* x x) 0.6666666666666666 2.0) x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((fma((x * x), 0.6666666666666666, 2.0) * x));
}
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x))) end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2N/A
sqr-abs-revN/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.0%
(FPCore (x) :precision binary64 (if (<= x 0.85) (* (/ 1.0 (sqrt PI)) (fabs (+ x x))) (/ (fabs (* 2.6666666666666665 (* (* x x) x))) (sqrt PI))))
double code(double x) {
double tmp;
if (x <= 0.85) {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((x + x));
} else {
tmp = fabs((2.6666666666666665 * ((x * x) * x))) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 0.85) {
tmp = (1.0 / Math.sqrt(Math.PI)) * Math.abs((x + x));
} else {
tmp = Math.abs((2.6666666666666665 * ((x * x) * x))) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.85: tmp = (1.0 / math.sqrt(math.pi)) * math.fabs((x + x)) else: tmp = math.fabs((2.6666666666666665 * ((x * x) * x))) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (x <= 0.85) tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(x + x))); else tmp = Float64(abs(Float64(2.6666666666666665 * Float64(Float64(x * x) * x))) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.85) tmp = (1.0 / sqrt(pi)) * abs((x + x)); else tmp = abs((2.6666666666666665 * ((x * x) * x))) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.85], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(2.6666666666666665 * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.85:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|x + x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|2.6666666666666665 \cdot \left(\left(x \cdot x\right) \cdot x\right)\right|}{\sqrt{\pi}}\\
\end{array}
\end{array}
if x < 0.849999999999999978Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow167.8
Applied rewrites67.8%
if 0.849999999999999978 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
metadata-evalN/A
pow2N/A
sqr-abs-revN/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.0%
Applied rewrites26.9%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (* x x) 0.6666666666666666 2.0) x)) (sqrt PI)))
double code(double x) {
return fabs((fma((x * x), 0.6666666666666666, 2.0) * x)) / sqrt(((double) M_PI));
}
function code(x) return Float64(abs(Float64(fma(Float64(x * x), 0.6666666666666666, 2.0) * x)) / sqrt(pi)) end
code[x_] := N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
metadata-evalN/A
pow2N/A
sqr-abs-revN/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.6%
(FPCore (x) :precision binary64 (* (/ 1.0 (sqrt PI)) (fabs (+ x x))))
double code(double x) {
return (1.0 / sqrt(((double) M_PI))) * fabs((x + x));
}
public static double code(double x) {
return (1.0 / Math.sqrt(Math.PI)) * Math.abs((x + x));
}
def code(x): return (1.0 / math.sqrt(math.pi)) * math.fabs((x + x))
function code(x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(x + x))) end
function tmp = code(x) tmp = (1.0 / sqrt(pi)) * abs((x + x)); end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\pi}} \cdot \left|x + x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow167.8
Applied rewrites67.8%
(FPCore (x) :precision binary64 (/ (fabs (+ x x)) (sqrt PI)))
double code(double x) {
return fabs((x + x)) / sqrt(((double) M_PI));
}
public static double code(double x) {
return Math.abs((x + x)) / Math.sqrt(Math.PI);
}
def code(x): return math.fabs((x + x)) / math.sqrt(math.pi)
function code(x) return Float64(abs(Float64(x + x)) / sqrt(pi)) end
function tmp = code(x) tmp = abs((x + x)) / sqrt(pi); end
code[x_] := N[(N[Abs[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x + x\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow167.4
Applied rewrites67.4%
(FPCore (x) :precision binary64 (/ (fabs 0.2) (sqrt PI)))
double code(double x) {
return fabs(0.2) / sqrt(((double) M_PI));
}
public static double code(double x) {
return Math.abs(0.2) / Math.sqrt(Math.PI);
}
def code(x): return math.fabs(0.2) / math.sqrt(math.pi)
function code(x) return Float64(abs(0.2) / sqrt(pi)) end
function tmp = code(x) tmp = abs(0.2) / sqrt(pi); end
code[x_] := N[(N[Abs[0.2], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|0.2\right|}{\sqrt{\pi}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.6%
Taylor expanded in x around 0
Applied rewrites4.7%
herbie shell --seed 2025115
(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)))))))