05. Vector Analysis
05. Vector Analysis¶
Learning Objectives¶
- Understand the physical meaning of gradient, divergence, and curl operators and be able to calculate them
- Perform line integrals and surface integrals, and explain the criteria for conservative fields
- State and apply Green's theorem, Stokes' theorem, and the divergence theorem
- Convert Maxwell's equations between integral and differential forms
- Visualize vector fields using Python (SymPy, Matplotlib) and numerically compute line/surface integrals
1. Vector Differential Operators¶
Vector differential operators are essential tools for describing the spatial variation of scalar fields and vector fields. In a 3D Cartesian coordinate system, the nabla operator is defined as:
$$ \nabla = \hat{x}\frac{\partial}{\partial x} + \hat{y}\frac{\partial}{\partial y} + \hat{z}\frac{\partial}{\partial z} $$
1.1 Gradient (โf)¶
The gradient of a scalar field $f(x, y, z)$ is a vector field that indicates the direction and rate at which $f$ increases most rapidly.
$$ \nabla f = \frac{\partial f}{\partial x}\hat{x} + \frac{\partial f}{\partial y}\hat{y} + \frac{\partial f}{\partial z}\hat{z} $$
Physical Meaning: - Direction: the direction of fastest increase of $f$ - Magnitude: the rate of change in that direction (maximum directional derivative) - Always perpendicular to level surfaces
Example: Temperature distribution $T(x, y) = x^2 + y^2$ (2D heat source)
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
from sympy.vector import CoordSys3D
# === SymPy๋ฅผ ์ด์ฉํ ํด์์ gradient ๊ณ์ฐ ===
N = CoordSys3D('N')
x, y, z = sp.symbols('x y z')
# ์ค์นผ๋ผ์ฅ ์ ์
f = x**2 + y**2
# gradient ๊ณ์ฐ
grad_f = sp.diff(f, x)*N.i + sp.diff(f, y)*N.j
print(f"f = {f}")
print(f"โf = {grad_f}") # 2*x*N.i + 2*y*N.j
# === Matplotlib๋ฅผ ์ด์ฉํ ์๊ฐํ ===
X, Y = np.meshgrid(np.linspace(-3, 3, 30), np.linspace(-3, 3, 30))
T = X**2 + Y**2 # ์จ๋ ๋ถํฌ
# gradient ์ฑ๋ถ
dTdx = 2 * X
dTdy = 2 * Y
fig, axes = plt.subplots(1, 2, figsize=(14, 6))
# ๋ฑ๊ณ ์ + gradient ๋ฒกํฐ
ax = axes[0]
contour = ax.contourf(X, Y, T, levels=20, cmap='hot')
ax.quiver(X[::3, ::3], Y[::3, ::3], dTdx[::3, ::3], dTdy[::3, ::3],
color='cyan', alpha=0.8)
plt.colorbar(contour, ax=ax, label='T(x,y)')
ax.set_title('์จ๋ ๋ถํฌ์ gradient ๋ฒกํฐ')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
# gradient ํฌ๊ธฐ
ax = axes[1]
grad_mag = np.sqrt(dTdx**2 + dTdy**2)
im = ax.pcolormesh(X, Y, grad_mag, cmap='viridis', shading='auto')
plt.colorbar(im, ax=ax, label='|โT|')
ax.set_title('gradient ํฌ๊ธฐ (๋ณํ์จ)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
plt.tight_layout()
plt.savefig('gradient_visualization.png', dpi=150, bbox_inches='tight')
plt.show()
1.2 Divergence (โยทF)¶
The divergence of a vector field $\mathbf{F} = F_x\hat{x} + F_y\hat{y} + F_z\hat{z}$ is a scalar quantity representing how much the field "spreads out" at each point.
$$ \nabla \cdot \mathbf{F} = \frac{\partial F_x}{\partial x} + \frac{\partial F_y}{\partial y} + \frac{\partial F_z}{\partial z} $$
Physical Meaning: - $\nabla \cdot \mathbf{F} > 0$: the point is a source โ field spreads outward - $\nabla \cdot \mathbf{F} < 0$: the point is a sink โ field converges inward - $\nabla \cdot \mathbf{F} = 0$: solenoidal โ no creation or annihilation
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
x, y = sp.symbols('x y')
# ์์ฒ์ด ์๋ ๋ฒกํฐ์ฅ: F = (x, y) โ ์์ ์์ ํผ์ ธ๋๊ฐ
Fx_expr = x
Fy_expr = y
div_F = sp.diff(Fx_expr, x) + sp.diff(Fy_expr, y)
print(f"F = ({Fx_expr})xฬ + ({Fy_expr})ลท")
print(f"โยทF = {div_F}") # 2 (ํญ์ ์์ โ ๋ชจ๋ ์ ์ด source)
# ๋น์์ถ ๋ฒกํฐ์ฅ: G = (-y, x) โ ํ์ ๋ง ํ๋ ์ฅ
Gx_expr = -y
Gy_expr = x
div_G = sp.diff(Gx_expr, x) + sp.diff(Gy_expr, y)
print(f"\nG = ({Gx_expr})xฬ + ({Gy_expr})ลท")
print(f"โยทG = {div_G}") # 0 (๋น์์ถ)
# ์๊ฐํ
X, Y = np.meshgrid(np.linspace(-2, 2, 15), np.linspace(-2, 2, 15))
fig, axes = plt.subplots(1, 2, figsize=(14, 6))
# F = (x, y): divergence > 0 (source field)
ax = axes[0]
ax.quiver(X, Y, X, Y, color='red', alpha=0.7)
ax.set_title(f'F = (x, y), โยทF = {div_F} (์์ฒ์ฅ)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.grid(True, alpha=0.3)
# G = (-y, x): divergence = 0 (solenoidal)
ax = axes[1]
ax.quiver(X, Y, -Y, X, color='blue', alpha=0.7)
ax.set_title(f'G = (-y, x), โยทG = {div_G} (๋น์์ถ์ฅ)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('divergence_comparison.png', dpi=150, bbox_inches='tight')
plt.show()
1.3 Curl (โรF)¶
The curl of a vector field $\mathbf{F}$ is a vector field representing the "rotational tendency" and axis of rotation at each point.
$$ \nabla \times \mathbf{F} = \begin{vmatrix} \hat{x} & \hat{y} & \hat{z} \\ \frac{\partial}{\partial x} & \frac{\partial}{\partial y} & \frac{\partial}{\partial z} \\ F_x & F_y & F_z \end{vmatrix} $$
Expanded form:
$$ \nabla \times \mathbf{F} = \left(\frac{\partial F_z}{\partial y} - \frac{\partial F_y}{\partial z}\right)\hat{x} + \left(\frac{\partial F_x}{\partial z} - \frac{\partial F_z}{\partial x}\right)\hat{y} + \left(\frac{\partial F_y}{\partial x} - \frac{\partial F_x}{\partial y}\right)\hat{z} $$
Physical Meaning: - Direction: rotation axis according to the right-hand rule - Magnitude: strength of rotation (circulation per unit area) - $\nabla \times \mathbf{F} = \mathbf{0}$ indicates an irrotational field โ necessary and sufficient condition for a conservative field (in simply connected domains)
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
x, y, z = sp.symbols('x y z')
# 3D ๋ฒกํฐ์ฅ: F = (-y, x, 0) โ z์ถ ๋๋ ํ์
Fx, Fy, Fz = -y, x, sp.Integer(0)
# curl ๊ณ์ฐ
curl_x = sp.diff(Fz, y) - sp.diff(Fy, z)
curl_y = sp.diff(Fx, z) - sp.diff(Fz, x)
curl_z = sp.diff(Fy, x) - sp.diff(Fx, y)
print(f"F = ({Fx})xฬ + ({Fy})ลท + ({Fz})แบ")
print(f"โรF = ({curl_x})xฬ + ({curl_y})ลท + ({curl_z})แบ")
# ๊ฒฐ๊ณผ: (0)xฬ + (0)ลท + (2)แบ โ z ๋ฐฉํฅ์ผ๋ก ๊ท ์ผํ ํ์
# 2D streamplot์ผ๋ก ์๊ฐํ
X, Y = np.meshgrid(np.linspace(-3, 3, 30), np.linspace(-3, 3, 30))
U = -Y # Fx = -y
V = X # Fy = x
speed = np.sqrt(U**2 + V**2)
fig, ax = plt.subplots(figsize=(8, 8))
strm = ax.streamplot(X, Y, U, V, color=speed, cmap='coolwarm',
density=1.5, linewidth=1.5, arrowsize=1.5)
plt.colorbar(strm.lines, ax=ax, label='|F|')
ax.set_title('F = (-y, x): โรF = 2แบ (๊ท ์ผํ ํ์ ์ฅ)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('curl_streamplot.png', dpi=150, bbox_inches='tight')
plt.show()
1.4 Laplacian (โยฒ)¶
The scalar Laplacian is defined as the divergence of the gradient:
$$ \nabla^2 f = \nabla \cdot (\nabla f) = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} + \frac{\partial^2 f}{\partial z^2} $$
The vector Laplacian applies the scalar Laplacian to each component:
$$ \nabla^2 \mathbf{F} = (\nabla^2 F_x)\hat{x} + (\nabla^2 F_y)\hat{y} + (\nabla^2 F_z)\hat{z} $$
Physical Meaning: - Represents the difference between a point's value and the average of its neighborhood - $\nabla^2 f > 0$: neighborhood average is greater than current value (local minimum tendency) - $\nabla^2 f = 0$: harmonic function โ solution to Laplace's equation
import sympy as sp
x, y, z = sp.symbols('x y z')
# ์กฐํํจ์์ธ์ง ํ์ธ: f = 1/r (r = sqrt(x^2 + y^2 + z^2))
r = sp.sqrt(x**2 + y**2 + z**2)
f = 1 / r
laplacian_f = sp.diff(f, x, 2) + sp.diff(f, y, 2) + sp.diff(f, z, 2)
laplacian_f_simplified = sp.simplify(laplacian_f)
print(f"f = 1/r")
print(f"โยฒf = {laplacian_f_simplified}") # 0 (r โ 0์์ ์กฐํํจ์)
# ๋น์กฐํํจ์ ์์: g = x^2 + y^2
g = x**2 + y**2
laplacian_g = sp.diff(g, x, 2) + sp.diff(g, y, 2)
print(f"\ng = {g}")
print(f"โยฒg = {laplacian_g}") # 4 (๋น์กฐํ)
1.5 Vector Identities¶
Important identities frequently used in vector analysis:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Key Vector Identities โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ 1. โร(โf) = 0 curl of gradient is always 0 โ
โ โ conservative fields are always irrotational โ
โ โ
โ 2. โยท(โรF) = 0 divergence of curl is always 0 โ
โ โ magnetic field is always divergence-free (โยทB = 0) โ
โ โ
โ 3. โร(โรF) = โ(โยทF) - โยฒF โ
โ โ curl of curl decomposition (used in EM wave equations) โ
โ โ
โ 4. โยท(fF) = f(โยทF) + Fยท(โf) divergence of product โ
โ 5. โร(fF) = f(โรF) + (โf)รF curl of product โ
โ 6. โ(FยทG) = (Fยทโ)G + (Gยทโ)F + Fร(โรG) + Gร(โรF) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
import sympy as sp
from sympy.vector import CoordSys3D, curl, divergence, gradient
N = CoordSys3D('N')
x, y, z = N.x, N.y, N.z
# ํญ๋ฑ์ 1 ๊ฒ์ฆ: curl(grad(f)) = 0
f = x**2 * y + y**2 * z + z**2 * x
grad_f = gradient(f, N)
curl_grad_f = curl(grad_f, N)
print(f"f = {f}")
print(f"โf = {grad_f}")
print(f"โร(โf) = {curl_grad_f}") # 0
# ํญ๋ฑ์ 2 ๊ฒ์ฆ: div(curl(F)) = 0
F = (x*y*z)*N.i + (x**2 - z)*N.j + (y*z**2)*N.k
curl_F = curl(F, N)
div_curl_F = divergence(curl_F, N)
print(f"\nF = {F}")
print(f"โรF = {curl_F}")
print(f"โยท(โรF) = {sp.simplify(div_curl_F)}") # 0
2. Line Integrals¶
Line integrals integrate scalar or vector fields along curves, computing physical quantities such as work, circulation, and path length.
2.1 Line Integral of a Scalar Field¶
Integrating a scalar field $f$ along curve $C: \mathbf{r}(t) = (x(t), y(t), z(t))$, $a \leq t \leq b$:
$$ \int_C f \, ds = \int_a^b f(\mathbf{r}(t)) \left|\frac{d\mathbf{r}}{dt}\right| dt $$
where $ds = |\mathbf{r}'(t)| \, dt$ is the arc length element.
Applications: mass of a wire with variable density, arc length
import numpy as np
import sympy as sp
t = sp.Symbol('t')
# ์์ : ๋์ ๊ฒฝ๋ก r(t) = (cos t, sin t, t), 0 <= t <= 2pi ์์์
# f = x^2 + y^2 + z^2 ์ ์ ์ ๋ถ
x_t = sp.cos(t)
y_t = sp.sin(t)
z_t = t
f = x_t**2 + y_t**2 + z_t**2 # cosยฒt + sinยฒt + tยฒ = 1 + tยฒ
# dr/dt ๊ณ์ฐ
dx = sp.diff(x_t, t)
dy = sp.diff(y_t, t)
dz = sp.diff(z_t, t)
ds_dt = sp.sqrt(dx**2 + dy**2 + dz**2)
ds_dt_simplified = sp.simplify(ds_dt)
print(f"|dr/dt| = {ds_dt_simplified}") # sqrt(2)
# ์ ์ ๋ถ ๊ณ์ฐ
integrand = f * ds_dt_simplified
result = sp.integrate(integrand, (t, 0, 2*sp.pi))
print(f"โซ_C f ds = {sp.simplify(result)}")
print(f"์์น๊ฐ = {float(result):.4f}")
2.2 Line Integral of a Vector Field (Work)¶
Integrating vector field $\mathbf{F}$ along curve $C$ gives work:
$$ W = \int_C \mathbf{F} \cdot d\mathbf{r} = \int_a^b \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \, dt $$
Component form:
$$ W = \int_C F_x \, dx + F_y \, dy + F_z \, dz $$
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
t = sp.Symbol('t')
# ๋ฒกํฐ์ฅ F = (y, -x) ์์ ์ํ ๊ฒฝ๋ก๋ฅผ ๋ฐ๋ฅธ ์ผ(work) ๊ณ์ฐ
# ๊ฒฝ๋ก: r(t) = (cos t, sin t), 0 <= t <= 2pi
# ๊ฒฝ๋ก ๋งค๊ฐ๋ณ์ํ
x_t = sp.cos(t)
y_t = sp.sin(t)
# ๋ฒกํฐ์ฅ ์ฑ๋ถ (๊ฒฝ๋ก ์)
Fx = y_t # F_x = y = sin t
Fy = -x_t # F_y = -x = -cos t
# dr/dt
dx_dt = sp.diff(x_t, t) # -sin t
dy_dt = sp.diff(y_t, t) # cos t
# F ยท dr/dt
integrand = Fx * dx_dt + Fy * dy_dt
integrand_simplified = sp.simplify(integrand)
print(f"Fยทdr/dt = {integrand_simplified}") # -1
# ์ผ(work) ๊ณ์ฐ
W = sp.integrate(integrand, (t, 0, 2*sp.pi))
print(f"W = โฎ Fยทdr = {W}") # -2*pi (์์: ์ฅ์ด ๊ฒฝ๋ก์ ๋ฐ๋ ๋ฐฉํฅ)
# ์๊ฐํ: ๋ฒกํฐ์ฅ๊ณผ ๊ฒฝ๋ก
theta = np.linspace(0, 2*np.pi, 100)
X, Y = np.meshgrid(np.linspace(-1.5, 1.5, 12), np.linspace(-1.5, 1.5, 12))
fig, ax = plt.subplots(figsize=(8, 8))
ax.quiver(X, Y, Y, -X, color='steelblue', alpha=0.6, label='F = (y, -x)')
ax.plot(np.cos(theta), np.sin(theta), 'r-', linewidth=2, label='๊ฒฝ๋ก C')
ax.annotate('', xy=(0.7, 0.7), xytext=(0.71, 0.69),
arrowprops=dict(arrowstyle='->', color='red', lw=2))
ax.set_title(f'โฎ Fยทdr = {W} (์๊ณ ๋ฐฉํฅ ์ํ)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.legend()
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('line_integral_work.png', dpi=150, bbox_inches='tight')
plt.show()
2.3 Conservative Fields and Potential Functions¶
If vector field $\mathbf{F}$ is a conservative field, the line integral value is path-independent and depends only on endpoints.
$$ \mathbf{F} = \nabla \phi \quad \Longleftrightarrow \quad \int_A^B \mathbf{F} \cdot d\mathbf{r} = \phi(B) - \phi(A) $$
Equivalent conditions for conservative fields (in simply connected domains):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ The following conditions are equivalent (in simply connected): โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ (1) There exists a potential function ฯ such that F = โฯ โ
โ (2) โฎ_C Fยทdr = 0 (for any closed path) โ
โ (3) โซ_A^B Fยทdr is path-independent โ
โ (4) โรF = 0 โ
โ (5) F_x dx + F_y dy + F_z dz is an exact differential โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
import sympy as sp
from sympy.vector import CoordSys3D, curl
N = CoordSys3D('N')
x, y, z = N.x, N.y, N.z
# === ๋ณด์กด์ฅ ํ๋ณ ์์ ===
# F1 = (2xy + z)xฬ + (xยฒ + 2yz)ลท + (x + yยฒ)แบ
F1 = (2*x*y + z)*N.i + (x**2 + 2*y*z)*N.j + (x + y**2)*N.k
curl_F1 = curl(F1, N)
print(f"F1 = {F1}")
print(f"โรF1 = {curl_F1}") # 0 โ ๋ณด์กด์ฅ!
# ํผํ
์
ํจ์ ๊ตฌํ๊ธฐ: โฯ/โx = 2xy + z
phi_x = sp.Symbol('phi')
phi = sp.integrate(2*x*y + z, x) # xยฒy + xz + g(y,z)
print(f"\nโซ (2xy+z)dx = {phi} + g(y,z)")
# g(y,z) ๊ฒฐ์ : โฯ/โy = xยฒ + โg/โy = xยฒ + 2yz โ โg/โy = 2yz
g = sp.integrate(2*y*z, y) # yยฒz + h(z)
print(f"โซ 2yz dy = {g} + h(z)")
# h(z) ๊ฒฐ์ : โฯ/โz = x + yยฒ + h'(z) = x + yยฒ โ h'(z) = 0 โ h = C
phi_total = x**2 * y + x*z + y**2 * z
print(f"\nฯ(x,y,z) = {phi_total}")
# ๊ฒ์ฆ: โฯ = F1?
from sympy.vector import gradient
grad_phi = gradient(phi_total, N)
print(f"โฯ = {grad_phi}")
print(f"F1 = โฯ? {sp.simplify(grad_phi - F1) == N.zero}")
# === ๋น๋ณด์กด์ฅ ์์ ===
# F2 = (y)xฬ + (x + z)ลท + (y + 1)แบ โ curl โ 0 ํ์ธ
F2 = y*N.i + (x + z)*N.j + (y + 1)*N.k
curl_F2 = curl(F2, N)
print(f"\nF2 = {F2}")
print(f"โรF2 = {curl_F2}") # ๋น๋ณด์กด์ฅ ์ฌ๋ถ ํ์ธ
3. Surface Integrals¶
3.1 Surface Element and Normal Vector¶
When surface $S$ is parameterized by $(u, v)$: $\mathbf{r}(u, v) = (x(u,v),\, y(u,v),\, z(u,v))$
Surface element:
$$ d\mathbf{S} = \left(\frac{\partial \mathbf{r}}{\partial u} \times \frac{\partial \mathbf{r}}{\partial v}\right) du \, dv = \hat{n} \, dA $$
where $\hat{n}$ is the unit normal vector and $dA = |d\mathbf{S}|$ is the surface area element.
For surfaces given as $z = g(x, y)$:
$$ d\mathbf{S} = \left(-\frac{\partial g}{\partial x}\hat{x} - \frac{\partial g}{\partial y}\hat{y} + \hat{z}\right) dx \, dy $$
3.2 Surface Integral of a Scalar Field¶
$$ \iint_S f \, dA = \iint_D f(\mathbf{r}(u,v)) \left|\frac{\partial \mathbf{r}}{\partial u} \times \frac{\partial \mathbf{r}}{\partial v}\right| du \, dv $$
Applications: surface area (when $f = 1$), total of physical quantity over surface
import numpy as np
import sympy as sp
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
# ๊ตฌ๋ฉด r = 1 ์ ๋ฉด์ ๊ณ์ฐ (๊ตฌ๋ฉด์ขํ)
theta, phi = sp.symbols('theta phi')
# ๊ตฌ๋ฉด ๋งค๊ฐ๋ณ์ํ: r(ฮธ, ฯ) = (sinฮธ cosฯ, sinฮธ sinฯ, cosฮธ)
r_theta = sp.Matrix([sp.cos(phi)*sp.cos(theta), # โr/โฮธ
sp.sin(phi)*sp.cos(theta),
-sp.sin(theta)])
r_phi = sp.Matrix([-sp.sin(phi)*sp.sin(theta), # โr/โฯ
sp.cos(phi)*sp.sin(theta),
0])
# ์ธ์ : โr/โฮธ ร โr/โฯ
cross = r_theta.cross(r_phi)
dA = sp.simplify(cross.norm())
print(f"|โr/โฮธ ร โr/โฯ| = {dA}") # sin(theta) (ฮธ โ [0, ฯ]์์ ์์)
# ๋ฉด์ ์ ๋ถ
area = sp.integrate(sp.sin(theta), (phi, 0, 2*sp.pi), (theta, 0, sp.pi))
print(f"๊ตฌ์ ๋ฉด์ = {area}") # 4*pi
# 3D ์๊ฐํ
u = np.linspace(0, np.pi, 40)
v = np.linspace(0, 2*np.pi, 40)
U, V = np.meshgrid(u, v)
X = np.sin(U) * np.cos(V)
Y = np.sin(U) * np.sin(V)
Z = np.cos(U)
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, alpha=0.6, cmap='viridis')
# ๋ฒ์ ๋ฒกํฐ ํ์ (์ผ๋ถ ์ ์์)
step = 8
for i in range(0, len(u), step):
for j in range(0, len(v), step):
px, py, pz = X[j, i], Y[j, i], Z[j, i]
ax.quiver(px, py, pz, px*0.3, py*0.3, pz*0.3,
color='red', arrow_length_ratio=0.3)
ax.set_title('๋จ์ ๊ตฌ๋ฉด๊ณผ ๋ฒ์ ๋ฒกํฐ')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.tight_layout()
plt.savefig('sphere_normal_vectors.png', dpi=150, bbox_inches='tight')
plt.show()
3.3 Surface Integral of a Vector Field (Flux)¶
The flux of vector field $\mathbf{F}$ through surface $S$:
$$ \Phi = \iint_S \mathbf{F} \cdot d\mathbf{S} = \iint_S \mathbf{F} \cdot \hat{n} \, dA $$
Physical Meaning: - Electric flux: amount of electric field penetrating the surface (Gauss's law) - Mass flux: mass flow rate through the surface
import sympy as sp
x, y, z = sp.symbols('x y z')
u, v = sp.symbols('u v')
# ์์ : F = (x, y, z)๊ฐ ๊ตฌ๋ฉด r = R์ ํต๊ณผํ๋ ํ๋ญ์ค
R = sp.Symbol('R', positive=True)
theta, phi = sp.symbols('theta phi')
# ๊ตฌ๋ฉด ์์์ rฬ = (sinฮธ cosฯ, sinฮธ sinฯ, cosฮธ)
# ๊ตฌ๋ฉด ์์์ F = R*(sinฮธ cosฯ, sinฮธ sinฯ, cosฮธ) = R*rฬ
# Fยทnฬ = Fยทrฬ = R (๊ตฌ๋ฉด์์ ๋ฒ์ ์ rฬ ๋ฐฉํฅ)
# dA = Rยฒ sinฮธ dฮธ dฯ
integrand = R * R**2 * sp.sin(theta)
flux = sp.integrate(integrand, (phi, 0, 2*sp.pi), (theta, 0, sp.pi))
print(f"F = (x, y, z) ๊ฐ ๊ตฌ๋ฉด r={R}์ ๊ดํตํ๋ ํ๋ญ์ค:")
print(f"ฮฆ = โฌ FยทdS = {flux}") # 4*pi*R^3
# ๋ฐ์ฐ ์ ๋ฆฌ๋ก ๊ฒ์ฆ: โฌ FยทdS = โญ (โยทF) dV
div_F = 3 # โยท(x,y,z) = 1 + 1 + 1 = 3
volume = sp.Rational(4, 3) * sp.pi * R**3
flux_divergence = div_F * volume
print(f"\n๋ฐ์ฐ ์ ๋ฆฌ ๊ฒ์ฆ: โญ (โยทF)dV = 3 ร (4/3)ฯRยณ = {flux_divergence}")
print(f"์ผ์น ์ฌ๋ถ: {sp.simplify(flux - flux_divergence) == 0}") # True
4. Integral Theorems¶
The three fundamental integral theorems of vector analysis connect differential operations (gradient, curl, divergence) with integrals (line, surface, volume).
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Three Fundamental Theorems โ by Dimension โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Dim Theorem Operator Integrals โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ 2D Green โ/โx, โ/โy Area โ Line โ
โ 3D-S Stokes โร Surface โ Line โ
โ 3D-V Gauss โยท Volume โ Surface โ
โ โ
โ Common pattern: โซโซ(differential) = โฎ(boundary integral) โ
โ "interior differential = boundary integral" โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4.1 Green's Theorem¶
In 2D, for a simple closed curve $C$ enclosing region $D$:
$$ \oint_C (P \, dx + Q \, dy) = \iint_D \left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right) dA $$
Physical Meaning: The circulation of a vector field equals the sum of the $z$-component curl over the interior.
import numpy as np
import sympy as sp
x, y, t = sp.symbols('x y t')
# ์์ : P = -yยฒ, Q = xยฒ ์ ๋ํด ๊ทธ๋ฆฐ ์ ๋ฆฌ ๊ฒ์ฆ
# ์์ญ: ๋จ์ ์ xยฒ + yยฒ โค 1
P = -y**2
Q = x**2
# ์ข๋ณ: ์ ์ ๋ถ (๋จ์ ์ ๊ฒฝ๋ก)
x_t = sp.cos(t)
y_t = sp.sin(t)
dx_dt = sp.diff(x_t, t)
dy_dt = sp.diff(y_t, t)
P_on_C = P.subs([(x, x_t), (y, y_t)])
Q_on_C = Q.subs([(x, x_t), (y, y_t)])
line_integral = sp.integrate(P_on_C * dx_dt + Q_on_C * dy_dt, (t, 0, 2*sp.pi))
print(f"์ ์ ๋ถ โฎ(P dx + Q dy) = {line_integral}")
# ์ฐ๋ณ: ๋ฉด์ ๋ถ (๊ทน์ขํ)
r, theta = sp.symbols('r theta')
dQ_dx = sp.diff(Q, x) # 2x
dP_dy = sp.diff(P, y) # -2y
integrand = dQ_dx - dP_dy # 2x + 2y
# ๊ทน์ขํ ๋ณํ
integrand_polar = integrand.subs([(x, r*sp.cos(theta)), (y, r*sp.sin(theta))])
area_integral = sp.integrate(integrand_polar * r, (r, 0, 1), (theta, 0, 2*sp.pi))
print(f"๋ฉด์ ๋ถ โฌ(โQ/โx - โP/โy)dA = {area_integral}")
print(f"\n๊ทธ๋ฆฐ ์ ๋ฆฌ ์ฑ๋ฆฝ: {sp.simplify(line_integral - area_integral) == 0}")
Special form of Green's theorem โ area formula:
$$ A = \frac{1}{2} \oint_C (x \, dy - y \, dx) $$
This formula is used in surveying and computer graphics to calculate polygon areas.
4.2 Stokes' Theorem¶
In 3D, for surface $S$ with boundary curve $C = \partial S$:
$$ \oint_C \mathbf{F} \cdot d\mathbf{r} = \iint_S (\nabla \times \mathbf{F}) \cdot d\mathbf{S} $$
Interpretation: Circulation around boundary = flux of curl through surface
import numpy as np
import sympy as sp
x, y, z, t = sp.symbols('x y z t')
# ์์ : F = (y, -x, zยฒ) ์ ๋ํด ์คํ ํฌ์ค ์ ๋ฆฌ ๊ฒ์ฆ
# ๊ณก๋ฉด S: z = 1 - xยฒ - yยฒ (z โฅ 0์ธ ํฌ๋ฌผ๋ฉด)
# ๊ฒฝ๊ณ C: z = 0์์ xยฒ + yยฒ = 1 (๋จ์ ์)
# --- curl(F) ๊ณ์ฐ ---
Fx, Fy, Fz = y, -x, z**2
curl_x = sp.diff(Fz, y) - sp.diff(Fy, z) # 0 - 0 = 0
curl_y = sp.diff(Fx, z) - sp.diff(Fz, x) # 0 - 0 = 0
curl_z = sp.diff(Fy, x) - sp.diff(Fx, y) # -1 - 1 = -2
print(f"โรF = ({curl_x}, {curl_y}, {curl_z})")
# --- ์ข๋ณ: ์ ์ ๋ถ โฎ_C Fยทdr ---
# C: r(t) = (cos t, sin t, 0), 0 โค t โค 2ฯ (๋ฐ์๊ณ)
x_t, y_t, z_t = sp.cos(t), sp.sin(t), sp.Integer(0)
dx_dt = sp.diff(x_t, t)
dy_dt = sp.diff(y_t, t)
dz_dt = sp.diff(z_t, t)
Fx_C = Fy_expr = y_t # Fx = y = sin t
Fy_C = -x_t # Fy = -x = -cos t
Fz_C = z_t**2 # Fz = zยฒ = 0
line_int = sp.integrate(
Fx_C * dx_dt + Fy_C * dy_dt + Fz_C * dz_dt,
(t, 0, 2*sp.pi)
)
print(f"\n์ข๋ณ (์ ์ ๋ถ): โฎ Fยทdr = {line_int}")
# --- ์ฐ๋ณ: ๋ฉด์ ๋ถ โฌ_S (โรF)ยทdS ---
# ๊ณก๋ฉด z = 1 - xยฒ - yยฒ, dS = (-โz/โx, -โz/โy, 1) dx dy = (2x, 2y, 1) dx dy
# (โรF)ยทdS = (0, 0, -2)ยท(2x, 2y, 1) dx dy = -2 dx dy
r_sym, theta_sym = sp.symbols('r_s theta_s')
surface_int = sp.integrate(
-2 * r_sym, # -2 ร r (์ผ์ฝ๋น์)
(r_sym, 0, 1),
(theta_sym, 0, 2*sp.pi)
)
print(f"์ฐ๋ณ (๋ฉด์ ๋ถ): โฌ (โรF)ยทdS = {surface_int}")
print(f"์คํ ํฌ์ค ์ ๋ฆฌ ์ฑ๋ฆฝ: {line_int == surface_int}")
4.3 Divergence Theorem (Gauss's Theorem)¶
For closed surface $S$ enclosing volume $V$:
$$ \oiint_S \mathbf{F} \cdot d\mathbf{S} = \iiint_V (\nabla \cdot \mathbf{F}) \, dV $$
Interpretation: Total flux through closed surface = sum of divergence throughout interior
import numpy as np
import sympy as sp
x, y, z = sp.symbols('x y z')
# ์์ : F = (xยณ, yยณ, zยณ), ๋ซํ ๊ณก๋ฉด = ๋จ์ ๊ตฌ xยฒ+yยฒ+zยฒ = 1
# โยทF = 3xยฒ + 3yยฒ + 3zยฒ = 3rยฒ
div_F = sp.diff(x**3, x) + sp.diff(y**3, y) + sp.diff(z**3, z)
print(f"โยทF = {div_F}") # 3xยฒ + 3yยฒ + 3zยฒ
# ์ฒด์ ์ ๋ถ (๊ตฌ๋ฉด์ขํ)
r, theta, phi = sp.symbols('r theta phi')
div_F_spherical = 3 * r**2 # 3(xยฒ + yยฒ + zยฒ) = 3rยฒ
jacobian = r**2 * sp.sin(theta)
volume_int = sp.integrate(
div_F_spherical * jacobian,
(r, 0, 1),
(theta, 0, sp.pi),
(phi, 0, 2*sp.pi)
)
print(f"โญ (โยทF) dV = {volume_int}") # 12ฯ/5
# ์ง์ ๋ฉด์ ๋ถ์ผ๋ก ๊ฒ์ฆ
# ๊ตฌ๋ฉด ์์์ rฬ = (x, y, z) (๋จ์๊ตฌ์ด๋ฏ๋ก |r| = 1)
# Fยทrฬ = xโด + yโด + zโด (๊ตฌ๋ฉด ์์์ xยฒ + yยฒ + zยฒ = 1)
# ๊ตฌ๋ฉด์ขํ: x = sinฮธ cosฯ, y = sinฮธ sinฯ, z = cosฮธ
F_dot_n = (sp.sin(theta)*sp.cos(phi))**4 + \
(sp.sin(theta)*sp.sin(phi))**4 + \
sp.cos(theta)**4
surface_int = sp.integrate(
F_dot_n * sp.sin(theta), # dA = sinฮธ dฮธ dฯ
(theta, 0, sp.pi),
(phi, 0, 2*sp.pi)
)
surface_int_simplified = sp.simplify(surface_int)
print(f"โฌ FยทdS = {surface_int_simplified}")
print(f"์ผ์น: {sp.simplify(volume_int - surface_int_simplified) == 0}")
4.4 Relationship Between the Three Theorems¶
All three integral theorems are special cases of the generalized Stokes' theorem:
$$ \int_{\partial \Omega} \omega = \int_{\Omega} d\omega $$
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Unified View of Three Theorems โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Fundamental Theorem of Calculus (1D): โ
โ โซ_a^b f'(x) dx = f(b) - f(a) โ
โ "integral of derivative = difference of boundary values" โ
โ โ
โ Green's Theorem (2D): โ
โ โฌ_D (โQ/โx - โP/โy) dA = โฎ_{โD} (P dx + Q dy) โ
โ "area integral of curl = line integral on boundary" โ
โ โ
โ Stokes' Theorem (3D, surfaceโboundary): โ
โ โฌ_S (โรF)ยทdS = โฎ_{โS} Fยทdr โ
โ "surface integral of curl = line integral on boundary" โ
โ โ
โ Gauss's Theorem (3D, volumeโboundary): โ
โ โญ_V (โยทF) dV = โฌ_{โV} FยทdS โ
โ "volume integral of divergence = surface integral" โ
โ โ
โ Pattern: "interior differential = boundary values" โ
โ n-dimensional integral โ (n-1)-dimensional boundary โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
5. Physical Applications¶
5.1 Electric Field and Gauss's Law¶
Gauss's Law (integral form):
$$ \oiint_S \mathbf{E} \cdot d\mathbf{S} = \frac{Q_{\text{enc}}}{\epsilon_0} $$
Gauss's Law (differential form): Applying the divergence theorem:
$$ \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0} $$
The divergence of the electric field is nonzero where charge density $\rho$ exists.
import numpy as np
import matplotlib.pyplot as plt
# ์ ์ ํ์ ์ ๊ธฐ์ฅ ์๊ฐํ (2D ๋จ๋ฉด)
# E = q/(4ฯฮตโ) ร rฬ/rยฒ (์ฟจ๋กฑ ๋ฒ์น)
q = 1.0 # ์ ํ๋ (์์ ๋จ์)
eps0 = 1.0 # ฮตโ (๋จ์๊ณ ํธ์์)
X, Y = np.meshgrid(np.linspace(-3, 3, 20), np.linspace(-3, 3, 20))
R = np.sqrt(X**2 + Y**2)
R = np.where(R < 0.3, 0.3, R) # ํน์ด์ ๋ฐฉ์ง
# ์ ๊ธฐ์ฅ ์ฑ๋ถ
k = q / (4 * np.pi * eps0)
Ex = k * X / R**3
Ey = k * Y / R**3
E_mag = np.sqrt(Ex**2 + Ey**2)
fig, axes = plt.subplots(1, 2, figsize=(16, 7))
# ์์ ํ (+q)
ax = axes[0]
ax.streamplot(X, Y, Ex, Ey, color=np.log(E_mag + 1), cmap='Reds',
density=2, linewidth=1.2)
ax.plot(0, 0, 'ro', markersize=15, label='+q')
circle1 = plt.Circle((0, 0), 1.0, fill=False, color='gray', linestyle='--', label='๊ฐ์ฐ์ค ๋ฉด r=1')
circle2 = plt.Circle((0, 0), 2.0, fill=False, color='gray', linestyle=':', label='๊ฐ์ฐ์ค ๋ฉด r=2')
ax.add_patch(circle1)
ax.add_patch(circle2)
ax.set_title('์์ ํ์ ์ ๊ธฐ์ฅ (๋ฐ์ฐ > 0)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.legend(loc='upper left', fontsize=9)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
# ์๊ทน์ (dipole): +q at (1,0), -q at (-1,0)
ax = axes[1]
d = 1.0
R1 = np.sqrt((X - d)**2 + Y**2)
R2 = np.sqrt((X + d)**2 + Y**2)
R1 = np.where(R1 < 0.3, 0.3, R1)
R2 = np.where(R2 < 0.3, 0.3, R2)
Ex_dip = k * (X - d) / R1**3 - k * (X + d) / R2**3
Ey_dip = k * Y / R1**3 - k * Y / R2**3
E_dip_mag = np.sqrt(Ex_dip**2 + Ey_dip**2)
ax.streamplot(X, Y, Ex_dip, Ey_dip, color=np.log(E_dip_mag + 1),
cmap='coolwarm', density=2, linewidth=1.2)
ax.plot(d, 0, 'ro', markersize=12, label='+q')
ax.plot(-d, 0, 'bo', markersize=12, label='-q')
ax.set_title('์ ๊ธฐ ์๊ทน์ (dipole)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.legend(fontsize=9)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
plt.tight_layout()
plt.savefig('electric_field_gauss.png', dpi=150, bbox_inches='tight')
plt.show()
5.2 Magnetic Field and Ampรจre's Law¶
Ampรจre's Law (integral form):
$$ \oint_C \mathbf{B} \cdot d\mathbf{r} = \mu_0 I_{\text{enc}} $$
Ampรจre's Law (differential form): Applying Stokes' theorem:
$$ \nabla \times \mathbf{B} = \mu_0 \mathbf{J} $$
where $\mathbf{J}$ is the current density.
Physical Meaning: - Curl of magnetic field is proportional to current density - Magnetic field lines form closed loops around currents (right-hand rule) - $\nabla \cdot \mathbf{B} = 0$ โ magnetic monopoles do not exist
import numpy as np
import matplotlib.pyplot as plt
# ๋ฌดํ ์ง์ ์ ๋ฅ์ ์ํ ์๊ธฐ์ฅ
# B = ฮผโI/(2ฯr) ร ฯฬ (์ํต์ขํ)
mu0 = 1.0 # ฮผโ (์์ ๋จ์)
I = 1.0 # ์ ๋ฅ (z ๋ฐฉํฅ)
X, Y = np.meshgrid(np.linspace(-3, 3, 20), np.linspace(-3, 3, 20))
R = np.sqrt(X**2 + Y**2)
R = np.where(R < 0.3, 0.3, R)
# B = ฮผโI/(2ฯr) ร ฯฬ, ์ฌ๊ธฐ์ ฯฬ = (-y/r, x/r, 0)
B_coeff = mu0 * I / (2 * np.pi * R)
Bx = B_coeff * (-Y / R)
By = B_coeff * (X / R)
fig, ax = plt.subplots(figsize=(8, 8))
B_mag = np.sqrt(Bx**2 + By**2)
strm = ax.streamplot(X, Y, Bx, By, color=np.log(B_mag + 0.01),
cmap='plasma', density=2, linewidth=1.5)
plt.colorbar(strm.lines, ax=ax, label='log|B|')
# ์ ๋ฅ ์์น (์์ , z ๋ฐฉํฅ)
ax.plot(0, 0, 'g^', markersize=15, label='I (z ๋ฐฉํฅ, ์ง๋ฉด์์ ๋์ด)')
# ์ํ๋ฅด ๋ฃจํ ํ์
for r in [1.0, 2.0]:
circle = plt.Circle((0, 0), r, fill=False, color='lime',
linestyle='--', linewidth=2)
ax.add_patch(circle)
ax.set_title('์ง์ ์ ๋ฅ ์ฃผ์์ ์๊ธฐ์ฅ (์ํ๋ฅด ๋ฒ์น)')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
ax.legend(loc='upper left')
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
plt.tight_layout()
plt.savefig('magnetic_field_ampere.png', dpi=150, bbox_inches='tight')
plt.show()
5.3 Continuity Equation in Fluid Dynamics¶
The continuity equation expressing mass conservation:
$$ \frac{\partial \rho}{\partial t} + \nabla \cdot (\rho \mathbf{v}) = 0 $$
where $\rho$ is fluid density and $\mathbf{v}$ is the velocity field.
Derivation: 1. Mass outflow rate through closed surface = $\oiint_S \rho \mathbf{v} \cdot d\mathbf{S}$ 2. Rate of mass change in volume = $-\frac{\partial}{\partial t}\iiint_V \rho \, dV$ 3. Apply divergence theorem: $\iiint_V \left[\frac{\partial \rho}{\partial t} + \nabla \cdot (\rho \mathbf{v})\right] dV = 0$ 4. For arbitrary volume, integrand must be zero
Incompressible fluid ($\rho$ = constant):
$$ \nabla \cdot \mathbf{v} = 0 $$
import numpy as np
import matplotlib.pyplot as plt
# 2D ๋น์์ถ ์ ์ฒด ํ๋ฆ ์์
# ํ๋ฆ ํจ์(stream function) ฯ๋ฅผ ์ด์ฉ: vx = โฯ/โy, vy = -โฯ/โx
# โ ์๋์ผ๋ก โยทv = 0 ๋ง์กฑ
X, Y = np.meshgrid(np.linspace(-3, 3, 25), np.linspace(-3, 3, 25))
# ์์ 1: ๊ท ์ผ ํ๋ฆ + ์ํต ์ฃผ์ ํ๋ฆ (ํผํ
์
ํ๋ฆ)
# ฯ = U*y*(1 - aยฒ/rยฒ), U = ์์ ๋ฅ ์๋, a = ์ํต ๋ฐ์ง๋ฆ
U_inf = 1.0
a = 1.0
R_sq = X**2 + Y**2
R_sq = np.where(R_sq < a**2, a**2, R_sq) # ์ํต ๋ด๋ถ ๋ง์คํน
Vx = U_inf * (1 - a**2 * (X**2 - Y**2) / R_sq**2)
Vy = -U_inf * 2 * a**2 * X * Y / R_sq**2
# ์ํต ๋ด๋ถ ์๋ = 0
mask = (X**2 + Y**2) < a**2
Vx[mask] = 0
Vy[mask] = 0
fig, ax = plt.subplots(figsize=(10, 8))
speed = np.sqrt(Vx**2 + Vy**2)
strm = ax.streamplot(X, Y, Vx, Vy, color=speed, cmap='RdYlBu_r',
density=2, linewidth=1.2)
plt.colorbar(strm.lines, ax=ax, label='|v| (์๋ ฅ)')
# ์ํต ํ์
circle = plt.Circle((0, 0), a, color='gray', alpha=0.5)
ax.add_patch(circle)
# ๋ฐ์ฐ ๊ณ์ฐ (์์น์ )
dVx_dx = np.gradient(Vx, X[0], axis=1)
dVy_dy = np.gradient(Vy, Y[:, 0], axis=0)
div_v = dVx_dx + dVy_dy
max_div = np.max(np.abs(div_v[~mask]))
ax.set_title(f'์ํต ์ฃผ์ ๋น์์ถ ์ ์ฒด ํ๋ฆ (max|โยทv| โ {max_div:.2e})')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_aspect('equal')
plt.tight_layout()
plt.savefig('fluid_flow_cylinder.png', dpi=150, bbox_inches='tight')
plt.show()
5.4 Maxwell's Equations: Integral and Differential Forms¶
Maxwell's equations completely describe electromagnetic phenomena. Through vector analysis integral theorems (Gauss, Stokes), we can convert between integral and differential forms.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Maxwell's Equations โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Law Differential Form Integral Form Theorem โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Gauss (electric) โยทE = ฯ/ฮตโ โฎ EยทdS = Q/ฮตโ Gauss โ
โ โ
โ Gauss (magnetic) โยทB = 0 โฎ BยทdS = 0 Gauss โ
โ โ
โ Faraday โรE = -โB/โt โฎ Eยทdr = -dฮฆ_B/dt Stokes โ
โ โ
โ Ampรจre-Maxwell โรB = ฮผโJ + ฮผโฮตโโE/โt Stokes โ
โ โฎ Bยทdr = ฮผโI + ฮผโฮตโ dฮฆ_E/dt โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Physical Meaning: โ
โ โข Gauss (electric): Charges are sources of electric field โ
โ โข Gauss (magnetic): Magnetic monopoles do not exist โ
โ โข Faraday: Changing magnetic field induces electric field โ
โ โข Ampรจre-Maxwell: Current and changing E-field induce B-field โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Converting from integral to differential form (Gauss's law example):
$$ \oiint_S \mathbf{E} \cdot d\mathbf{S} = \frac{Q_{\text{enc}}}{\epsilon_0} = \frac{1}{\epsilon_0}\iiint_V \rho \, dV $$
Apply divergence theorem to left side:
$$ \iiint_V (\nabla \cdot \mathbf{E}) \, dV = \frac{1}{\epsilon_0}\iiint_V \rho \, dV $$
Valid for arbitrary volume $V$:
$$ \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0} $$
import numpy as np
import matplotlib.pyplot as plt
# ๋งฅ์ค์ฐ ๋ฐฉ์ ์์ ์๊ฐ์ ์ ๋ฆฌ: ์ ๊ธฐ์ฅ๊ณผ ์๊ธฐ์ฅ์ ๊ด๊ณ
fig, axes = plt.subplots(2, 2, figsize=(14, 12))
# === (1) ๊ฐ์ฐ์ค ๋ฒ์น (์ ๊ธฐ): โยทE = ฯ/ฮตโ ===
ax = axes[0, 0]
X, Y = np.meshgrid(np.linspace(-2, 2, 15), np.linspace(-2, 2, 15))
R = np.sqrt(X**2 + Y**2)
R = np.where(R < 0.3, 0.3, R)
Ex = X / R**3
Ey = Y / R**3
ax.quiver(X, Y, Ex, Ey, color='red', alpha=0.6)
circle = plt.Circle((0, 0), 0.2, color='red', alpha=0.8)
ax.add_patch(circle)
ax.set_title('(1) ๊ฐ์ฐ์ค ๋ฒ์น: โยทE = ฯ/ฮตโ\n์ ํ โ ๋ฐ์ฐํ๋ E')
ax.set_aspect('equal')
ax.set_xlim(-2.5, 2.5)
ax.set_ylim(-2.5, 2.5)
ax.grid(True, alpha=0.2)
# === (2) ๊ฐ์ฐ์ค ๋ฒ์น (์๊ธฐ): โยทB = 0 ===
ax = axes[0, 1]
# ์๊ธฐ ์๊ทน์ (๋จ๊ทน์ ์์)
d = 0.5
R1 = np.sqrt((X - 0)**2 + (Y - d)**2)
R2 = np.sqrt((X - 0)**2 + (Y + d)**2)
R1 = np.where(R1 < 0.3, 0.3, R1)
R2 = np.where(R2 < 0.3, 0.3, R2)
Bx = X / R1**3 - X / R2**3
By = (Y - d) / R1**3 - (Y + d) / R2**3
speed = np.sqrt(Bx**2 + By**2)
ax.streamplot(X, Y, Bx, By, color=np.log(speed + 0.1), cmap='Blues',
density=2, linewidth=1)
ax.set_title('(2) ๊ฐ์ฐ์ค ๋ฒ์น: โยทB = 0\n์๊ธฐ์ฅ์ ์ ๋ซํ ๋ฃจํ')
ax.set_aspect('equal')
ax.set_xlim(-2.5, 2.5)
ax.set_ylim(-2.5, 2.5)
ax.grid(True, alpha=0.2)
# === (3) ํจ๋ฌ๋ฐ์ด ๋ฒ์น: โรE = -โB/โt ===
ax = axes[1, 0]
# ๋ณํ๋ ์๊ธฐ์ฅ โ ์ ๋ ์ ๊ธฐ์ฅ (์ํ)
R_circ = np.sqrt(X**2 + Y**2)
R_circ = np.where(R_circ < 0.2, 0.2, R_circ)
Ex_ind = -Y / R_circ**2
Ey_ind = X / R_circ**2
ax.streamplot(X, Y, Ex_ind, Ey_ind, color='orange', density=1.5, linewidth=1.5)
ax.annotate('dB/dt\n(z ๋ฐฉํฅ)', xy=(0, 0), fontsize=12, ha='center',
bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.8))
ax.set_title('(3) ํจ๋ฌ๋ฐ์ด: โรE = -โB/โt\n๋ณํ๋ B โ ์ ๋ E')
ax.set_aspect('equal')
ax.set_xlim(-2.5, 2.5)
ax.set_ylim(-2.5, 2.5)
ax.grid(True, alpha=0.2)
# === (4) ์ํ๋ฅด-๋งฅ์ค์ฐ: โรB = ฮผโJ + ฮผโฮตโ โE/โt ===
ax = axes[1, 1]
R_wire = np.sqrt(X**2 + Y**2)
R_wire = np.where(R_wire < 0.2, 0.2, R_wire)
Bx_wire = -Y / R_wire**2
By_wire = X / R_wire**2
ax.streamplot(X, Y, Bx_wire, By_wire, color='purple', density=1.5, linewidth=1.5)
ax.annotate('I or โE/โt\n(z ๋ฐฉํฅ)', xy=(0, 0), fontsize=12, ha='center',
bbox=dict(boxstyle='round', facecolor='lightyellow', alpha=0.8))
ax.set_title('(4) ์ํ๋ฅด-๋งฅ์ค์ฐ: โรB = ฮผโJ + ฮผโฮตโโE/โt\n์ ๋ฅ/๋ณํ๋ E โ B')
ax.set_aspect('equal')
ax.set_xlim(-2.5, 2.5)
ax.set_ylim(-2.5, 2.5)
ax.grid(True, alpha=0.2)
plt.suptitle('๋งฅ์ค์ฐ ๋ฐฉ์ ์์ 4๊ฐ์ง ๋ฒ์น', fontsize=16, fontweight='bold', y=1.02)
plt.tight_layout()
plt.savefig('maxwell_equations.png', dpi=150, bbox_inches='tight')
plt.show()
Practice Problems¶
Problem 1: Gradient and Directional Derivative¶
For scalar field $f(x, y, z) = x^2 y + y^2 z + z^2 x$: 1. Find $\nabla f$. 2. Calculate the directional derivative at point $(1, 1, 1)$ in direction $\hat{u} = \frac{1}{\sqrt{3}}(1, 1, 1)$. 3. At point $(1, 1, 1)$, find the direction of fastest increase of $f$ and its rate.
Problem 2: Divergence and Curl¶
Calculate the divergence and curl of the following vector fields, and determine if they are conservative:
(a) $\mathbf{F} = (yz, xz, xy)$
(b) $\mathbf{G} = (x^2 - y, y^2 + x, z)$
If conservative, find the potential function.
Problem 3: Line Integrals¶
For vector field $\mathbf{F} = (2xy + z^2)\hat{x} + x^2\hat{y} + 2xz\hat{z}$: 1. Show that $\mathbf{F}$ is conservative and find potential function $\phi$. 2. Calculate the line integral from $(0, 0, 0)$ to $(1, 2, 3)$ using (a) the potential function, (b) direct integration along straight path $\mathbf{r}(t) = (t, 2t, 3t)$, and verify they match.
Problem 4: Divergence Theorem Verification¶
For $\mathbf{F} = (x^2, y^2, z^2)$ in the unit cube $[0,1]^3$, verify the divergence theorem: 1. Calculate $\nabla \cdot \mathbf{F}$ and compute the volume integral. 2. Calculate surface integrals on all 6 faces and sum them. 3. Verify that the two results match.
Problem 5: Stokes' Theorem and Physical Application¶
For uniform current density $\mathbf{J} = J_0 \hat{z}$ in a cylindrical wire of radius $a$: 1. Use Ampรจre's law (integral form) to find magnetic field $\mathbf{B}$ for $r < a$ and $r > a$. 2. For $r < a$, directly verify that $\nabla \times \mathbf{B} = \mu_0 \mathbf{J}$ (use cylindrical coordinate curl formula).
Problem 6: Maxwell Equation Transformation¶
From Faraday's law integral form:
$$ \oint_C \mathbf{E} \cdot d\mathbf{r} = -\frac{d}{dt}\iint_S \mathbf{B} \cdot d\mathbf{S} $$
Use Stokes' theorem to derive the differential form $\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t}$. Describe the derivation step by step.
References¶
Textbooks¶
- Boas, M. L. (2005). Mathematical Methods in the Physical Sciences, 3rd ed., Chapter 6. Wiley.
- Griffiths, D. J. (2017). Introduction to Electrodynamics, 4th ed. Cambridge University Press.
- Excellent reference for electromagnetic applications of vector analysis
- Arfken, G. B., Weber, H. J., & Harris, F. E. (2012). Mathematical Methods for Physicists, 7th ed., Chapters 1-3. Academic Press.
- Schey, H. M. (2005). Div, Grad, Curl, and All That, 4th ed. W.W. Norton.
- Intuitive introduction to vector analysis
Online Resources¶
- 3Blue1Brown โ Divergence and Curl: Visual understanding of divergence and curl
- MIT OCW 18.02 โ Multivariable Calculus: Vector analysis lectures
- Paul's Online Math Notes โ Calculus III: Rich practice problems
Python Tools¶
sympy.vector: Symbolic vector calculus (gradient,divergence,curl)matplotlib.pyplot.quiver: 2D vector field arrow visualizationmatplotlib.pyplot.streamplot: Streamline visualizationmpl_toolkits.mplot3d: 3D surface and vector visualization
Next Lesson¶
- Previous: 02. Complex Numbers โ Complex algebra, polar/exponential form, De Moivre's theorem
- Next: 04. Curvilinear Coordinates and Multiple Integrals โ Cylindrical/spherical coordinates, Jacobian, coordinate transformations