|
9 | 9 | "\n", |
10 | 10 | "An alternative method for finding the minimum of a function is the Newton-Raphson Method (also called Newton's Method).\n", |
11 | 11 | "\n", |
12 | | - "The central idea here is that if we zoom in on any function, then we can approximate the local shape of that function as quadratic, i.e.\n", |
| 12 | + "The key insight is that **at a minimum, the first derivative equals zero**: $f^\\prime(x) = 0$. So finding a minimum is equivalent to finding where the derivative vanishes.\n", |
| 13 | + "\n", |
| 14 | + "The Newton-Raphson method uses the idea that if we zoom in on any function, we can approximate the local shape of that function as quadratic, i.e.\n", |
13 | 15 | "\n", |
14 | 16 | "$$f(x) \\approx ax^2 + bx + c$$\n", |
15 | 17 | "\n", |
16 | 18 | "over some small range of $x$.\n", |
17 | 19 | "\n", |
18 | | - "If $f(x)$ has a minimum, then at that point\n", |
| 20 | + "If $f(x)$ is approximately quadratic near our current position, then its first derivative is approximately **linear**:\n", |
| 21 | + "\n", |
| 22 | + "$$f^\\prime(x) \\approx 2ax + b$$\n", |
19 | 23 | "\n", |
20 | | - "$$f^{\\prime\\prime}(x) = 0$$\n", |
| 24 | + "If we know the coefficients $a$ and $b$, we can directly solve for where this linear approximation crosses zero (i.e., where $f^\\prime(x) = 0$):\n", |
21 | 25 | "\n", |
22 | | - "and, if we know the coefficients $a$ and $b$, then we can directly calculate the value of $x$ that minimises our function.\n", |
| 26 | + "$$2ax + b = 0$$\n", |
23 | 27 | "\n", |
24 | | - "$$f^{\\prime\\prime}(x) = 2ax + b = 0$$\n", |
| 28 | + "$$x = \\frac{-b}{2a}$$\n", |
25 | 29 | "\n", |
26 | | - "$$x = \\frac{-b}{2a}$$\n" |
| 30 | + "This gives us our predicted location of the minimum.\n" |
27 | 31 | ] |
28 | 32 | }, |
29 | 33 | { |
30 | 34 | "cell_type": "markdown", |
31 | 35 | "id": "641bab47-12b3-485d-afcb-4d25ad60030f", |
32 | 36 | "metadata": {}, |
33 | 37 | "source": [ |
34 | | - "To find the value of the coefficients $a$ and $b$, we use the property that any function can be expanded as a **Taylor series**\n", |
35 | | - "(see, e.g., Chapter 6 in [Foundations of Science Mathematics](https://bath.primo.exlibrisgroup.com/permalink/44BAT_INST/iac705/alma991004175199902761)).\n", |
| 38 | + "To find the coefficients $a$ and $b$ of our local quadratic approximation, we use the property that any smooth function can be expanded as a **Taylor series** (see, e.g., Chapter 6 in [Foundations of Science Mathematics](https://bath.primo.exlibrisgroup.com/permalink/44BAT_INST/iac705/alma991004175199902761)).\n", |
36 | 39 | "\n", |
37 | 40 | "If we are at some point $x_0$, then we can approximate our function locally as a polynomial in $(x-x_0)$:\n", |
38 | 41 | "\n", |
39 | 42 | "$$f(x) = f(x_0) + f^\\prime(x_0)(x-x_0) + \\frac{1}{2}f^{\\prime\\prime}(x_0)(x-x_0)^2 + \\ldots$$\n", |
40 | 43 | "\n", |
41 | | - "And, if we remain close to $x_0$, where the higher order terms in $(x-x_0)$ are small, we have the approximation that \n", |
| 44 | + "If we remain close to $x_0$, where the higher-order terms in $(x-x_0)$ are small, we can truncate this series after the quadratic term:\n", |
42 | 45 | "\n", |
43 | 46 | "$$f(x) \\approx f(x_0) + f^\\prime(x_0)(x-x_0) + \\frac{1}{2}f^{\\prime\\prime}(x_0)(x-x_0)^2$$\n", |
44 | 47 | "\n", |
45 | | - "i.e., we approximate $f(x)$ as quadratic.\n", |
| 48 | + "This is our quadratic approximation. Differentiating this expression with respect to $x$ gives us the approximation for the first derivative:\n", |
46 | 49 | "\n", |
47 | | - "Differentiating this approximate expression with respect to $x$gives:\n", |
| 50 | + "$$f^\\prime(x) \\approx f^\\prime(x_0) + f^{\\prime\\prime}(x_0)(x - x_0)$$\n", |
48 | 51 | "\n", |
49 | | - "$$f^\\prime(x) = f^\\prime + f^{\\prime\\prime}(x - x_0) = 0$$\n", |
| 52 | + "At a minimum, $f^\\prime(x) = 0$, so we can set this expression to zero and solve for $x$:\n", |
50 | 53 | "\n", |
51 | | - "and setting this to zero allows us to solve for $x$:\n", |
| 54 | + "$$f^\\prime(x_0) + f^{\\prime\\prime}(x_0)(x - x_0) = 0$$\n", |
52 | 55 | "\n", |
53 | | - "$$x = x_0 - \\frac{f^\\prime(x_0)}{f^{\\prime\\prime}(x_0)}$$" |
54 | | - ] |
55 | | - }, |
56 | | - { |
57 | | - "cell_type": "markdown", |
58 | | - "id": "4c58aee1-7acf-4ac2-a237-a8f77cf57138", |
59 | | - "metadata": {}, |
60 | | - "source": [ |
61 | | - "In the context of finding the minimum of a potential energy surface, this looks like:\n", |
| 56 | + "$$x = x_0 - \\frac{f^\\prime(x_0)}{f^{\\prime\\prime}(x_0)}$$\n", |
| 57 | + "\n", |
| 58 | + "This is the **Newton-Raphson equation**. Starting from our current position $x_0$, it predicts a new position $x$ that should be closer to the minimum.\n", |
| 59 | + "\n", |
| 60 | + "In the context of finding the minimum of a potential energy surface, we can rewrite this using our usual notation for energy and bond length:\n", |
| 61 | + "\n", |
| 62 | + "1. Starting at an initial guess $r_n$, calculate the first and second derivatives of $U(r_n)$ at that point.\n", |
| 63 | + "2. Use the Newton-Raphson equation to predict a new position:\n", |
| 64 | + "\n", |
| 65 | + "$$r_{n+1} = r_n - \\frac{U^\\prime(r_n)}{U^{\\prime\\prime}(r_n)}$$\n", |
62 | 66 | "\n", |
63 | | - "1. Starting at an initial guess, $r_n$, calculate the first and second derivatives of $U(r_n)$ at that point.\n", |
64 | | - "2. Use the Newton-Raphson equation $r_{n+1} = r_n - U^\\prime(r_n) / U^{\\prime\\prime}(r_n)$ to predict the position of the minimum.\n", |
65 | | - " \n", |
66 | | - "In reality, our potential energy surface is never exactly quadratic (except for the special case of a harmonic potential), so step 2. only gives us an approximate **guess** for the minimum position. We then repeat steps 1. and 2. as an iterative process, until we (hopefully) converge on the energy minimum." |
| 67 | + "In reality, our potential energy surface is never exactly quadratic (except for the special case of a harmonic potential), so this equation only gives us an approximate guess for the minimum position. We therefore repeat steps 1 and 2 as an iterative process, recalculating the derivatives at each new position, until we (hopefully) converge on the energy minimum." |
67 | 68 | ] |
68 | 69 | }, |
69 | 70 | { |
|
97 | 98 | "name": "python", |
98 | 99 | "nbconvert_exporter": "python", |
99 | 100 | "pygments_lexer": "ipython3", |
100 | | - "version": "3.11.10" |
| 101 | + "version": "3.12.3" |
101 | 102 | } |
102 | 103 | }, |
103 | 104 | "nbformat": 4, |
|
0 commit comments