]> gitweb.factorcode.org Git - factor.git/blob - extra/math/complex/complex-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / extra / math / complex / complex-docs.factor
1 USING: help.markup help.syntax math math.private math.functions
2 math.complex.private ;
3 IN: math.complex
4
5 ARTICLE: "complex-numbers" "Complex numbers"
6 { $subsection complex }
7 "Complex numbers arise as solutions to quadratic equations whose graph does not intersect the " { $emphasis "x" } " axis. Their literal syntax is covered in " { $link "syntax-complex-numbers" } "."
8 $nl
9 "Unlike math, where all real numbers are also complex numbers, Factor only considers a number to be a complex number if its imaginary part is non-zero. However, complex number operations are fully supported for real numbers; they are treated as having an imaginary part of zero."
10 $nl
11 "Complex numbers can be taken apart:"
12 { $subsection real-part }
13 { $subsection imaginary-part }
14 { $subsection >rect }
15 "Complex numbers can be constructed from real numbers:"
16 { $subsection rect> }
17 { $see-also "syntax-complex-numbers" } ;
18 HELP: complex
19 { $class-description "The class of complex numbers with non-zero imaginary part." } ;
20
21 ABOUT: "complex-numbers"
22
23 HELP: 2>rect
24 { $values { "x" "a complex number" } { "y" "a complex number" } { "xr" "real part of " { $snippet "x" } } { "xi" "imaginary part of " { $snippet "x" } } { "yr" "real part of " { $snippet "y" } } { "yi" "imaginary part of " { $snippet "y" } } }
25 { $description "Extracts real and imaginary components of two numbers at once." } ;
26
27 HELP: complex/
28 { $values { "x" "a complex number" } { "y" "a complex number" } { "r" "a real number" } { "i" "a real number" } { "m" "a real number" } }
29 { $description
30     "Complex division kernel. If we use the notation from " { $link 2>rect } ", this word computes:"
31     { $code
32         "r = xr*yr+xi*yi"
33         "i = xi*yr-xr*yi"
34         "m = yr*yr+yi*yi"
35     }
36 } ;
37
38 HELP: <complex> ( x y -- z )
39 { $values { "x" "a real number" } { "y" "a real number" } { "z" "a complex number" } }
40 { $description "Low-level complex number constructor. User code should call " { $link rect> } " instead." } ;