1math::complexnumbers(n)        Tcl Math Library        math::complexnumbers(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       math::complexnumbers - Straightforward complex number package
9

SYNOPSIS

11       package require Tcl  8.3
12
13       package require math::complexnumbers  ?1.0.2?
14
15       ::math::complexnumbers::+ z1 z2
16
17       ::math::complexnumbers::- z1 z2
18
19       ::math::complexnumbers::* z1 z2
20
21       ::math::complexnumbers::/ z1 z2
22
23       ::math::complexnumbers::conj z1
24
25       ::math::complexnumbers::real z1
26
27       ::math::complexnumbers::imag z1
28
29       ::math::complexnumbers::mod z1
30
31       ::math::complexnumbers::arg z1
32
33       ::math::complexnumbers::complex real imag
34
35       ::math::complexnumbers::tostring z1
36
37       ::math::complexnumbers::exp z1
38
39       ::math::complexnumbers::sin z1
40
41       ::math::complexnumbers::cos z1
42
43       ::math::complexnumbers::tan z1
44
45       ::math::complexnumbers::log z1
46
47       ::math::complexnumbers::sqrt z1
48
49       ::math::complexnumbers::pow z1 z2
50
51______________________________________________________________________________
52

DESCRIPTION

54       The  mathematical  module  complexnumbers  provides  a  straightforward
55       implementation of complex numbers in pure Tcl. The philosophy  is  that
56       the user knows he or she is dealing with complex numbers in an abstract
57       way and wants as high a performance as can be had  within  the  limita‐
58       tions of an interpreted language.
59
60       Therefore  the procedures defined in this package assume that the argu‐
61       ments are valid (representations of) "complex numbers", that is,  lists
62       of two numbers defining the real and imaginary part of a complex number
63       (though this is a mere detail: rely on the complex command to construct
64       a valid number.)
65
66       Most procedures implement the basic arithmetic operations or elementary
67       functions whereas several others convert to and from  different  repre‐
68       sentations:
69
70                  set z [complex 0 1]
71                  puts "z = [tostring $z]"
72                  puts "z**2 = [* $z $z]
73
74       would result in:
75
76
77                  z = i
78                  z**2 = -1
79
80

AVAILABLE PROCEDURES

82       The  package  implements  all  or  most basic operations and elementary
83       functions.
84
85       The arithmetic operations are:
86
87       ::math::complexnumbers::+ z1 z2
88              Add the two arguments and return the resulting complex number
89
90              complex z1 (in)
91                     First argument in the summation
92
93              complex z2 (in)
94                     Second argument in the summation
95
96
97       ::math::complexnumbers::- z1 z2
98              Subtract the second argument  from  the  first  and  return  the
99              resulting  complex  number.  If  there is only one argument, the
100              opposite of z1 is returned (i.e. -z1)
101
102              complex z1 (in)
103                     First argument in the subtraction
104
105              complex z2 (in)
106                     Second argument in the subtraction (optional)
107
108
109       ::math::complexnumbers::* z1 z2
110              Multiply the two arguments and return the resulting complex num‐
111              ber
112
113              complex z1 (in)
114                     First argument in the multiplication
115
116              complex z2 (in)
117                     Second argument in the multiplication
118
119
120       ::math::complexnumbers::/ z1 z2
121              Divide the first argument by the second and return the resulting
122              complex number
123
124              complex z1 (in)
125                     First argument (numerator) in the division
126
127              complex z2 (in)
128                     Second argument (denominator) in the division
129
130
131       ::math::complexnumbers::conj z1
132              Return the conjugate of the given complex number
133
134              complex z1 (in)
135                     Complex number in question
136
137
138       Conversion/inquiry procedures:
139
140       ::math::complexnumbers::real z1
141              Return the real part of the given complex number
142
143              complex z1 (in)
144                     Complex number in question
145
146
147       ::math::complexnumbers::imag z1
148              Return the imaginary part of the given complex number
149
150              complex z1 (in)
151                     Complex number in question
152
153
154       ::math::complexnumbers::mod z1
155              Return the modulus of the given complex number
156
157              complex z1 (in)
158                     Complex number in question
159
160
161       ::math::complexnumbers::arg z1
162              Return the argument ("angle" in radians) of  the  given  complex
163              number
164
165              complex z1 (in)
166                     Complex number in question
167
168
169       ::math::complexnumbers::complex real imag
170              Construct the complex number "real + imag*i" and return it
171
172              float real (in)
173                     The real part of the new complex number
174
175              float imag (in)
176                     The imaginary part of the new complex number
177
178
179       ::math::complexnumbers::tostring z1
180              Convert  the  complex  number  to  the  form "real + imag*i" and
181              return the string
182
183              float complex (in)
184                     The complex number to be converted
185
186
187       Elementary functions:
188
189       ::math::complexnumbers::exp z1
190              Calculate the exponential for the  given  complex  argument  and
191              return the result
192
193              complex z1 (in)
194                     The complex argument for the function
195
196
197       ::math::complexnumbers::sin z1
198              Calculate  the  sine function for the given complex argument and
199              return the result
200
201              complex z1 (in)
202                     The complex argument for the function
203
204
205       ::math::complexnumbers::cos z1
206              Calculate the cosine function for the given complex argument and
207              return the result
208
209              complex z1 (in)
210                     The complex argument for the function
211
212
213       ::math::complexnumbers::tan z1
214              Calculate  the  tangent  function for the given complex argument
215              and return the result
216
217              complex z1 (in)
218                     The complex argument for the function
219
220
221       ::math::complexnumbers::log z1
222              Calculate the (principle value of the) logarithm for  the  given
223              complex argument and return the result
224
225              complex z1 (in)
226                     The complex argument for the function
227
228
229       ::math::complexnumbers::sqrt z1
230              Calculate the (principle value of the) square root for the given
231              complex argument and return the result
232
233              complex z1 (in)
234                     The complex argument for the function
235
236
237       ::math::complexnumbers::pow z1 z2
238              Calculate "z1 to the power of z2" and return the result
239
240              complex z1 (in)
241                     The complex number to be raised to a power
242
243              complex z2 (in)
244                     The complex power to be used
245

BUGS, IDEAS, FEEDBACK

247       This document, and the package it describes, will  undoubtedly  contain
248       bugs  and  other  problems.  Please report such in the category math ::
249       complexnumbers         of         the          Tcllib          Trackers
250       [http://core.tcl.tk/tcllib/reportlist].   Please  also report any ideas
251       for enhancements you may have for either package and/or documentation.
252
253       When proposing code changes, please provide unified diffs, i.e the out‐
254       put of diff -u.
255
256       Note  further  that  attachments  are  strongly  preferred over inlined
257       patches. Attachments can be made by going  to  the  Edit  form  of  the
258       ticket  immediately  after  its  creation, and then using the left-most
259       button in the secondary navigation bar.
260

KEYWORDS

262       complex numbers, math
263

CATEGORY

265       Mathematics
266
268       Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net>
269
270
271
272
273tcllib                               1.0.2             math::complexnumbers(n)
Impressum