// Collection of code snippets by Arne Vajhøj // posted to eksperten.dk, usenet and other places (2002-now) using System; public class Solv { private const double DELTA = 0.0000001; public delegate double FX(double x); public static double FindZero(FX f) { double x, xnext = 0; do { x = xnext; xnext = x - f(x) / ((f(x + DELTA) - f(x)) / DELTA); } while(Math.Abs(xnext - x) > DELTA); return xnext; } public static void Main(string[] args) { Console.WriteLine(Solv.FindZero((double x) => 1500*Math.Pow(1.05, 2*x) + 3000*Math.Pow(1.05, x) - 6272 )); } }