enhance cbrt to work on Complex and to return all cube roots #29
Labels
No labels
design
feature
maintenance
priority
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#30 implement polynomialRoot
StudioInfinity/nanomath
Reference
StudioInfinity/nanomath#29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For now, we will make
cbrtwith return typing strategyfreeorfull(the default) always return all three cube roots (by analogy withsqrt's default behavior of returning Complex as necessary), but under typing strategyconservativeon real inputs return just the real cube root.This is the last function needed to implement polynomialRoot.
Hmm, since every real number has a unique real cube root, I actually think
freeandconservativeshould return that real cube root, whilefullreturn all three, whereas on complex input, you just always get all three.The "easiest" way to find a complex cube root is to use polar form. That requires atan2, sin, and cos. Or there appears to be a formula that just uses real cube and square roots at https://mathproofs.jrensen.nl/proofs/cube-root-complex-number. That's a much lengthier formula, but won't involve starting a trigonometry category.