Example 2: Minimum of a smooth function

The minimum of e^x - 5x is found using function evaluations and first derivative evaluations.
using System;
using Imsl.Math;

public class MinUnconEx2 : MinUncon.IDerivative
{
    public double F(double x)
    {
        return Math.Exp(x) - 5.0 * x;
    }
    
    public double Derivative(double x)
    {
        return Math.Exp(x) - 5.0;
    }
    

    public static void  Main(String[] args)
    {
        MinUncon zf = new MinUncon();
        zf.Guess = 0.0;
        zf.Accuracy = .001;
        double x = zf.ComputeMin(new MinUnconEx2());
        Console.Out.WriteLine("x = " + x);
    }
}

Output

x = 1.61001131622703

Link to C# source.