Skip to content
LeetQuant
F1 Mathematical Reasoning and Calculus

F1 · Mathematical Reasoning and Calculus · Lesson 3 of 6

Derivatives and Optimisation in One Variable

The differentiation rules you need, the first- and second-derivative tests, and full optimisation problems of the kind that appear in betting and portfolio questions.

15 min

The rules

A derivative is a local rate of change: f′(x)=lim⁡h→0f(x+h)−f(x)hf'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}. In practice you compute it from a short list of facts:

(xn)′=nxn−1,(eax)′=aeax,(ln⁡x)′=1x,(ax)′=axln⁡a,(x^n)' = nx^{n-1}, \quad (e^{ax})' = ae^{ax}, \quad (\ln x)' = \frac1x, \quad (a^x)' = a^x\ln a, (fg)′=f′g+fg′,(fg)′=f′g−fg′g2,f(g(x))′=f′(g(x)) g′(x).(fg)' = f'g + fg', \qquad \left(\frac fg\right)' = \frac{f'g - fg'}{g^2}, \qquad f(g(x))' = f'(g(x))\,g'(x) .

Logarithmic differentiation handles variable exponents. For y=xxy = x^x, take logs: ln⁡y=xln⁡x\ln y = x\ln x, so y′/y=ln⁡x+1y'/y = \ln x + 1 and y′=xx(ln⁡x+1)y' = x^x(\ln x + 1).

Finding and classifying extrema

  1. Candidates. Interior critical points, where f′(x)=0f'(x) = 0 or f′f' does not exist, plus the endpoints of the domain.
  2. First-derivative test. If f′f' changes from ++ to −- at x0x_0, it is a local maximum; from −- to ++, a local minimum; no sign change, neither.
  3. Second-derivative test. If f′(x0)=0f'(x_0) = 0 and f′′(x0)<0f''(x_0) < 0, local maximum; f′′(x0)>0f''(x_0) > 0, local minimum; f′′(x0)=0f''(x_0) = 0, the test says nothing (x3x^3, x4x^4 and −x4-x^4 all have f′=f′′=0f' = f'' = 0 at 0).
  4. Global answer. Compare the values at all candidates. If ff is concave on an interval (f′′≤0f'' \le 0), any critical point is the global maximum there, which is the usual shortcut.

Concavity is the property to look for. Log-utility, expected growth rates and −-variance are all concave in the decision variable, so setting the derivative to zero gives the answer directly.

Worked example

which is bigger, e^π or π^e?

Decide, without a calculator, whether eπe^\pi or πe\pi^e is larger.

Show solution

Take logs and divide by eπe\pi: eπ>πe  ⟺  πln⁡e>eln⁡π  ⟺  ln⁡ee>ln⁡ππe^\pi > \pi^e \iff \pi\ln e > e\ln\pi \iff \frac{\ln e}{e} > \frac{\ln \pi}{\pi}. So compare g(x)=ln⁡xxg(x) = \frac{\ln x}{x} at x=ex = e and x=πx = \pi.

g′(x)=1−ln⁡xx2,g'(x) = \frac{1 - \ln x}{x^2},

which is positive for x<ex < e, zero at x=ex = e and negative for x>ex > e. So gg has its global maximum on (0,∞)(0, \infty) at x=ex = e, and g(e)>g(π)g(e) > g(\pi). Therefore eπ>πee^\pi > \pi^e. (Numerically 23.14>22.4623.14 > 22.46.)

The same function answers "which xx maximises x1/xx^{1/x}?" (also ee) and explains why 24=422^4 = 4^2 is the only integer coincidence: the two sides of the peak take each value once.

Worked example

Kelly betting and a minimum-variance portfolio

(a) A coin lands heads with probability p>12p > \tfrac12 and you bet a fraction ff of your wealth at even odds. Find the ff that maximises the expected log growth g(f)=pln⁡(1+f)+qln⁡(1−f)g(f) = p\ln(1 + f) + q\ln(1 - f), q=1−pq = 1 - p, and evaluate it at p=0.55p = 0.55.

(b) Two assets have volatilities 20% and 30% and correlation 0.50.5. Find the weight ww in the first asset (with 1−w1 - w in the second) that minimises portfolio variance.

Show solution

(a) Differentiate:

g′(f)=p1+f−q1−f=0  ⟺  p(1−f)=q(1+f)  ⟺  f∗=p−q.g'(f) = \frac{p}{1 + f} - \frac{q}{1 - f} = 0 \iff p(1 - f) = q(1 + f) \iff f^* = p - q .

g′′(f)=−p(1+f)2−q(1−f)2<0g''(f) = -\frac{p}{(1 + f)^2} - \frac{q}{(1 - f)^2} < 0, so gg is concave and f∗f^* is the global maximum on (−1,1)(-1, 1). At p=0.55p = 0.55, f∗=0.10f^* = 0.10 and the growth rate is 0.55ln⁡1.1+0.45ln⁡0.9=0.0524−0.0474=0.00500.55\ln 1.1 + 0.45\ln 0.9 = 0.0524 - 0.0474 = 0.0050 per bet. Betting double, f=0.2f = 0.2, gives −0.0001-0.0001: over-betting a positive edge loses money in the long run.

(b) With σ1=0.2\sigma_1 = 0.2, σ2=0.3\sigma_2 = 0.3 and covariance ρσ1σ2=0.03\rho\sigma_1\sigma_2 = 0.03,

V(w)=0.04w2+0.09(1−w)2+2(0.03)w(1−w).V(w) = 0.04w^2 + 0.09(1 - w)^2 + 2(0.03)w(1 - w) .

V′(w)=0.08w−0.18(1−w)+0.06(1−2w)=0.14w−0.12V'(w) = 0.08w - 0.18(1 - w) + 0.06(1 - 2w) = 0.14w - 0.12, so w∗=67≈0.857w^* = \tfrac{6}{7} \approx 0.857. V′′(w)=0.14>0V''(w) = 0.14 > 0 confirms a minimum. The minimum variance is V(67)=0.03857V(\tfrac67) = 0.03857, a volatility of 19.6%, slightly below the 20% of the safer asset alone. In general

w∗=σ22−ρσ1σ2σ12+σ22−2ρσ1σ2.w^* = \frac{\sigma_2^2 - \rho\sigma_1\sigma_2}{\sigma_1^2 + \sigma_2^2 - 2\rho\sigma_1\sigma_2} .

Knowledge check

What is the derivative of xxx^x at x=1x = 1?

Knowledge check

Where is the local maximum of f(x)=x3−3xf(x) = x^3 - 3x, and what is its value?

Knowledge check

What is the maximum of xe−xx e^{-x} over x>0x > 0?

Knowledge check

For f(x)=x4f(x) = x^4, f′(0)=f′′(0)=0f'(0) = f''(0) = 0. What is x=0x = 0?

Key takeaways

  • Power, exponential, log, product, quotient and chain rules cover almost everything; use logarithmic differentiation for variable exponents.
  • Candidates for extrema are critical points and endpoints; the second-derivative test classifies them unless f′′=0f'' = 0.
  • Concave objective, interior critical point: global maximum. Look for concavity before doing anything else.
  • ln⁡x/x\ln x / x peaks at ee, so eπ>πee^\pi > \pi^e.
  • Kelly fraction at even odds is p−qp - q; the two-asset minimum-variance weight comes from a single derivative.

Practice problems

Finished reading?

Answer the 4 knowledge checks to complete this lesson (0 done).