# 6. Frequently Asked Questions¶

## 6.1. How can I adjust the integrator parameters?¶

If the python interface is used for the numerical integration, i.e. a python script like `examples/integrate_box1L.py`

, the integration parameters can be specified in the argument list of the integrator call.
For example, using Vegas as integrator:

```
box1L.use_Vegas(flags=2, epsrel=1e-3, epsabs=1e-12, nstart=5000, nincrease=10000, maxeval=10000000, real_complex_together=True)
```

Or, using Divonne as integrator:

```
box1L.use_Divonne(flags=2, epsrel=1e-3, epsabs=1e-12, maxeval=10000000, border=1e-8, real complex together=True)
```

The parameter real complex together tells the integrator to integrate real and imaginary parts simultaneously. A complete list of possible options for the integrators can be found in `integral_interface`

.

If the C++ interface is used, the options can be specified as fields of the integrator.
For example, after running `examples/generate_box1L.py`

, in the file `examples/box1L/integrate_box1L.cpp`

, you can modify the corresponding block to e.g.:

```
// Integrate
secdecutil::cuba::Vegas<box1L::integrand_return_t> integrator;
integrator.flags = 2; // verbose output --> see cuba manual
integrator.epsrel = 1e-2;
integrator.epsabs = 1e-12;
integrator.nstart = 5000;
integrator.nincrease = 10000;
integrator.maxeval = 10000000;
integrator.together = true;
```

In order to set the Divonne integrator with the same parameters as above, do:

```
// Integrate
secdecutil::cuba::Divonne<box1L::integrand_return_t> integrator;
integrator.flags = 2; // verbose output --> see cuba manual
integrator.epsrel = 1e-2;
integrator.epsabs = 1e-12;
integrator.maxeval = 10000000;
integrator.border = 1e-8;
integrator.together = true;
```

More information about the C++ integrator class can be found in Section 4.6.

## 6.2. How can I request a higher numerical accuracy?¶

The integrator stops if any of the following conditions is fulfilled: (1) `epsrel`

is reached, (2) `epsabs`

is reached, (3) `maxeval`

is reached.
Therefore, setting these parameters accordingly will cause the integrator to make more iterations and reach a more accurate result.

## 6.3. What can I do if the integration takes very long?¶

For most integrals, the best performance will be achieved using the QMC integrator and we recommend switching to it, if not already used.
If changing the integrator doesn’t improve the runtime, it is possible that the integrator parameters should be adjusted, as described in the previous sections.
In particular for integrals with spurious poles, the parameter `epsabs`

should be increased, since it is the only relevant stopping criterion in this case, besides `maxeval`

.

## 6.4. How can I tune the contour deformation parameters?¶

You can specify the parameters in the argument of the integral call in the python script for the integration, see e.g. line 12 of `examples/integrate box1L.py`

:

```
str_integral_without_prefactor, str_prefactor, str_integral_with_prefactor=box1L(real_parameters=[4.,-0.75,1.25,1.],number_of_presamples=10**6,deformation_parameters_maximum=0.5)
```

This sets the number of presampling points to `10**6`

(default: `10**5`

) and the maximum value for the contour deformation parameter `deformation_parameters_maximum`

to `0.5`

(default: `1`

). The user should make sure that deformation parameters maximum is always larger than deformation_parameters_minimum (default: `1e-5`

). These parameters are described in `IntegralLibrary`

.

## 6.5. What can I do if the program stops with an error message containing sign_check_error?¶

This error occurs if the contour deformation leads to a wrong sign of the Feynman prescription, usually due to the fact that the deformation parameter is too large.
If this error is encountered the program will automatically reduce and re-attempt integration. If the code continues after the error and eventually returns a result then it successfully adjusted the contour and the error can be ignored. To avoid this error in the first place choose a larger value for `number_of_presamples`

and a smaller value (e.g. `0.5`

) for `deformation_parameters_maximum`

(see item above). If that does not help, you can try `0.1`

instead of `0.5`

for `deformation_parameters_maximum`

. The relevant parameters are described in `IntegralLibrary`

.

If the code fails to find a contour it may display the error message `All deformation parameters at minimum already, integral still fails`

and stop. In this case try reducing `deformation_parameters_maximum`

