9. Nonlinear Optimization (Single Variable)
Note – This document was created using AI translation.
9.1 Overview
This section addresses the problem of finding the minimum point of a single-variable nonlinear function (or, by reversing the sign, the maximum point):
min f(x)
We assume the target region contains only one minimum point, meaning the method focuses solely on the vicinity of that specific minimum. This is referred to as local optimization or local minimization.
9.2 Methods for Nonlinear Optimization (Single Variable)
9.2.1 Golden Section Search
Initial values a and b are provided, with function values f(a) and f(b). The interval [a, b] must contain exactly one minimum point.
r = (√5 – 1)/2 (approximately 0.618) is known as the golden ratio’s reciprocal, satisfying the equation r^2 = 1 – r.
We define points c and d as:
c = a + (b - a)(1 - r) d = a + (b - a)r
Then, function values f(c) and f(d) are computed.
– If f(c) < f(d), then d is set as the new b, reducing the interval size. The new interval width becomes (previous interval width) x r, with updated c and d:
New c: (New interval width) x (1 – r) = (Previous interval width) x (1 – r)r New d: (New interval width) x r = (Previous interval width) x r^2 = (Previous interval width) x (1 – r)
Since new d coincides with previous c, only the function value at new c needs to be computed.
– If f(c) > f(d), then c is set as the new a, similarly reducing the interval width and requiring only the function value at new d.
This process repeats until the interval width becomes sufficiently small.
This method is called the golden section search. Each iteration shrinks the interval width by approximately 0.618, making convergence slightly slower than bisection method for nonlinear equations (which shrinks by 0.5).
9.3 Solving Nonlinear Optimization for Single-Variable Functions Using XLPack
The VBA subroutine Dfmin finds a minimum point faster than golden-section search when given an interval containing the minimum. Similar to Dfzero (for nonlinear equations), Dfmin combines interpolation with optimization to achieve faster convergence. Dfmin can also be accessed through the XLPack solver.
Example Problem
Find the local minimum near x = 1 for the following function:
f(x) = x3 - 2x - 5
The function’s shape is shown below. Although the function diverges to negative infinity globally, there is a local minimum near x = 1.
9.3.1 Solving Using VBA Program (1)
Below is an example VBA program using Dfmin.
Function F(X As Double) As Double
F = X ^ 3 - 2 * X - 5
End Function
Sub Start()
Dim Ax As Double, Bx As Double, Tol As Double, X As Double
'--- Input data
Ax = 0
Bx = 1.5
Tol = 0.000000000000001 '1e-15
'--- Compute min. point of equation
Call Dfmin(Ax, Bx, AddressOf F, Tol, X)
'--- Output min. point
MsgBox X
End Sub
Dfmin assumes that exactly one local minimum exists within the interval [Ax, Bx] and seeks to find it. Since the minimum is near x = 1, we set Ax = 0 and Bx = 1.5.
Executing this program finds X = 0.81650.
9.3.2 Solving Using VBA Program (2)
Below is an example using Dfmin_r, the reverse communication version (RCI).
Sub Start()
Dim Ax As Double, Bx As Double, Tol As Double, X As Double
Dim XX As Double, YY As Double, IRev As Long
'--- Input data
Ax = 0
Bx = 1.5
Tol = 0.000000000000001 '1e-15
'--- Compute min. point of equation
IRev = 0
Do
Call Dfmin_r(Ax, Bx, Tol, XX, YY, IRev)
If IRev <> 0 Then YY = XX ^ 3 - 2 * XX - 5
Loop While IRev <> 0
X = XX
'--- Output min. point
MsgBox X
End Sub
Instead of using an external function, this version directly computes values when IRev = 1, assigns them to YY, and re-calls Dfmin_r. More details on RCI are available here.
Running this program produces the same results.
9.3.3 Solving Using the Solver
The XLPack Solver Add-in can also solve the optimization problem using the “Univariate Nonlinear Optimization” function. The formula (=B6^3-2*B6-5) is entered in cell B7.
For more information about the solver, refer to this link.