Roots of unity: Difference between revisions
Content added Content deleted
(→{{header|Rust}}: cleanup) |
|||
Line 1,631: | Line 1,631: | ||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
Here we demonstrate initialization from polar complex coordinate, radius 1, e^πi/n, and raising the resulting complex number to the power 2k for k in 0..n-1, which generates |
Here we demonstrate initialization from polar complex coordinate, radius 1, e^πi/n, and raising the resulting complex number to the power 2k for k in 0..n-1, which generates approximate roots (see the Mathematica answer for a nice display of exact vs approximate). This code will require adding the num crate to one's rust project, typically in Cargo.toml <i>[dependencies] \n num="0.2.0";</i> |
||
<lang C>use num::Complex; |
<lang C>use num::Complex; |
||
fn main() { |
fn main() { |