// d01ah Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class D01AHE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { D01.D01AH_F fD01AH = new D01.D01AH_F(f); double a, ans, b, epsr, relerr; int nlimit, npts; int ifail; Console.WriteLine("d01ah Example Program Results"); a = 0.00e0; b = 1.00e0; nlimit = 0; epsr = 1.00e-5; ans = D01.d01ah(a, b, epsr, out npts, out relerr, fD01AH, nlimit, out ifail); Console.WriteLine(""); if ((ifail >= 0) && (ifail <= 2)) { Console.WriteLine(" {0}{1,8:f5}", "Integral = ", ans); Console.WriteLine(""); Console.WriteLine(" {0}{1,10:e2}", "Estimated relative error = ", relerr); Console.WriteLine(""); Console.WriteLine(" {0}{1,5}", "Number of function evaluations = ", npts); } else { Console.WriteLine("** d01ah 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; fValue = 4.00e0 / (1.00e0 + x * x); return fValue; } } }