// d01bd Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class D01BDE { public static double pi = 0.0; public static int kount = 0; static void Main(String[] args) { StartExample(); } public static void StartExample() { try { D01.D01BD_F fD01BD = new D01.D01BD_F(f); double a, abserr, b, epsabs, epsrel, result; int ifail; Console.WriteLine("d01bd Example Program Results"); // pi = Math.PI; epsabs = 0.00e0; epsrel = 1.00e-04; a = 0.00e0; b = 1.00e0; kount = 0; // D01.d01bd(fD01BD, a, b, epsabs, epsrel, out result, out abserr, out ifail); // Console.WriteLine(""); Console.WriteLine(" {0}{1,10:f4}", "a - lower limit of integration = ", a); Console.WriteLine(" {0}{1,10:f4}", "b - upper limit of integration = ", b); Console.WriteLine(" {0}{1,9:e2}", "epsabs - absolute accuracy requested = ", epsabs); Console.WriteLine(" {0}{1,9:e2}", "epsrel - relative accuracy requested = ", epsrel); Console.WriteLine(""); Console.WriteLine(" {0}{1,9:f5}", "result - approximation to the integral = ", result); Console.WriteLine(" {0}{1,9:e2}", "abserr - estimate to the absolute error = ", abserr); Console.WriteLine(" {0}{1,4}", "kount - number of function evaluations = ", kount); Console.WriteLine(""); if ((kount > 87) || (abserr > Math.Max(epsabs, epsrel * Math.Abs(result)))) { Console.WriteLine(" {0}", "Warning - requested accuracy may not have been achieved"); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } ; } // // public static double f(double x) { double fValue; kount = kount + 1; fValue = ((x) * (x)) * Math.Sin(10.00e0 * pi * x); return fValue; } } }