Ulam Spiral by Denis

Ulam Spiral by Denis
Loading the math board and drawing, please wait…
2012-06-14 13:14
This example demonstrates the Ulam spiral pattern. Core mathematical concepts include prime number distribution and geometric construction. Key points for drawing: Uses GeoGebra commands Join, Min, Sequence, Polygon, Length, Zip, RemoveUndefined; objects include n, center, stepX, stepY, nn, listX, listY, scale, numsShow, factsShow, sprShow, A, B, C, back, D, mm, lp, prmsShow, text1, circles, spiral, pntShow, primes, numbers, cx, cy, prmsPoints, numsPoints. Suitable for high school and above mathematics enthusiasts and researchers.

GeoGebra Commands & Parameters

  1. Join({{0, 1}, Join[Sequence[Join[{Sequence[0, j, 1, m], Sequence[(-1)^(m), j, 1, m + 1]}], m, 1, n]]}) → stepX
  2. Join({{0, 0}, Join[Sequence[Join[{Sequence[(-1)^(m + 1), j, 1, m], Sequence[0, j, 1, m + 1]}], m, 1, n]]}) → stepY
  3. Min(Length[stepX], Length[stepY]) → nn
  4. Sequence(Sum[stepX, m], m, 1, nn) → listX
  5. Sequence(Sum[stepY, m], m, 1, nn) → listY
  6. Polygon((-1.2, -1.2), (1.2, -1.2), 4) → back
  7. Length(PrimeFactors[mm]) → lp
  8. Zip(Circle[(2 * cx / n, 2 * cy / n), LP[center + k] / scale / n], cx, listX, cy, listY, k, Sequence[nn - 1]) → circles
  9. Sequence(mySegm[2 * (Element[listX, k], Element[listY, k]) / n, 2 * (Element[listX, k + 1], Element[listY, k + 1]) / n], k, 1, nn - 2) → spiral
  10. RemoveUndefined(Zip[If[LP[center + k] ≟ 1, Text[center + k, (2 * (cx - 0.15) / n, 2 * (cy - 0.05) / n)]], cx, listX, cy, listY, k, Sequence[nn - 1]]) → primes
  11. RemoveUndefined(Zip[Text[center + k, (2 * (cx - 0.15) / n, 2 * (cy - 0.05) / n)], cx, listX, cy, listY, k, Sequence[nn - 1]]) → numbers
  12. RemoveUndefined(Zip[If[LP[center + k] ≟ 1, 2 * (cx, cy) / n], cx, listX, cy, listY, k, Sequence[nn - 1]]) → prmsPoints
  13. Zip(2 * (cx, cy) / n, cx, listX, cy, listY, k, Sequence[nn - 1]) → numsPoints