// c05av Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class C05AVE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { double boundl, boundu, fx, h, x, y; int ind; double[] c = new double[11]; int ifail; Console.WriteLine("c05av Example Program Results"); Console.WriteLine(""); x = 3.00e0; h = 0.10e0; boundl = 0.00e0; boundu = 4.00e0; fx = 0.0; y = 0.0; ind = 1; // do { C05.c05av(ref x, fx, ref h, boundl, boundu, ref y, c, ref ind, out ifail); // fx = x * x - 3.00e0 * x + 2.00e0; } while (ind != 0); if (ifail == 0) { Console.WriteLine(" {0}","Interval containing root is [X,Y], where"); Console.WriteLine(" {0}{1,12:f4}{2}{3,12:f4}","x =",x," y =",y); Console.WriteLine(" {0}","Values of f at x and y are"); Console.WriteLine(" {0}{1,12:f2}{2}{3,12:f2}","f(x) =",fx," f(y) =",c[0]); } else { Console.WriteLine(""); Console.WriteLine("** c05av failed with ifail = {0,5}", ifail); } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } Console.WriteLine(""); } } }