PDA

View Full Version : Quadrature integration--> two variable function



yamid
08-29-2010, 12:33 PM
Hi Guys,
I have got a problem with using integration in Quadrature method.
Actually I need to pass two variables to the "Function"F(double x) . For example I want F to accept two variables (x,y) instead of just x. The variable Y is defined under the "main" method.
How can I modify the code below?
needed: public double F(double x, double y)


thanks

-------------------------------------------------------------------------


using System;
using Imsl.Math;
public class QuadratureEx2 : Quadrature.IFunction
{
public double F(double x)
{
return Math.Exp(- x);
}
public static void Main(String[] args)
{
Quadrature q = new Quadrature();
Quadrature.IFunction fcn = new QuadratureEx2();
double result = q.Eval(fcn, 0.0, Double.PositiveInfinity);
double expect = 1.0;
Console.Out.WriteLine("result = " + result);
Console.Out.WriteLine("expect = " + expect);
}
}

Richard Hanson
08-30-2010, 01:03 PM
There is a way to do this within the C# framework. It is awkward but workable. First, please state a sample two-dimensional integral you would like to evaluate. The recommendation for what to use will depend on the integrand function and the shape of the integration domain.

There is a 2D integration routine being added to Fortran Numerical Library, Version 7. There is no schedule for adding this algorithm to C# at present.

Regards,