(default: `1e-5`

) to a smaller number. If the code still fails to find a valid contour it may be that your integral has an unavoidable end-point singularity or other numerical problems. Often this error is encountered when the `real_parameters`

and/or `complex_parameters`

are very large/small or if some of the parameters differ from each other by orders of magnitude. If all of the `real_parameters`

or `complex_parameters`

are of a similar size (but not ) then dividing each parameter by e.g. the largest parameter (such that all parameters are ) can help to avoid a situation where extremely small deformation parameters are required to obtain a valid contour. It may then be possible to restore the desired result using dimensional analysis (i.e. multiplying the result by some power of the largest parameter).

If you still encounter an error after following these suggestions, please open an issue.

## 6.6. What does additional_prefactor mean exactly?¶

We should first point out that the conventions for additional prefactors defined by the user have been changed between SecDec 3 and pySecDec. The prefactor specified by the user will now be *included* in the numerical result.

To make clear what is meant by “additional”, we repeat our conventions for Feynman integrals here.

A scalar Feynman graph in dimensions at loops with propagators, where the propagators can have arbitrary, not necessarily integer powers , has the following representation in momentum space:

where the are linear combinations of external momenta and loop momenta .

Introducing Feynman parameters leads to:

The prefactor coming from the Feynman parametrisation will always be included in the numerical result, corresponding to additional_prefactor=1 (default), i.e. the program will return the numerical value for . If the user defines additional_prefactor=’gamma(3-2*eps)’, this prefactor will be expanded in and included in the numerical result returned by pySecDec, in addition to the one coming from the Feynman parametrisation.

For general polynomials not related to loop integrals, i.e. in `make_package`

, the prefactor provided by the user is the only prefactor, as there is no prefactor coming from a Feynman parametrisation in this case. This is the reason why in `make_package`

the keyword for the prefactor defined by the user is `prefactor`

, while in `loop_package`

it is `additional_prefactor`

.

## 6.7. What can I do if I get nan?¶

This means that the integral does not converge which can have several reasons. When Divonne is used as an integrator, it is important to use a non-zero value for border, e.g. `border=1e-8`

. Vegas is in general the most robust integrator. When using Vegas, try to increase the values for `nstart`

and `nincrease`

, for example `nstart=100000`

(default: `10000`

) and `nincrease=50000`

(default: `5000`

).

If the integral is non-Euclidean, make sure that contour_deformation=True is set.
Another reason for getting nan can be that the integral has singularities at and therefore needs usage of the `split`

option, see item below.

## 6.8. What can I use as numerator of a loop integral?¶

