// c05az Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class C05AZE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { double fx=0.0, tolx, x, y; int ind; int ir = 0; double[] c = new double[17]; int ifail; Console.WriteLine("c05az Example Program Results"); Console.WriteLine(""); Console.WriteLine(" {0}", " Iterations"); Console.WriteLine(""); tolx = 1.00e-5; x = 0.00e0; y = 1.00e0; ind = 1; // do { C05.c05az(ref x, ref y, fx, tolx, ir, c, ref ind, out ifail); // fx = f(ref x); Console.WriteLine(" {0}{1,8:f5}{2}{3,12:e4}{4}{5,2}", " x =", x, " fx =", fx, " ind =", ind); } while (ind != 0 ); if (ifail == 0) { Console.WriteLine(""); Console.WriteLine(" {0}", " Solution"); Console.WriteLine(""); Console.WriteLine(" {0}{1,8:f5}{2}{3,8:f5}", " x =", x, " y =", y); } else { if (ifail < 0) { Console.WriteLine(""); } Console.WriteLine("** c05az failed with ifail = {0,5}", ifail); if ((ifail == 4) || (ifail == 5)) { Console.WriteLine(" {0}{1,8:f5}{2}{3,8:f5}", "x =", x, " y =", y); } } // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } Console.WriteLine(""); } // public static double f(ref double x) { double fValue; fValue = Math.Exp(-x) - x; return fValue; } } }