Skip to content

Clarify ComplexNumber |z| vs |z|² naming (abs / absSquared) - #27

Merged
barrybecker4 merged 1 commit into
masterfrom
cursor/rename-complex-magnitude-67b4
Nov 8, 2026
Merged

barrybecker4 merged 1 commit into
masterfrom
cursor/rename-complex-magnitude-67b4

Conversation

@barrybecker4

Copy link
Copy Markdown
Member

Fixes #18

ComplexNumber had two easy-to-confuse operations: magnitude returned |z|², while getMagnitude returned |z|. Callers could not tell which was which from the names.

API change

  • abs — Euclidean modulus |z| = sqrt(real² + imaginary²) (overflow-safe via hypot)
  • absSquared — squared modulus |z|² = real² + imaginary² (used by reciprocal)

Deprecated aliases keep published and downstream callers compiling:

  • getMagnitude → abs
  • magnitude → absSquared

In-repo tests and call sites now use the clearer names. Names were chosen after checking this repo and bb4 consumers: the only external use found was getMagnitude in bb4-simulations (EscapeIteration), which continues to work via the deprecated alias.

Open in Web Open in Cursor 

Rename getMagnitude to abs and magnitude to absSquared so callers can
tell the Euclidean modulus from its square. Keep the old names as
deprecated 2.1 aliases for published and downstream callers, and point
reciprocal at absSquared.

Co-authored-by: Barry G Becker <barrybecker4@yahoo.com>
@barrybecker4
barrybecker4 merged commit eb47582 into master Nov 8, 2026
1 check passed
@barrybecker4
barrybecker4 deleted the cursor/rename-complex-magnitude-67b4 branch November 8, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComplexNumber.magnitude is |z|² while getMagnitude is |z|

2 participants