// d01fc Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class D01FCE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { const int ndim = 4; const int maxpts = 1000 * ndim; D01.D01FC_FUNCTN functnD01FC = new D01.D01FC_FUNCTN(functn); double acc, eps, finval; int minpts; double[] a = new double[ndim]; double[] b = new double[ndim]; int ifail; Console.WriteLine("d01fc Example Program Results"); for (int k = 1; k <= ndim; k++) { a[k - 1] = 0.00e0; b[k - 1] = 1.00e0; } eps = 0.00010e0; minpts = 0; // D01.d01fc(ndim, a, b, ref minpts, maxpts, functnD01FC, eps, out acc, out finval, out ifail); // Console.WriteLine(""); if (ifail >= 0) { if (ifail > 0) { Console.WriteLine(" {0}{1,5}", "ifail =", ifail); Console.WriteLine(""); } if ((ifail == 0) || (ifail >= (2))) { Console.WriteLine(" {0}{1,12:e2}", "Requested accuracy = ", eps); Console.WriteLine(" {0}{1,12:f4}", "Estimated value = ", finval); Console.WriteLine(" {0}{1,12:e2}", "Estimated accuracy = ", acc); } } else { Console.WriteLine("** d01fc failed with ifail = {0,5}", ifail); } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } ; } // public static double functn(int ndim, double[] z) { double functnValue = 0.0; functnValue = 4.00e0 * z[0] * z[2] * z[2] * Math.Exp(2.00e0 * z[0] * z[2]) / ((1.00e0 + z[1] + z[3]) * (1.00e0 + z[1] + z[3])); return functnValue; } } }