Skip to content

Latest commit

 

History

History
580 lines (448 loc) · 12 KB

complex.org

File metadata and controls

580 lines (448 loc) · 12 KB

#

#

Complex numbers; getting started

Rabbit holes

These are rabbit holes about complex numbers

⌜🐇 Rabbit holes to get started with CIMMIC are:

  1. This would be a good text-based starter for complex numbers. (RC-hole)
  2. This is Eddie Woo’s excellent series of YouTube videos on complex numbers. (RC-hole)
  3. This is the Wikipedia article. (RO-hole)
  4. (RO-hole)
  5. (RFYI-hole)

🐇⌟

Complex numbers

  • cite:&larson2007precalculus
import Data.Complex
x = 0 :+ 3
x
0 :+ 3
realPart x
0.0
imagPart x
3.0
y = 1 + x
let z = y ^ 2
a = 0 :+ 1
a ^ 1
0.0 :+ 1.0
a ^ 2
(-1.0) :+ 0.0
[(0 :+ 1)^x | x <- [0..15]]
[1.0 :+ 0.0,0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0),1.0 :+ (-0.0),0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0),1.0 :+ (-0.0),0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0),1.0 :+ (-0.0),0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0)]
:{
complxPower nx | null nx = []
complxPower (n:nx) = (0 :+ 1)^n : complxPower nx               
:}
complxPower [0..15]
[1.0 :+ 0.0,0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0),1.0 :+ (-0.0),0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0),1.0 :+ (-0.0),0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0),1.0 :+ (-0.0),0.0 :+ 1.0,(-1.0) :+ 0.0,(-0.0) :+ (-1.0)]

We can try to make this print prettier

import Numeric
showFFloat (Just 0) (-5.014) ""
-5
:{
complxPower2 nx | null nx = []
complxPower2 (n:nx) = ri : complxPower2 nx
  where ri = let ccalc = ((0 :+ 1)^n)
             in if (realPart ccalc) /= 0
                then (showFFloat (Just 0) (realPart ccalc) "")
                else "i"      
:}
complxPower2 [0..10]
["1","i","-1","i","1","i","-1","i","1","i","-1"]

or just

:{
complxPower6 nx | null nx = []
complxPower6 (n:nx) =
  let
    ccalc = ((0 :+ 1)^n)
    ri =
      if (realPart ccalc) /= 0
      then (showFFloat (Just 0) (realPart ccalc) "")
      else "i"
   in ri : complxPower6 nx
:}

Footnotes

[fn:1] Cardinality of a set is simply the number count of elements therein.