The numerator must be a sum of products of numbers, scalar products (e.g. `p1(mu)*k1(mu)*p1(nu)*k2(nu)`

and/or symbols (e.g. `m`

). The numerator can also be an inverse propagator.
In addition, the numerator must be finite in the limit . The default numerator is `1`

.

Examples:

```
p1(mu)*k1(mu)*p1(nu)*k2(nu) + 4*s*eps*k1(mu)*k1(mu)
p1(mu)*(k1(mu) + k2(mu))*p1(nu)*k2(nu)
p1(mu)*k1(mu)
```

More details can be found in `LoopIntegralFromPropagators`

.

## 6.9. How can I integrate just one coefficient of a particular order in the regulator?¶

You can pick a certain order in the C++ interface (see C++ Interface (advanced)). To integrate only one order, for example the finite part, change the line:

```
const box1L::nested_series_t<secdecutil::UncorrelatedDeviation<box1L::integrand_return_t>> result_all = secdecutil::deep_apply( all_sectors, integrator.integrate );
```

to:

```
int order = 0; // compute finite part only
const secdecutil::UncorrelatedDeviation<box1L::integrand_return_t> result_order = secdecutil::deep_apply(all_sectors.at(order), integrator.integrate );
```

where `box1L`

is to be replaced by the name of your integral. In addition, you should change the lines:

```
std::cout << "-- integral without prefactor -- " << std::endl;
std::cout << result_all << std::endl << std::endl;
```

to:

```
std::cout << "-- integral without prefactor -- " << std::endl;
std::cout << result_order << std::endl << std::endl;
```

and remove the lines:

```
std::cout << "-- prefactor -- " << std::endl;
const box1L::nested_series_t<box1L::integrand_return_t> prefactor = box1L::prefactor(real_parameters, complex_parameters);
std::cout << prefactor << std::endl << std::endl;
std::cout << "-- full result (prefactor*integral) -- " << std::endl;
std::cout << prefactor*result_all << std::endl;
```

because the expansion of the prefactor will in general mix with the pole coefficients and thus affect the finite part. We should point out however that deleting these lines also means that the result will not contain any prefactor, not even the one coming from the Feynman parametrisation.

## 6.10. How can I use complex masses?¶

In the python script generating the expressions for the integral, define mass symbols in the same way as for real masses, e.g:

```
Mandelstam_symbols=['s']
mass_symbols=['msq']
```

Then, in `loop_package`

define:

```
real parameters = Mandelstam_symbols,
complex parameters = mass_symbols,
```

In the integration script (using the python interface), the numerical values for the complex parameters are given after the ones for the real parameters:

```
str_integral_without_prefactor, str_prefactor, str_integral_with_prefactor = integral(real_parameters=[4.],complex_parameters=[1.-0.0038j])
```

Note that in python the letter `j`

is used rather than `i`

for the imaginary part.

In the C++ interface, you can set (for the example triangle2L):

```
const std::vector<triangle2L::real_t> real_parameters = { 4. };
const std::vector<triangle2L::complex_t> complex_parameters = { {1.,0.0038} };
```

## 6.11. When should I use the “split” option?¶

The modules `loop_package`

and `make_package`

have the option to split the integration domain (`split=True`

). This option can be useful for integrals which do not have a Euclidean region. If certain kinematic conditions are fulfilled, for example if the integral contains massive on-shell lines, it can happen that singularities at remain in the polynomial after the decomposition. The split option remaps these singularities to the origin of parameter space. If your integral is of this type, and with the standard approach the numerical integration does not seem to converge, try the `split`

option. It produces a lot more sectors, so it should not be used without need. We also would like to mention that very often a change of basis to increase the (negative) power of the polynomial can be beneficial if integrals of this type occur in the calculation.

## 6.12. How can I obtain results from pySecDec in a format convenient for GiNaC/ Sympy/ Mathematica/ Maple?¶

If you are using the python interface, you can use the functions `series_to_ginac`

, `series_to_sympy`

, `series_to_mathematica`

, `series_to_maple`

to convert the output of the integral library.

Example:

```
#!/usr/bin/env python3
from pySecDec.integral_interface import IntegralLibrary
from pySecDec.integral_interface import series_to_ginac, series_to_sympy, series_to_mathematica, series_to_maple
if __name__ == "__main__":
# load c++ library
easy = IntegralLibrary('easy/easy_pylink.so')
# integrate
_, _, result = easy()
# print result
print(series_to_ginac(result))
print(series_to_sympy(result))
print(series_to_mathematica(result))
print(series_to_maple(result))
```

Outputs:

```
('(1+0*I)/eps + (0.306852819440052549+0*I) + Order(eps)', '(5.41537065611170534e-17+0*I)/eps + (1.3864926114078559e-15+0*I) + Order(eps)')
('(1+0*I)/eps + (0.306852819440052549+0*I) + O(eps)', '(5.41537065611170534e-17+0*I)/eps + (1.3864926114078559e-15+0*I) + O(eps)')
('(1+0*I)/eps + (0.306852819440052549+0*I) + O[eps]', '(5.41537065611170534*10^-17+0*I)/eps + (1.3864926114078559*10^-15+0*I) + O[eps]')
('(1+0*I)/eps + (0.306852819440052549+0*I) + O(eps)', '(5.41537065611170534e-17+0*I)/eps + (1.3864926114078559e-15+0*I) + O(eps)')
```

## 6.13. Expansion by regions: what does the parameter `z`

mean?¶

When expansion by regions via the “rescaling with z-method” is used, the parameter `z`

acts as expansion parameter in the Taylor expansion of the integrand. After the code generation step, in the numerical integration, `z=1`

needs to be used and the kinematic invariants have to be set to the same values as would be used with the t-method, i.e. the kinematic values desired by the user.

## 6.14. Expansion by regions: why does the t-method not converge?¶

With the t-method, configurations can occur for particular kinematic points which, after sector decomposition, lead to a pole at the upper integration boundary, where the contour deformation vanishes and therefore cannot regulate this pole. In such a case the z-method should be used, because it does not transform the Feynman parameters in a way which can induce such a configuration.