16 bool ok = pol.find(x(
w), xyset);
18 ok = pol.find(y(
w), xyset);
19 if(!ok)
return exvector();
21 exvector xys(xyset.size());
22 copy(xyset.begin(), xyset.end(), xys.begin());
23 sort(xys.begin(), xys.end(), [](
const auto &
a,
const auto &b){
24 return normal((b-a)).subs(lst{ x(w)==w, y(w)==w }).info(info_flags::positive);
26 return exvector(std::move(xys));
31 bool ok = pol.find(x(
w), xset);
36 exvector xs(xset.size());
37 copy(xset.begin(), xset.end(), xs.begin());
38 sort(xs.begin(), xs.end(), [](
const auto &
a,
const auto &b){
39 return normal((b-a)).subs(lst{ x(w)==w }).info(info_flags::positive);
41 return exvector(std::move(xs));
46 bool ok = pol.find(y(
w), yset);
51 exvector ys(yset.size());
52 copy(yset.begin(), yset.end(), ys.begin());
53 sort(ys.begin(), ys.end(), [](
const auto &
a,
const auto &b){
54 return normal((b-a)).subs(lst{ y(w)==w }).info(info_flags::positive);
56 return exvector(std::move(ys));
61 bool ok = pol.find(z(
w), zset);
66 exvector zs(zset.size());
67 copy(zset.begin(), zset.end(), zs.begin());
68 sort(zs.begin(), zs.end(), [](
const auto &
a,
const auto &b){
69 return normal((b-a)).subs(lst{ z(w)==w }).info(info_flags::positive);
71 return exvector(std::move(zs));
76 bool ok = pol.find(PL(
w), plset);
81 exvector pls(plset.size());
82 copy(plset.begin(), plset.end(), pls.begin());
83 sort(pls.begin(), pls.end(), [](
const auto &
a,
const auto &b){
84 return normal((b-a)).subs(lst{ PL(w)==w }).info(info_flags::positive);
86 return exvector(std::move(pls));
94 auto cvs =
collect_lst(ee, [](
const ex & e)->
bool {
return !is_a<numeric>(e) && !e.match(VE(
w1,
w2)); });
99 ex vIR=0, eI2 = 0, eR2 = 0;
100 for(
auto cc_vv : cc_vv_lst) {
101 auto co =
NN(cc_vv.op(0));
102 auto ve = cc_vv.op(1);
103 if(!is_a<numeric>(co)) {
105 throw Error(
"VESimplify: coefficient of VE is not numeric.");
107 if(abs(co)>numeric(
"1E300"))
return NaN;
108 vIR += co * ve.op(0);
109 numeric nco = ex_to<numeric>(co);
110 ex ee = ve.op(1) * ve.op(1);
111 eR2 += nco.real_part() * nco.real_part() * ee;
112 eI2 += nco.imag_part() * nco.imag_part() * ee;
114 if(!is_zero(eR2) || !is_zero(vIR))
115 ret += VE(ex_to<numeric>(vIR).real_part(), sqrt(eR2)) * vf;
116 if(!is_zero(eI2) || !is_zero(vIR))
117 ret += VE(ex_to<numeric>(vIR).imag_part(), sqrt(eI2)) * vf * I;
124 return expr.subs(VE(0,0)==0).subs(VE(
w1,
w2)==VEO(
w1,
w2));
128 return expr.subs(VE(0,0)==0).subs(VE(
w1,
w2)==VEO2(
w1,
w2));
133 auto ccRes = expr.expand();
135 if(is_a<add>(ccRes)) {
136 for(
auto item : ccRes) ccResList.append(item);
138 ccResList.append(ccRes);
142 for(
auto item : ccResList) {
144 if(is_a<mul>(item)) {
146 for(
auto ii : item) {
147 if(is_a<numeric>(ii) || ii.match(VE(
w1,
w2))) {
151 }
else if(is_a<numeric>(item) || item.match(VE(
w1,
w2))) {
154 ntmp =
NN(abs(ntmp.subs(VE(
w1,
w2)==
w2)));
155 if(ntmp>ccRes) ccRes = ntmp;
167 for(
int i=0; i<=xs.size(); i++) {
170 if(xi.is_equal(x(i))) {
182 for(
int i=0; i<=ys.size(); i++) {
185 if(yi.is_equal(y(i))) {
197 if(!expr_in.has(epi))
return 0;
199 auto expr = expr_in.subs(epi==s);
202 auto tmp = series_to_poly(expr.series(s, p));
205 return tmp.ldegree(s);
208 throw Error(
"epsRank error!");
212 if(!expr_in.has(
vs))
return 0;
216 auto tmp = series_to_poly(expr.series(
vs, p));
219 return tmp.ldegree(
vs);
222 throw Error(
"vsRank error!");
229 void SecDec::VEPrint(
bool endlQ) {
231 for(
int i=expr.ldegree(
eps); i<=expr.degree(
eps); i++) {
232 ex exp1 = expr.coeff(
eps, i);
233 for(
int j=expr.ldegree(
ep); j<=expr.degree(
ep); j++) {
235 cout << exp1.coeff(
ep, j);
238 if(j<expr.degree(
ep)) cout <<
" + ";
241 if(endlQ) cout << endl;
245 ex expr = collect_common_factors(expr_in);
246 if(is_a<mul>(expr)) {
248 for(
auto item : expr) {
249 if(item.has(x(
w)) || (item.has(y(
w))) || (item.has(z(
w)))) ret *=
Factor(item);
253 }
else if(is_a<power>(expr) || expr.match(pow(
w1,
w2))) {
254 return pow(
Factor(expr.op(0)), expr.op(1));
258 expr.find(x(
w), xyset);
259 expr.find(y(
w), xyset);
260 expr.find(z(
w), xyset);
261 expr.find(PL(
w), xyset);
263 for(
auto xyi : xyset) {
265 xy2s.append(xyi==txy);
266 s2xy.append(txy==xyi);
269 expr2 = collect_common_factors(expr2);
270 expr2 = expr2.subs(xy2s);
271 expr2 = factor(expr2);
272 expr2 = expr2.subs(s2xy);
274 expr2 = collect_common_factors(expr2);
280 expr.find(x(
w), xset);
282 for(
auto xi : xset) {
288 expr2 = collect_common_factors(expr2);
289 expr2 = expr2.subs(x2s);
290 expr2 = factor(expr2);
291 expr2 = expr2.subs(s2x);
293 expr2 = collect_common_factors(expr2);
294 if(!is_a<mul>(expr2))
return expr2;
296 for(
auto item : expr2) {
297 if(!item.match(x(
w)) && !item.match(pow(x(
w1),
w2))) ret *= item;
305 sub_exp[pow(exp(
w1),
w2)]=exp(
w1*
w2);
306 sub_exp[sqrt(exp(
w1))]=exp(
w1/2);
308 sub_exp[exp(
w1)*exp(
w2)]=exp(
w1+
w2);
310 auto expo = expr.subs(sub_exp);
311 if(is_zero(expo-expr))
break;
321 sub_pow[sqrt(pow(
w1,
w2))] = pow(
w1,
w2/2);
322 sub_pow[pow(sqrt(
w1),
w2)] = pow(
w1,
w2/2);
326 sub_pow[pow(
w1,
w2)*sqrt(
w1)] = pow(
w1,
w2+1/ex(2));
327 sub_pow[pow(
w1,
w2)/sqrt(
w1)] = pow(
w1,
w2-1/ex(2));
329 auto expo = expr.subs(sub_pow);
330 if(is_zero(expo-expr))
break;
342 sub_pow[sqrt(pow(
w1,
w2))] = pow(
w1,
w2/2);
343 sub_pow[pow(sqrt(
w1),
w2)] = pow(
w1,
w2/2);
347 sub_pow[pow(
w1,
w2)*sqrt(
w1)] = pow(
w1,
w2+1/ex(2));
348 sub_pow[pow(
w1,
w2)/sqrt(
w1)] = pow(
w1,
w2-1/ex(2));
354 auto expo = expr.subs(sub_pow);
355 if(is_zero(expo-expr))
break;
361 ex SecDec::PrefactorFIESTA(
int nLoop) {
362 return pow(I*pow(Pi,2-
ep)*exp(ex(0)-
ep*Euler), ex(0)-ex(nLoop));
369 ex SecDec::XRefined(ex
const & in_ft) {
373 if(ft.match(pow(
w1,
w2))) {
375 }
else if(is_a<mul>(ft)) {
380 else if(s<0) tmp = ex(0)-tmp;
381 else tmp = tmp * fti;
384 if((ft-ft0).is_zero())
break;
392 lst SecDec::XRefined_lst(ex
const & in_ft) {
393 auto ft = XRefined(in_ft);
396 for(
auto const &item : ft) ret.append(item);
class used to wrap error message
namespace for Numerical integration with Sector Decomposition method
ex FactorOutX(const ex expr)
exvector get_z_from(ex pol)
exvector get_xy_from(ex pol)
ex xyz_pow_simplify(const ex expr_in)
ex exp_simplify(const ex expr_in)
int x_free_index(ex expr)
exvector get_pl_from(ex pol)
exvector get_y_from(ex pol)
exvector get_x_from(ex pol)
int y_free_index(ex expr)
int epsRank(ex expr_in, ex epi)
ex Factor(const ex expr_in)
ex pow_simplify(const ex expr_in)
const char * Color_HighLight
ex EvalF(ex expr)
the nuerical evaluation, Digits=100 will be used
ex NN(ex expr, int digits)
the nuerical evaluation
ex collect_ex(ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
the collect function like Mathematica
lst collect_lst(ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
the collect function like Mathematica, reture the lst { {c1,v1}, {c2,v2}, ... }
int xSign(ex const expr)
the always sign for expr