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

  1. Boas, M. L. (2005). Mathematical Methods in the Physical Sciences, 3rd ed., Chapter 6. Wiley.
  2. Griffiths, D. J. (2017). Introduction to Electrodynamics, 4th ed. Cambridge University Press.
  3. Excellent reference for electromagnetic applications of vector analysis
  4. Arfken, G. B., Weber, H. J., & Harris, F. E. (2012). Mathematical Methods for Physicists, 7th ed., Chapters 1-3. Academic Press.
  5. Schey, H. M. (2005). Div, Grad, Curl, and All That, 4th ed. W.W. Norton.
  6. Intuitive introduction to vector analysis

Online Resources

  1. 3Blue1Brown โ€” Divergence and Curl: Visual understanding of divergence and curl
  2. MIT OCW 18.02 โ€” Multivariable Calculus: Vector analysis lectures
  3. 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 visualization
  • matplotlib.pyplot.streamplot: Streamline visualization
  • mpl_toolkits.mplot3d: 3D surface and vector visualization

Next Lesson

to navigate between lessons