Example 1: Minimum of a smooth function

The minimum of e^x - 5x is found using function evaluations only.
import com.imsl.math.*;

public class MinUnconEx1 {
    public static void main(String args[]) {
        MinUncon zf = new MinUncon();
        zf.setGuess(0.0);
        zf.setAccuracy(0.001);
        MinUncon.Function fcn = new MinUncon.Function() {
            public double f(double x) {
                return Math.exp(x) - 5.*x;
            }
        };
        System.out.println("Minimum is " + zf.computeMin(fcn));
    }
}

Output

Minimum is 1.6094175999200253
Link to Java source.