public static double Integrate(Func <double, double, double> f, Integral1 integral1, Integral2 integral2) { return(Integration.Integrate(x => Integration.Integrate(y => f(x, y), new Integral1( () => integral2.Lower(x), () => integral2.Upper(x), integral2.Steps)), integral1)); }
public override double IntegratePerimeterCartesian(Func <double, double, double> f, int steps) { Integral1 integral1 = new Integral1(() => 0, () => this.Size, steps); return(Integration.Integrate(x => f(x, 0), integral1) + Integration.Integrate(y => f(this.Size, y), integral1) + Integration.Integrate(x => f(x, this.Size), integral1) + Integration.Integrate(y => f(0, y), integral1)); }
public static double Integrate(Func <double, double, double, double> f, Integral1 integral1, Integral2 integral2, Integral3 integral3) { return(Integration.Integrate( (x, y) => Integration.Integrate(z => f(x, y, z), new Integral1( () => integral3.Lower(x, y), () => integral3.Upper(x, y), integral3.Steps)), integral1, integral2)); }
public static double Integrate(Func <double, double> f, Integral1 integral1) { double lower = integral1.Lower(); double upper = integral1.Upper(); if (lower == upper) { return(0); } double width = (upper - lower) / integral1.Steps; double result = width * (f(lower) + f(upper)) / 2; for (int i = 1; i < integral1.Steps; i++) { result += width * f(lower + (upper - lower) * i / integral1.Steps); } return(result); }
public static double Spherical(Func <double, double, double, double> f, Integral1 integral1, Integral2 integral2, Integral3 integral3) { return(Integration.Integrate((r, theta, phi) => r * r * Math.Sin(theta) * f(r, theta, phi), integral1, integral2, integral3)); }
public static double Cylindrical(Func <double, double, double, double> f, Integral1 integral1, Integral2 integral2, Integral3 integral3) { return(Integration.Integrate((r, theta, z) => r * f(r, theta, z), integral1, integral2, integral3)); }
public static double Polar(Func <double, double, double> f, Integral1 integral1, Integral2 integral2) { return(Integration.Integrate((r, theta) => r * f(r, theta), integral1, integral2)); }