Skip to content

Commit

Permalink
Fix solution to heat equation
Browse files Browse the repository at this point in the history
  • Loading branch information
Songtech-0912 committed Oct 25, 2023
1 parent ab798ae commit e2b3bd3
Showing 1 changed file with 96 additions and 20 deletions.
116 changes: 96 additions & 20 deletions book/knowledge-library/differential-equations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"id": "3742fdae",
"metadata": {},
"source": [
"Differential equations are simultaneously often regarded as some of the coolest and strangest objects in physics. On one hand, they're ubiquitous, and nearly every physics theory is expressed using them. On the other, they have a tendency to be considered unsolvable and difficult to understand. It is hoped that this chapter will bring all their positive qualities into the limelight, and make differential equations no longer scary or intimidating, but descriptions of nature unrivaled in their beauty."
"Differential equations are simultaneously often regarded as some of the coolest and strangest objects in physics. On one hand, they're ubiquitous, and nearly every physics theory is expressed using them. On the other, they have a tendency to be unsolvable and difficult to understand. It is hoped that this chapter will bring all their positive qualities into the limelight, and make differential equations no longer scary or intimidating, but descriptions of nature unrivaled in their beauty."
]
},
{
Expand All @@ -39,7 +39,7 @@
"id": "0b34e032",
"metadata": {},
"source": [
"Differential equations are any equations that involve a function and its derivatives. For instance, we could have:"
"Differential equations are any equations that describe a function in terms of how it changes through space or time. For instance, we could have:"
]
},
{
Expand Down Expand Up @@ -504,10 +504,18 @@
"metadata": {},
"source": [
"$$\n",
"\\frac{g'}{g \\alpha^2} = \\frac{f''}{f} = \\lambda\n",
"\\frac{g'}{g \\alpha^2} = \\frac{f''}{f} = -\\lambda\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "a466a55f",
"metadata": {},
"source": [
"Why the negative sign? Since a negative sign applied to a constant makes it still a constant, so we can technically do what we want to $\\lambda$ - scale it, add another constant to it, make it positive or negative, the math still works out. The only difference is that $-\\lambda$ makes the resulting differential equations way easier to solve, which is why we're adding a negative sign."
]
},
{
"cell_type": "markdown",
"id": "2966a062",
Expand All @@ -522,11 +530,11 @@
"metadata": {},
"source": [
"$$\n",
"g' = \\lambda \\alpha^2 g \n",
"g' = -\\lambda \\alpha^2 g \n",
"$$ \n",
"\n",
"$$\n",
"f'' = \\lambda f\n",
"f'' = -\\lambda f\n",
"$$"
]
},
Expand All @@ -544,7 +552,7 @@
"metadata": {},
"source": [
"$$\n",
"g(t) = C_1 e^{\\lambda a^2 t}\n",
"g(t) = C_1 e^{-\\lambda a^2 t}\n",
"$$"
]
},
Expand All @@ -553,7 +561,7 @@
"id": "8fae18b0",
"metadata": {},
"source": [
"The second equation requires a little bit more work. Which functions are proportional to their second derivative? On inspection, the function $e^x$ would work:"
"The second equation requires a little bit more work. Which functions are equal to negative of their second derivative? On inspection, we can guess that the function $\\sin x$ would work, and indeed it does work when we compute its second derivative:"
]
},
{
Expand All @@ -562,7 +570,7 @@
"metadata": {},
"source": [
"$$\n",
"\\frac{d^2}{dx^2} e^x = e^x\n",
"\\frac{d^2}{dx^2} \\sin x = -\\sin x\n",
"$$"
]
},
Expand All @@ -571,7 +579,7 @@
"id": "cec4218f",
"metadata": {},
"source": [
"However, we want the second derivative to not be equal to the function, but **proportional** to it. Thus, perhaps a good guess would be $e^{\\lambda x}$. But note that:"
"However, we want the second derivative to not be equal to the function, but **proportional** to it. Thus, perhaps a good guess would be $\\sin(\\lambda x)$. But note that:"
]
},
{
Expand All @@ -580,7 +588,7 @@
"metadata": {},
"source": [
"$$\n",
"\\frac{d^2}{dx^2} e^{\\lambda x} = \\lambda^2 e^{\\lambda x}\n",
"\\frac{d^2}{dx^2} \\sin(\\lambda x) = -\\lambda^2 \\sin(\\lambda x)\n",
"$$"
]
},
Expand All @@ -598,16 +606,16 @@
"metadata": {},
"source": [
"$$\n",
"\\frac{d^2}{dx^2} e^{\\sqrt{\\lambda}x} = \\lambda e^{\\sqrt{\\lambda}x}\n",
"\\frac{d^2}{dx^2} \\sin(\\sqrt{\\lambda} x) = - \\lambda \\sin(\\sqrt{\\lambda} x)\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "8b9655ee",
"id": "10e08f05",
"metadata": {},
"source": [
"So we have solved our second differential equation:"
"To make this equation more general, since multiplying by a constant does not affect proportionality, we can scale $\\sin(\\sqrt{\\lambda} x)$ by an arbitrary constant $C_2$. So we have solved our second differential equation:"
]
},
{
Expand All @@ -616,7 +624,7 @@
"metadata": {},
"source": [
"$$\n",
"f(x) = e^{\\sqrt{\\lambda}x}\n",
"f(x) = C_2 \\sin(\\sqrt{\\lambda} x)\n",
"$$"
]
},
Expand All @@ -634,28 +642,36 @@
"metadata": {},
"source": [
"$$\n",
"u(x, t) = f(x) g(t) = C_1 e^{\\sqrt{\\lambda}x} e^{\\lambda \\alpha^2 t}\n",
"u(x, t) = f(x) g(t) = C_2 \\sin(\\sqrt{\\lambda} x) C_1 e^{-\\lambda \\alpha^2 t}\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "b53f3020",
"id": "658133b8",
"metadata": {},
"source": [
"Using the rules of exponents, we can rewrite this as:"
"Since we have two multiplied constants, we can rewrite them as a third constant where $C_3 = C_2 C_1$:"
]
},
{
"cell_type": "markdown",
"id": "584aba82",
"id": "c6a326d5",
"metadata": {},
"source": [
"$$\n",
"u(x, t) = C_1 e^{\\sqrt{\\lambda} x + \\lambda \\alpha^2 t}\n",
"u(x, t) = C_3 \\sin(\\sqrt{\\lambda} x) e^{-\\lambda \\alpha^2 t}\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "0bee7757",
"metadata": {},
"source": [
"This is our general solution of the 1D heat equation!"
]
},
{
"cell_type": "markdown",
"id": "6b9d17ac",
Expand All @@ -664,6 +680,50 @@
"## Laplace and Fourier transforms"
]
},
{
"cell_type": "markdown",
"id": "6c484a16",
"metadata": {},
"source": [
"The next category of methods to solve differential equations involves Laplace and Fourier transforms. These are two transforms that take an expression of one variable to be expressed in terms of a different variable. For a given function $f(t)$, the Laplace transform results in a new function $g(s)$:"
]
},
{
"cell_type": "markdown",
"id": "e1b77fb0",
"metadata": {},
"source": [
"$$\n",
"g(s) = \\int_0^\\infty f(t) e^{-st} dt\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "9d5ff18d",
"metadata": {},
"source": [
"And the Fourier transform also results in a new function $h(s)$:"
]
},
{
"cell_type": "markdown",
"id": "5ced8e24",
"metadata": {},
"source": [
"$$\n",
"h(s) = \\int_{-\\infty}^{\\infty} f(t) e^{-2\\pi i st} dt\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "54b0fe45",
"metadata": {},
"source": [
"The main idea behind these transforms is that they allow ordinary differential equations in terms of $t$ to become algebraic equations in terms of $s$. They also allow partial differential equations in terms of $t$ to become algebraic or ordinary differential equations in terms of $s$. Then, the unknown function can be algebraically solved for, and an inverse transform can be taken to find the solution in terms of $t$."
]
},
{
"cell_type": "markdown",
"id": "7897c99c",
Expand Down Expand Up @@ -697,7 +757,7 @@
"id": "3e111d08",
"metadata": {},
"source": [
"The \"guess and check\" approach, also known as the \"method of inspired guessing\", is literally that - given knowledge of functions and their derivatives, guess an solution to the differential equation. For instance, suppose we had the differential equation:"
"The \"guess and check\" approach, also known as the \"method of inspired guessing\", is literally that - given knowledge of functions and their derivatives, guess a solution to the differential equation. For instance, suppose we had the differential equation:"
]
},
{
Expand Down Expand Up @@ -877,6 +937,22 @@
"source": [
"This method is tedious to do by hand, but computers can do it very quickly. More accurate types of numerical methods, including the very popular Runge-Kutta methods, are similar in nature, only they break each step into smaller steps for more precision."
]
},
{
"cell_type": "markdown",
"id": "446761aa",
"metadata": {},
"source": [
"## Summary of Differential Equations"
]
},
{
"cell_type": "markdown",
"id": "eb65dad8",
"metadata": {},
"source": [
"The great paradox of differential equations is that they can be ridiculously easy to solve, or ridiculously hard to solve. Using just pen-and-paper techniques, differential equations require lots of creativity and imaginative approaches to be solved, and often require simplifying the problem or special cases of problems. But with brute-force computer solving, differential equations can be simplified into much easier problems, albeit problems that require a lot of steps and computing power. In Project Elära, the majority of differential equation solving will be done numerically, but knowing the analytic techniques will certainly be helpful as well. That said, enough on differential equations - let's get back into physics!"
]
}
],
"metadata": {
Expand Down

0 comments on commit e2b3bd3

Please sign in to comment.