
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1 (sqrt PI))
(+
(+ (+ (* 2 (fabs x)) (* (/ 2 3) t_0)) (* (/ 1 5) t_1))
(* (/ 1 21) (* (* 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 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2 / 3), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1 / 5), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1 / 21), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\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}
Herbie found 12 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 (sqrt PI))
(+
(+ (+ (* 2 (fabs x)) (* (/ 2 3) t_0)) (* (/ 1 5) t_1))
(* (/ 1 21) (* (* 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 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2 / 3), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1 / 5), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1 / 21), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\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}
(FPCore (x)
:precision binary64
(let* ((t_0 (pow (fabs x) 5)))
(fabs
(*
(/ 1 (sqrt PI))
(+
(+
(+
(* 2 (fabs x))
(* (/ 2 3) (* (* (fabs x) (fabs x)) (fabs x))))
(* (/ 1 5) t_0))
(* (/ 1 21) (* (* t_0 (fabs x)) (fabs x))))))))double code(double x) {
double t_0 = pow(fabs(x), 5.0);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * ((fabs(x) * fabs(x)) * fabs(x)))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = Math.pow(Math.abs(x), 5.0);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * ((Math.abs(x) * Math.abs(x)) * Math.abs(x)))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = math.pow(math.fabs(x), 5.0) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * ((math.fabs(x) * math.fabs(x)) * math.fabs(x)))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = abs(x) ^ 5.0 return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * Float64(Float64(abs(x) * abs(x)) * abs(x)))) + Float64(Float64(1.0 / 5.0) * t_0)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_0 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = abs(x) ^ 5.0; tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * ((abs(x) * abs(x)) * abs(x)))) + ((1.0 / 5.0) * t_0)) + ((1.0 / 21.0) * ((t_0 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[Power[N[Abs[x], $MachinePrecision], 5], $MachinePrecision]}, N[Abs[N[(N[(1 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2 / 3), $MachinePrecision] * N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1 / 5), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1 / 21), $MachinePrecision] * N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := {\left(\left|x\right|\right)}^{5}\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot t\_0\right) + \frac{1}{21} \cdot \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow2N/A
pow-prod-upN/A
metadata-evalN/A
lower-pow.f6499.8%
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow2N/A
pow-prod-upN/A
metadata-evalN/A
lower-pow.f6499.9%
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(*
(/ 1 (sqrt PI))
(fabs
(+
(* (fabs x) (+ (* (* 1/5 (* x x)) (* x x)) (* (* t_0 t_0) 1/21)))
(* (fabs x) (+ (* (* x x) 2/3) 2)))))))double code(double x) {
double t_0 = (x * x) * x;
return (1.0 / sqrt(((double) M_PI))) * fabs(((fabs(x) * (((0.2 * (x * x)) * (x * x)) + ((t_0 * t_0) * 0.047619047619047616))) + (fabs(x) * (((x * x) * 0.6666666666666666) + 2.0))));
}
public static double code(double x) {
double t_0 = (x * x) * x;
return (1.0 / Math.sqrt(Math.PI)) * Math.abs(((Math.abs(x) * (((0.2 * (x * x)) * (x * x)) + ((t_0 * t_0) * 0.047619047619047616))) + (Math.abs(x) * (((x * x) * 0.6666666666666666) + 2.0))));
}
def code(x): t_0 = (x * x) * x return (1.0 / math.sqrt(math.pi)) * math.fabs(((math.fabs(x) * (((0.2 * (x * x)) * (x * x)) + ((t_0 * t_0) * 0.047619047619047616))) + (math.fabs(x) * (((x * x) * 0.6666666666666666) + 2.0))))
function code(x) t_0 = Float64(Float64(x * x) * x) return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(Float64(abs(x) * Float64(Float64(Float64(0.2 * Float64(x * x)) * Float64(x * x)) + Float64(Float64(t_0 * t_0) * 0.047619047619047616))) + Float64(abs(x) * Float64(Float64(Float64(x * x) * 0.6666666666666666) + 2.0))))) end
function tmp = code(x) t_0 = (x * x) * x; tmp = (1.0 / sqrt(pi)) * abs(((abs(x) * (((0.2 * (x * x)) * (x * x)) + ((t_0 * t_0) * 0.047619047619047616))) + (abs(x) * (((x * x) * 0.6666666666666666) + 2.0)))); end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(1 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 1/21), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * 2/3), $MachinePrecision] + 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\frac{1}{\sqrt{\pi}} \cdot \left|\left|x\right| \cdot \left(\left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right) + \left(t\_0 \cdot t\_0\right) \cdot \frac{1}{21}\right) + \left|x\right| \cdot \left(\left(x \cdot x\right) \cdot \frac{2}{3} + 2\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (x) :precision binary64 (fabs (* (- (* x (+ (* (* (* (* (* x x) x) x) x) 1/21) (* (* 1/5 (* x x)) x))) (- -2 (* 2/3 (* x x)))) (* (/ (fabs x) PI) (sqrt PI)))))
double code(double x) {
return fabs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * ((fabs(x) / ((double) M_PI)) * sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * ((Math.abs(x) / Math.PI) * Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * ((math.fabs(x) / math.pi) * math.sqrt(math.pi))))
function code(x) return abs(Float64(Float64(Float64(x * Float64(Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * x) * 0.047619047619047616) + Float64(Float64(0.2 * Float64(x * x)) * x))) - Float64(-2.0 - Float64(0.6666666666666666 * Float64(x * x)))) * Float64(Float64(abs(x) / pi) * sqrt(pi)))) end
function tmp = code(x) tmp = abs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * ((abs(x) / pi) * sqrt(pi)))); end
code[x_] := N[Abs[N[(N[(N[(x * N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 1/21), $MachinePrecision] + N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-2 - N[(2/3 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Abs[x], $MachinePrecision] / Pi), $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\left(x \cdot \left(\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot \frac{1}{21} + \left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x\right) - \left(-2 - \frac{2}{3} \cdot \left(x \cdot x\right)\right)\right) \cdot \left(\frac{\left|x\right|}{\pi} \cdot \sqrt{\pi}\right)\right|
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
sqr-abs-revN/A
pow2N/A
lift-*.f64N/A
mul-fabsN/A
lift-*.f64N/A
mul-fabsN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
pow2N/A
Applied rewrites99.8%
Applied rewrites99.6%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(-
(* x (+ (* (* (* (* (* x x) x) x) x) 1/21) (* (* 1/5 (* x x)) x)))
(- -2 (* 2/3 (* x x))))
(fabs x)))
(sqrt PI)))double code(double x) {
return fabs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * fabs(x))) / sqrt(((double) M_PI));
}
public static double code(double x) {
return Math.abs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * Math.abs(x))) / Math.sqrt(Math.PI);
}
def code(x): return math.fabs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * math.fabs(x))) / math.sqrt(math.pi)
function code(x) return Float64(abs(Float64(Float64(Float64(x * Float64(Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * x) * 0.047619047619047616) + Float64(Float64(0.2 * Float64(x * x)) * x))) - Float64(-2.0 - Float64(0.6666666666666666 * Float64(x * x)))) * abs(x))) / sqrt(pi)) end
function tmp = code(x) tmp = abs((((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) - (-2.0 - (0.6666666666666666 * (x * x)))) * abs(x))) / sqrt(pi); end
code[x_] := N[(N[Abs[N[(N[(N[(x * N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 1/21), $MachinePrecision] + N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-2 - N[(2/3 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\frac{\left|\left(x \cdot \left(\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot \frac{1}{21} + \left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x\right) - \left(-2 - \frac{2}{3} \cdot \left(x \cdot x\right)\right)\right) \cdot \left|x\right|\right|}{\sqrt{\pi}}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
sqr-abs-revN/A
pow2N/A
lift-*.f64N/A
mul-fabsN/A
lift-*.f64N/A
mul-fabsN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
pow2N/A
Applied rewrites99.8%
Applied rewrites99.4%
(FPCore (x) :precision binary64 (fabs (* (/ (fabs x) (sqrt PI)) (- (* (- (* (* 1/5 (* x x)) x) (* -1/21 (* (* (* (* x x) x) x) x))) x) (- -2 (* 2/3 (* x x)))))))
double code(double x) {
return fabs(((fabs(x) / sqrt(((double) M_PI))) * (((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x) - (-2.0 - (0.6666666666666666 * (x * x))))));
}
public static double code(double x) {
return Math.abs(((Math.abs(x) / Math.sqrt(Math.PI)) * (((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x) - (-2.0 - (0.6666666666666666 * (x * x))))));
}
def code(x): return math.fabs(((math.fabs(x) / math.sqrt(math.pi)) * (((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x) - (-2.0 - (0.6666666666666666 * (x * x))))))
function code(x) return abs(Float64(Float64(abs(x) / sqrt(pi)) * Float64(Float64(Float64(Float64(Float64(0.2 * Float64(x * x)) * x) - Float64(-0.047619047619047616 * Float64(Float64(Float64(Float64(x * x) * x) * x) * x))) * x) - Float64(-2.0 - Float64(0.6666666666666666 * Float64(x * x)))))) end
function tmp = code(x) tmp = abs(((abs(x) / sqrt(pi)) * (((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x) - (-2.0 - (0.6666666666666666 * (x * x)))))); end
code[x_] := N[Abs[N[(N[(N[Abs[x], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] - N[(-1/21 * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] - N[(-2 - N[(2/3 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{\left|x\right|}{\sqrt{\pi}} \cdot \left(\left(\left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x - \frac{-1}{21} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right)\right) \cdot x - \left(-2 - \frac{2}{3} \cdot \left(x \cdot x\right)\right)\right)\right|
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
sqr-abs-revN/A
pow2N/A
lift-*.f64N/A
mul-fabsN/A
lift-*.f64N/A
mul-fabsN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
pow2N/A
Applied rewrites99.8%
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6%
Applied rewrites99.4%
(FPCore (x)
:precision binary64
(*
(/ (sqrt PI) PI)
(fabs
(*
x
(+
(* x (+ (* (* (* x x) x) (* x (* 1/21 x))) (* (* 1/5 (* x x)) x)))
2)))))double code(double x) {
return (sqrt(((double) M_PI)) / ((double) M_PI)) * fabs((x * ((x * ((((x * x) * x) * (x * (0.047619047619047616 * x))) + ((0.2 * (x * x)) * x))) + 2.0)));
}
public static double code(double x) {
return (Math.sqrt(Math.PI) / Math.PI) * Math.abs((x * ((x * ((((x * x) * x) * (x * (0.047619047619047616 * x))) + ((0.2 * (x * x)) * x))) + 2.0)));
}
def code(x): return (math.sqrt(math.pi) / math.pi) * math.fabs((x * ((x * ((((x * x) * x) * (x * (0.047619047619047616 * x))) + ((0.2 * (x * x)) * x))) + 2.0)))
function code(x) return Float64(Float64(sqrt(pi) / pi) * abs(Float64(x * Float64(Float64(x * Float64(Float64(Float64(Float64(x * x) * x) * Float64(x * Float64(0.047619047619047616 * x))) + Float64(Float64(0.2 * Float64(x * x)) * x))) + 2.0)))) end
function tmp = code(x) tmp = (sqrt(pi) / pi) * abs((x * ((x * ((((x * x) * x) * (x * (0.047619047619047616 * x))) + ((0.2 * (x * x)) * x))) + 2.0))); end
code[x_] := N[(N[(N[Sqrt[Pi], $MachinePrecision] / Pi), $MachinePrecision] * N[Abs[N[(x * N[(N[(x * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * N[(1/21 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{\pi}}{\pi} \cdot \left|x \cdot \left(x \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot \left(\frac{1}{21} \cdot x\right)\right) + \left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x\right) + 2\right)\right|
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.6%
Applied rewrites99.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
(FPCore (x)
:precision binary64
(*
(/ (sqrt PI) PI)
(fabs
(*
x
(+
(* x (+ (* (* 1/21 (* (* (* x x) x) x)) x) (* (* 1/5 (* x x)) x)))
2)))))double code(double x) {
return (sqrt(((double) M_PI)) / ((double) M_PI)) * fabs((x * ((x * (((0.047619047619047616 * (((x * x) * x) * x)) * x) + ((0.2 * (x * x)) * x))) + 2.0)));
}
public static double code(double x) {
return (Math.sqrt(Math.PI) / Math.PI) * Math.abs((x * ((x * (((0.047619047619047616 * (((x * x) * x) * x)) * x) + ((0.2 * (x * x)) * x))) + 2.0)));
}
def code(x): return (math.sqrt(math.pi) / math.pi) * math.fabs((x * ((x * (((0.047619047619047616 * (((x * x) * x) * x)) * x) + ((0.2 * (x * x)) * x))) + 2.0)))
function code(x) return Float64(Float64(sqrt(pi) / pi) * abs(Float64(x * Float64(Float64(x * Float64(Float64(Float64(0.047619047619047616 * Float64(Float64(Float64(x * x) * x) * x)) * x) + Float64(Float64(0.2 * Float64(x * x)) * x))) + 2.0)))) end
function tmp = code(x) tmp = (sqrt(pi) / pi) * abs((x * ((x * (((0.047619047619047616 * (((x * x) * x) * x)) * x) + ((0.2 * (x * x)) * x))) + 2.0))); end
code[x_] := N[(N[(N[Sqrt[Pi], $MachinePrecision] / Pi), $MachinePrecision] * N[Abs[N[(x * N[(N[(x * N[(N[(N[(1/21 * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] + N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{\pi}}{\pi} \cdot \left|x \cdot \left(x \cdot \left(\left(\frac{1}{21} \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right)\right) \cdot x + \left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x\right) + 2\right)\right|
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.6%
Applied rewrites99.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.1%
Applied rewrites99.1%
(FPCore (x)
:precision binary64
(*
(sqrt PI)
(/
(fabs
(*
(+
2
(*
(- (* (* 1/5 (* x x)) x) (* -1/21 (* (* (* (* x x) x) x) x)))
x))
x))
PI)))double code(double x) {
return sqrt(((double) M_PI)) * (fabs(((2.0 + ((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x)) * x)) / ((double) M_PI));
}
public static double code(double x) {
return Math.sqrt(Math.PI) * (Math.abs(((2.0 + ((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x)) * x)) / Math.PI);
}
def code(x): return math.sqrt(math.pi) * (math.fabs(((2.0 + ((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x)) * x)) / math.pi)
function code(x) return Float64(sqrt(pi) * Float64(abs(Float64(Float64(2.0 + Float64(Float64(Float64(Float64(0.2 * Float64(x * x)) * x) - Float64(-0.047619047619047616 * Float64(Float64(Float64(Float64(x * x) * x) * x) * x))) * x)) * x)) / pi)) end
function tmp = code(x) tmp = sqrt(pi) * (abs(((2.0 + ((((0.2 * (x * x)) * x) - (-0.047619047619047616 * ((((x * x) * x) * x) * x))) * x)) * x)) / pi); end
code[x_] := N[(N[Sqrt[Pi], $MachinePrecision] * N[(N[Abs[N[(N[(2 + N[(N[(N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] - N[(-1/21 * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
\sqrt{\pi} \cdot \frac{\left|\left(2 + \left(\left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x - \frac{-1}{21} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right)\right) \cdot x\right) \cdot x\right|}{\pi}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.6%
Applied rewrites99.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.8%
Applied rewrites98.8%
(FPCore (x)
:precision binary64
(/
(fabs
(*
x
(+
(* x (+ (* (* (* (* (* x x) x) x) x) 1/21) (* (* 1/5 (* x x)) x)))
2)))
(sqrt PI)))double code(double x) {
return fabs((x * ((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) + 2.0))) / sqrt(((double) M_PI));
}
public static double code(double x) {
return Math.abs((x * ((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) + 2.0))) / Math.sqrt(Math.PI);
}
def code(x): return math.fabs((x * ((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) + 2.0))) / math.sqrt(math.pi)
function code(x) return Float64(abs(Float64(x * Float64(Float64(x * Float64(Float64(Float64(Float64(Float64(Float64(x * x) * x) * x) * x) * 0.047619047619047616) + Float64(Float64(0.2 * Float64(x * x)) * x))) + 2.0))) / sqrt(pi)) end
function tmp = code(x) tmp = abs((x * ((x * ((((((x * x) * x) * x) * x) * 0.047619047619047616) + ((0.2 * (x * x)) * x))) + 2.0))) / sqrt(pi); end
code[x_] := N[(N[Abs[N[(x * N[(N[(x * N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * 1/21), $MachinePrecision] + N[(N[(1/5 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\frac{\left|x \cdot \left(x \cdot \left(\left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot \frac{1}{21} + \left(\frac{1}{5} \cdot \left(x \cdot x\right)\right) \cdot x\right) + 2\right)\right|}{\sqrt{\pi}}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.6%
Applied rewrites98.6%
(FPCore (x) :precision binary64 (if (<= (fabs x) 4722366482869645/9444732965739290427392) (* (/ (sqrt PI) PI) (fabs (* 2 (fabs x)))) (fabs (* 2 (/ (sqrt (* (* (fabs x) (fabs x)) PI)) PI)))))
double code(double x) {
double tmp;
if (fabs(x) <= 5e-7) {
tmp = (sqrt(((double) M_PI)) / ((double) M_PI)) * fabs((2.0 * fabs(x)));
} else {
tmp = fabs((2.0 * (sqrt(((fabs(x) * fabs(x)) * ((double) M_PI))) / ((double) M_PI))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 5e-7) {
tmp = (Math.sqrt(Math.PI) / Math.PI) * Math.abs((2.0 * Math.abs(x)));
} else {
tmp = Math.abs((2.0 * (Math.sqrt(((Math.abs(x) * Math.abs(x)) * Math.PI)) / Math.PI)));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 5e-7: tmp = (math.sqrt(math.pi) / math.pi) * math.fabs((2.0 * math.fabs(x))) else: tmp = math.fabs((2.0 * (math.sqrt(((math.fabs(x) * math.fabs(x)) * math.pi)) / math.pi))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 5e-7) tmp = Float64(Float64(sqrt(pi) / pi) * abs(Float64(2.0 * abs(x)))); else tmp = abs(Float64(2.0 * Float64(sqrt(Float64(Float64(abs(x) * abs(x)) * pi)) / pi))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 5e-7) tmp = (sqrt(pi) / pi) * abs((2.0 * abs(x))); else tmp = abs((2.0 * (sqrt(((abs(x) * abs(x)) * pi)) / pi))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 4722366482869645/9444732965739290427392], N[(N[(N[Sqrt[Pi], $MachinePrecision] / Pi), $MachinePrecision] * N[Abs[N[(2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(2 * N[(N[Sqrt[N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq \frac{4722366482869645}{9444732965739290427392}:\\
\;\;\;\;\frac{\sqrt{\pi}}{\pi} \cdot \left|2 \cdot \left|x\right|\right|\\
\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \frac{\sqrt{\left(\left|x\right| \cdot \left|x\right|\right) \cdot \pi}}{\pi}\right|\\
\end{array}
if x < 4.9999999999999998e-7Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.6%
Applied rewrites99.1%
Taylor expanded in x around 0
lower-*.f6467.7%
Applied rewrites67.7%
if 4.9999999999999998e-7 < x Initial program 99.8%
Applied rewrites99.6%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
lower-PI.f6467.4%
Applied rewrites67.4%
lift-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6453.7%
Applied rewrites53.7%
(FPCore (x) :precision binary64 (* (/ (sqrt PI) PI) (fabs (* 2 x))))
double code(double x) {
return (sqrt(((double) M_PI)) / ((double) M_PI)) * fabs((2.0 * x));
}
public static double code(double x) {
return (Math.sqrt(Math.PI) / Math.PI) * Math.abs((2.0 * x));
}
def code(x): return (math.sqrt(math.pi) / math.pi) * math.fabs((2.0 * x))
function code(x) return Float64(Float64(sqrt(pi) / pi) * abs(Float64(2.0 * x))) end
function tmp = code(x) tmp = (sqrt(pi) / pi) * abs((2.0 * x)); end
code[x_] := N[(N[(N[Sqrt[Pi], $MachinePrecision] / Pi), $MachinePrecision] * N[Abs[N[(2 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{\pi}}{\pi} \cdot \left|2 \cdot x\right|
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites98.6%
Applied rewrites99.1%
Taylor expanded in x around 0
lower-*.f6467.7%
Applied rewrites67.7%
(FPCore (x) :precision binary64 (fabs (* 2 (/ (fabs x) (sqrt PI)))))
double code(double x) {
return fabs((2.0 * (fabs(x) / sqrt(((double) M_PI)))));
}
public static double code(double x) {
return Math.abs((2.0 * (Math.abs(x) / Math.sqrt(Math.PI))));
}
def code(x): return math.fabs((2.0 * (math.fabs(x) / math.sqrt(math.pi))))
function code(x) return abs(Float64(2.0 * Float64(abs(x) / sqrt(pi)))) end
function tmp = code(x) tmp = abs((2.0 * (abs(x) / sqrt(pi)))); end
code[x_] := N[Abs[N[(2 * N[(N[Abs[x], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right|
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
lift-fabs.f64N/A
mul-fabsN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
sqr-abs-revN/A
pow2N/A
lift-*.f64N/A
mul-fabsN/A
lift-*.f64N/A
mul-fabsN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
pow2N/A
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6467.2%
Applied rewrites67.2%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x)
:name "Jmat.Real.erfi, branch x less than or equal to 0.5"
:precision binary64
:pre (<= x 1/2)
(fabs (* (/ 1 (sqrt PI)) (+ (+ (+ (* 2 (fabs x)) (* (/ 2 3) (* (* (fabs x) (fabs x)) (fabs x)))) (* (/ 1 5) (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)))) (* (/ 1 21) (* (* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)))))))