public static double Multivariate(double x, int p)
{
if (p < 1)
throw new ArgumentOutOfRangeException("p",
"Parameter p must be higher than 1.");
if (p == 1)
return Function(x);
double prod = Math.Pow(Math.PI, (1 / 4.0) * p * (p - 1));
for (int i = 0; i < p; i++)
prod *= Function(x - 0.5 * i);
return prod;
}