// d01am Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class D01AME { public static int kount = 0; static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int lw = 800; D01.D01AM_F fD01AM = new D01.D01AM_F(f); double abserr, bound, epsabs, epsrel, result; int inf; double[] w = new double[lw]; int subintvls; int ifail; Console.WriteLine("d01am Example Program Results"); epsabs = 0.00e0; epsrel = 1.00e-04; bound = 0.00e0; inf = 1; kount = 0; // D01.d01am(fD01AM, bound, inf, epsabs, epsrel, out result, out abserr, w, out subintvls, out ifail); // if (ifail >= 0) { Console.WriteLine(""); Console.WriteLine(" {0}{1,10:f4}", "a - lower limit of integration = ", bound); Console.WriteLine(" {0}", "b - upper limit of integration = infinity"); Console.WriteLine(" {0}{1,9:e2}", "epsabs - absolute accuracy requested = ", epsabs); Console.WriteLine(" {0}{1,9:e2}", "epsrel - relative accuracy requested = ", epsrel); Console.WriteLine(""); if (ifail != 0) { Console.WriteLine(" {0}{1,4}", "ifail = ", ifail); } if (ifail <= 5) { Console.WriteLine(" {0}{1,9:f5}", "result - approximation to the integral = ", result); Console.WriteLine(" {0}{1,9:e2}", "abserr - estimate of the absolute error = ", abserr); Console.WriteLine(" {0}{1,4}", "kount - number of function evaluations = ", kount); Console.WriteLine(" {0}{1,4}", "subintvls - number of subintervals used = ", subintvls); } } else { Console.WriteLine(""); Console.WriteLine("** d01am failed with ifail = {0,5}", ifail); } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } ; } // public static double f(double x) { double fValue; kount = kount + 1; fValue = 1.00e0 / ((x + 1.00e0) * Math.Sqrt(x)); return fValue; } } }