Abstract. The method of one-dimensional optimization is explained in the context of capillary waves.

1. Introduction.

R provides functions for both one-dimensional and multi-dimensional optimization. The second topic is much more complicated than the former (see e.g. Nocedal 1999) and will be left for another day.

A convenient function for 1D optimization is optimize(), also known as optimise(). Its first argument is a function whose minimum (or maximum) is sought, and the second is a two-element vector giving the range of values of the independent variable to be searched. (See ?optimize for more.)

2. Application.

As an example, consider the phase speed of deep gravity-capillary waves, which is given by \( \omega/k \) where \( \omega \) is the frequency and \( k \) is the wavenumber, and the two are bound together with the dispersion relationship \( \omega^2=gk+\sigma k^3/\rho \), where \( g \) is the acceleration due to gravity, \( \sigma \) is the surface tension parameter (0.074 N/m for an air-water interface) and \( \rho \) is the water density (1000 kg/m3 for fresh water). This yields wave speed given by the following R function.

phaseSpeed <- function(k) {
    g <- 9.8
    sigma <- 0.074  # water-air
    rho <- 1000  # fresh water
    omega2 <- g * k + sigma * k^3/rho
    sqrt(omega2)/k
}

Readers with a background in the topic of waves may know that there is a minimum phase speed at wavelengths of about 2 cm, or a \( k \) of approximately \( 2\pi/0.02 \) which is about 300. It always makes sense to plot a function to be optimized, if only to check that it has been coded correctly, so that's the next step.

k <- seq(100, 1000, length.out = 100)
par(mar = c(3, 3, 1, 1), mgp = c(2, 0.7, 0))
plot(k, phaseSpeed(k), type = "l", xlab = "Wavenumber", ylab = "Phase speed")

plot of chunk unnamed-chunk-2

The results suggest that the range of \( k \) illustrate contains the minimum, so we provide that to optimize().

o <- optimize(phaseSpeed, range(k))
phaseSpeed(o$minimum)
## [1] 0.2321

This speed is not especially fast; it would take about a heartbeat to move past your hand.

3. Exercises

  1. Use str(o) to learn about the contents of the optimized solution.

  2. Use abline() to indicate the wavenumber at the speed minimum.

  3. Try other functions that are of interest to you.

  4. Use the multi-dimensional optimizer named optim() on this problem.

References

@book{nocedal1999no,
  Address = {New York, NY, USA},
    Author = {Jorge Nocedal and Stephen J. Wright},
    Publisher = {{S}pringer-{V}erlag},
    Series = {Springer series in operations research},
    Title = {Numerical optimization},
    Year = {1999}}