Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / Math / Complex.html
blob3b651dedab1f6f54a5cc4b7fddb6ca82f1ad9455
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>Math::Complex - complex numbers and associated mathematical functions</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;Math::Complex - complex numbers and associated mathematical functions</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <li><a href="#operations">OPERATIONS</a></li>
26 <li><a href="#creation">CREATION</a></li>
27 <li><a href="#displaying">DISPLAYING</a></li>
28 <ul>
30 <li><a href="#changed_in_perl_5_6">CHANGED IN PERL 5.6</a></li>
31 </ul>
33 <li><a href="#usage">USAGE</a></li>
34 <li><a href="#errors_due_to_division_by_zero_or_logarithm_of_zero">ERRORS DUE TO DIVISION BY ZERO OR LOGARITHM OF ZERO</a></li>
35 <li><a href="#errors_due_to_indigestible_arguments">ERRORS DUE TO INDIGESTIBLE ARGUMENTS</a></li>
36 <li><a href="#bugs">BUGS</a></li>
37 <li><a href="#authors">AUTHORS</a></li>
38 </ul>
39 <!-- INDEX END -->
41 <hr />
42 <p>
43 </p>
44 <hr />
45 <h1><a name="name">NAME</a></h1>
46 <p>Math::Complex - complex numbers and associated mathematical functions</p>
47 <p>
48 </p>
49 <hr />
50 <h1><a name="synopsis">SYNOPSIS</a></h1>
51 <pre>
52 use Math::Complex;</pre>
53 <pre>
54 $z = Math::Complex-&gt;make(5, 6);
55 $t = 4 - 3*i + $z;
56 $j = cplxe(1, 2*pi/3);</pre>
57 <p>
58 </p>
59 <hr />
60 <h1><a name="description">DESCRIPTION</a></h1>
61 <p>This package lets you create and manipulate complex numbers. By default,
62 <em>Perl</em> limits itself to real numbers, but an extra <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_use"><code>use</code></a> statement brings
63 full complex support, along with a full set of mathematical functions
64 typically associated with and/or extended to complex numbers.</p>
65 <p>If you wonder what complex numbers are, they were invented to be able to solve
66 the following equation:</p>
67 <pre>
68 x*x = -1</pre>
69 <p>and by definition, the solution is noted <em>i</em> (engineers use <em>j</em> instead since
70 <em>i</em> usually denotes an intensity, but the name does not matter). The number
71 <em>i</em> is a pure <em>imaginary</em> number.</p>
72 <p>The arithmetics with pure imaginary numbers works just like you would expect
73 it with real numbers... you just have to remember that</p>
74 <pre>
75 i*i = -1</pre>
76 <p>so you have:</p>
77 <pre>
78 5i + 7i = i * (5 + 7) = 12i
79 4i - 3i = i * (4 - 3) = i
80 4i * 2i = -8
81 6i / 2i = 3
82 1 / i = -i</pre>
83 <p>Complex numbers are numbers that have both a real part and an imaginary
84 part, and are usually noted:</p>
85 <pre>
86 a + bi</pre>
87 <p>where <code>a</code> is the <em>real</em> part and <a href="file://C|\msysgit\mingw\html/pod/perlguts.html#item_b"><code>b</code></a> is the <em>imaginary</em> part. The
88 arithmetic with complex numbers is straightforward. You have to
89 keep track of the real and the imaginary parts, but otherwise the
90 rules used for real numbers just apply:</p>
91 <pre>
92 (4 + 3i) + (5 - 2i) = (4 + 5) + i(3 - 2) = 9 + i
93 (2 + i) * (4 - i) = 2*4 + 4i -2i -i*i = 8 + 2i + 1 = 9 + 2i</pre>
94 <p>A graphical representation of complex numbers is possible in a plane
95 (also called the <em>complex plane</em>, but it's really a 2D plane).
96 The number</p>
97 <pre>
98 z = a + bi</pre>
99 <p>is the point whose coordinates are (a, b). Actually, it would
100 be the vector originating from (0, 0) to (a, b). It follows that the addition
101 of two complex numbers is a vectorial addition.</p>
102 <p>Since there is a bijection between a point in the 2D plane and a complex
103 number (i.e. the mapping is unique and reciprocal), a complex number
104 can also be uniquely identified with polar coordinates:</p>
105 <pre>
106 [rho, theta]</pre>
107 <p>where <code>rho</code> is the distance to the origin, and <code>theta</code> the angle between
108 the vector and the <em>x</em> axis. There is a notation for this using the
109 exponential form, which is:</p>
110 <pre>
111 rho * exp(i * theta)</pre>
112 <p>where <em>i</em> is the famous imaginary number introduced above. Conversion
113 between this form and the cartesian form <code>a + bi</code> is immediate:</p>
114 <pre>
115 a = rho * cos(theta)
116 b = rho * sin(theta)</pre>
117 <p>which is also expressed by this formula:</p>
118 <pre>
119 z = rho * exp(i * theta) = rho * (cos theta + i * sin theta)</pre>
120 <p>In other words, it's the projection of the vector onto the <em>x</em> and <em>y</em>
121 axes. Mathematicians call <em>rho</em> the <em>norm</em> or <em>modulus</em> and <em>theta</em>
122 the <em>argument</em> of the complex number. The <em>norm</em> of <code>z</code> will be
123 noted <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs(z)</code></a>.</p>
124 <p>The polar notation (also known as the trigonometric
125 representation) is much more handy for performing multiplications and
126 divisions of complex numbers, whilst the cartesian notation is better
127 suited for additions and subtractions. Real numbers are on the <em>x</em>
128 axis, and therefore <em>theta</em> is zero or <em>pi</em>.</p>
129 <p>All the common operations that can be performed on a real number have
130 been defined to work on complex numbers as well, and are merely
131 <em>extensions</em> of the operations defined on real numbers. This means
132 they keep their natural meaning when there is no imaginary part, provided
133 the number is within their definition set.</p>
134 <p>For instance, the <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_sqrt"><code>sqrt</code></a> routine which computes the square root of
135 its argument is only defined for non-negative real numbers and yields a
136 non-negative real number (it is an application from <strong>R+</strong> to <strong>R+</strong>).
137 If we allow it to return a complex number, then it can be extended to
138 negative real numbers to become an application from <strong>R</strong> to <strong>C</strong> (the
139 set of complex numbers):</p>
140 <pre>
141 sqrt(x) = x &gt;= 0 ? sqrt(x) : sqrt(-x)*i</pre>
142 <p>It can also be extended to be an application from <strong>C</strong> to <strong>C</strong>,
143 whilst its restriction to <strong>R</strong> behaves as defined above by using
144 the following definition:</p>
145 <pre>
146 sqrt(z = [r,t]) = sqrt(r) * exp(i * t/2)</pre>
147 <p>Indeed, a negative real number can be noted <code>[x,pi]</code> (the modulus
148 <em>x</em> is always non-negative, so <code>[x,pi]</code> is really <code>-x</code>, a negative
149 number) and the above definition states that</p>
150 <pre>
151 sqrt([x,pi]) = sqrt(x) * exp(i*pi/2) = [sqrt(x),pi/2] = sqrt(x)*i</pre>
152 <p>which is exactly what we had defined for negative real numbers above.
153 The <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_sqrt"><code>sqrt</code></a> returns only one of the solutions: if you want the both,
154 use the <code>root</code> function.</p>
155 <p>All the common mathematical functions defined on real numbers that
156 are extended to complex numbers share that same property of working
157 <em>as usual</em> when the imaginary part is zero (otherwise, it would not
158 be called an extension, would it?).</p>
159 <p>A <em>new</em> operation possible on a complex number that is
160 the identity for real numbers is called the <em>conjugate</em>, and is noted
161 with a horizontal bar above the number, or <code>~z</code> here.</p>
162 <pre>
163 z = a + bi
164 ~z = a - bi</pre>
165 <p>Simple... Now look:</p>
166 <pre>
167 z * ~z = (a + bi) * (a - bi) = a*a + b*b</pre>
168 <p>We saw that the norm of <code>z</code> was noted <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs(z)</code></a> and was defined as the
169 distance to the origin, also known as:</p>
170 <pre>
171 rho = abs(z) = sqrt(a*a + b*b)</pre>
172 <p>so</p>
173 <pre>
174 z * ~z = abs(z) ** 2</pre>
175 <p>If z is a pure real number (i.e. <code>b == 0</code>), then the above yields:</p>
176 <pre>
177 a * a = abs(a) ** 2</pre>
178 <p>which is true (<a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs</code></a> has the regular meaning for real number, i.e. stands
179 for the absolute value). This example explains why the norm of <code>z</code> is
180 noted <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs(z)</code></a>: it extends the <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs</code></a> function to complex numbers, yet
181 is the regular <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs</code></a> we know when the complex number actually has no
182 imaginary part... This justifies <em>a posteriori</em> our use of the <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs</code></a>
183 notation for the norm.</p>
185 </p>
186 <hr />
187 <h1><a name="operations">OPERATIONS</a></h1>
188 <p>Given the following notations:</p>
189 <pre>
190 z1 = a + bi = r1 * exp(i * t1)
191 z2 = c + di = r2 * exp(i * t2)
192 z = &lt;any complex or real number&gt;</pre>
193 <p>the following (overloaded) operations are supported on complex numbers:</p>
194 <pre>
195 z1 + z2 = (a + c) + i(b + d)
196 z1 - z2 = (a - c) + i(b - d)
197 z1 * z2 = (r1 * r2) * exp(i * (t1 + t2))
198 z1 / z2 = (r1 / r2) * exp(i * (t1 - t2))
199 z1 ** z2 = exp(z2 * log z1)
200 ~z = a - bi
201 abs(z) = r1 = sqrt(a*a + b*b)
202 sqrt(z) = sqrt(r1) * exp(i * t/2)
203 exp(z) = exp(a) * exp(i * b)
204 log(z) = log(r1) + i*t
205 sin(z) = 1/2i (exp(i * z1) - exp(-i * z))
206 cos(z) = 1/2 (exp(i * z1) + exp(-i * z))
207 atan2(y, x) = atan(y / x) # Minding the right quadrant, note the order.</pre>
208 <p>The definition used for complex arguments of <code>atan2()</code> is</p>
209 <pre>
210 -i log((x + iy)/sqrt(x*x+y*y))</pre>
211 <p>The following extra operations are supported on both real and complex
212 numbers:</p>
213 <pre>
214 Re(z) = a
215 Im(z) = b
216 arg(z) = t
217 abs(z) = r</pre>
218 <pre>
219 cbrt(z) = z ** (1/3)
220 log10(z) = log(z) / log(10)
221 logn(z, n) = log(z) / log(n)</pre>
222 <pre>
223 tan(z) = sin(z) / cos(z)</pre>
224 <pre>
225 csc(z) = 1 / sin(z)
226 sec(z) = 1 / cos(z)
227 cot(z) = 1 / tan(z)</pre>
228 <pre>
229 asin(z) = -i * log(i*z + sqrt(1-z*z))
230 acos(z) = -i * log(z + i*sqrt(1-z*z))
231 atan(z) = i/2 * log((i+z) / (i-z))</pre>
232 <pre>
233 acsc(z) = asin(1 / z)
234 asec(z) = acos(1 / z)
235 acot(z) = atan(1 / z) = -i/2 * log((i+z) / (z-i))</pre>
236 <pre>
237 sinh(z) = 1/2 (exp(z) - exp(-z))
238 cosh(z) = 1/2 (exp(z) + exp(-z))
239 tanh(z) = sinh(z) / cosh(z) = (exp(z) - exp(-z)) / (exp(z) + exp(-z))</pre>
240 <pre>
241 csch(z) = 1 / sinh(z)
242 sech(z) = 1 / cosh(z)
243 coth(z) = 1 / tanh(z)</pre>
244 <pre>
245 asinh(z) = log(z + sqrt(z*z+1))
246 acosh(z) = log(z + sqrt(z*z-1))
247 atanh(z) = 1/2 * log((1+z) / (1-z))</pre>
248 <pre>
249 acsch(z) = asinh(1 / z)
250 asech(z) = acosh(1 / z)
251 acoth(z) = atanh(1 / z) = 1/2 * log((1+z) / (z-1))</pre>
252 <p><em>arg</em>, <em>abs</em>, <em>log</em>, <em>csc</em>, <em>cot</em>, <em>acsc</em>, <em>acot</em>, <em>csch</em>,
253 <em>coth</em>, <em>acosech</em>, <em>acotanh</em>, have aliases <em>rho</em>, <em>theta</em>, <em>ln</em>,
254 <em>cosec</em>, <em>cotan</em>, <em>acosec</em>, <em>acotan</em>, <em>cosech</em>, <em>cotanh</em>,
255 <em>acosech</em>, <em>acotanh</em>, respectively. <code>Re</code>, <code>Im</code>, <code>arg</code>, <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_abs"><code>abs</code></a>,
256 <code>rho</code>, and <code>theta</code> can be used also as mutators. The <code>cbrt</code>
257 returns only one of the solutions: if you want all three, use the
258 <code>root</code> function.</p>
259 <p>The <em>root</em> function is available to compute all the <em>n</em>
260 roots of some complex, where <em>n</em> is a strictly positive integer.
261 There are exactly <em>n</em> such roots, returned as a list. Getting the
262 number mathematicians call <code>j</code> such that:</p>
263 <pre>
264 1 + j + j*j = 0;</pre>
265 <p>is a simple matter of writing:</p>
266 <pre>
267 $j = ((root(1, 3))[1];</pre>
268 <p>The <em>k</em>th root for <code>z = [r,t]</code> is given by:</p>
269 <pre>
270 (root(z, n))[k] = r**(1/n) * exp(i * (t + 2*k*pi)/n)</pre>
271 <p>You can return the <em>k</em>th root directly by <code>root(z, n, k)</code>,
272 indexing starting from <em>zero</em> and ending at <em>n - 1</em>.</p>
273 <p>The <em>spaceship</em> comparison operator, &lt;=&gt;, is also defined. In
274 order to ensure its restriction to real numbers is conform to what you
275 would expect, the comparison is run on the real part of the complex
276 number first, and imaginary parts are compared only when the real
277 parts match.</p>
279 </p>
280 <hr />
281 <h1><a name="creation">CREATION</a></h1>
282 <p>To create a complex number, use either:</p>
283 <pre>
284 $z = Math::Complex-&gt;make(3, 4);
285 $z = cplx(3, 4);</pre>
286 <p>if you know the cartesian form of the number, or</p>
287 <pre>
288 $z = 3 + 4*i;</pre>
289 <p>if you like. To create a number using the polar form, use either:</p>
290 <pre>
291 $z = Math::Complex-&gt;emake(5, pi/3);
292 $x = cplxe(5, pi/3);</pre>
293 <p>instead. The first argument is the modulus, the second is the angle
294 (in radians, the full circle is 2*pi). (Mnemonic: <code>e</code> is used as a
295 notation for complex numbers in the polar form).</p>
296 <p>It is possible to write:</p>
297 <pre>
298 $x = cplxe(-3, pi/4);</pre>
299 <p>but that will be silently converted into <code>[3,-3pi/4]</code>, since the
300 modulus must be non-negative (it represents the distance to the origin
301 in the complex plane).</p>
302 <p>It is also possible to have a complex number as either argument of the
303 <code>make</code>, <code>emake</code>, <code>cplx</code>, and <code>cplxe</code>: the appropriate component of
304 the argument will be used.</p>
305 <pre>
306 $z1 = cplx(-2, 1);
307 $z2 = cplx($z1, 4);</pre>
308 <p>The <code>new</code>, <code>make</code>, <code>emake</code>, <code>cplx</code>, and <code>cplxe</code> will also
309 understand a single (string) argument of the forms</p>
310 <pre>
311 2-3i
313 [2,3]
314 [2,-3pi/4]
315 [2]</pre>
316 <p>in which case the appropriate cartesian and exponential components
317 will be parsed from the string and used to create new complex numbers.
318 The imaginary component and the theta, respectively, will default to zero.</p>
319 <p>The <code>new</code>, <code>make</code>, <code>emake</code>, <code>cplx</code>, and <code>cplxe</code> will also
320 understand the case of no arguments: this means plain zero or (0, 0).</p>
322 </p>
323 <hr />
324 <h1><a name="displaying">DISPLAYING</a></h1>
325 <p>When printed, a complex number is usually shown under its cartesian
326 style <em>a+bi</em>, but there are legitimate cases where the polar style
327 <em>[r,t]</em> is more appropriate. The process of converting the complex
328 number into a string that can be displayed is known as <em>stringification</em>.</p>
329 <p>By calling the class method <code>Math::Complex::display_format</code> and
330 supplying either <code>&quot;polar&quot;</code> or <code>&quot;cartesian&quot;</code> as an argument, you
331 override the default display style, which is <code>&quot;cartesian&quot;</code>. Not
332 supplying any argument returns the current settings.</p>
333 <p>This default can be overridden on a per-number basis by calling the
334 <code>display_format</code> method instead. As before, not supplying any argument
335 returns the current display style for this number. Otherwise whatever you
336 specify will be the new display style for <em>this</em> particular number.</p>
337 <p>For instance:</p>
338 <pre>
339 use Math::Complex;</pre>
340 <pre>
341 Math::Complex::display_format('polar');
342 $j = (root(1, 3))[1];
343 print &quot;j = $j\n&quot;; # Prints &quot;j = [1,2pi/3]&quot;
344 $j-&gt;display_format('cartesian');
345 print &quot;j = $j\n&quot;; # Prints &quot;j = -0.5+0.866025403784439i&quot;</pre>
346 <p>The polar style attempts to emphasize arguments like <em>k*pi/n</em>
347 (where <em>n</em> is a positive integer and <em>k</em> an integer within [-9, +9]),
348 this is called <em>polar pretty-printing</em>.</p>
349 <p>For the reverse of stringifying, see the <code>make</code> and <code>emake</code>.</p>
351 </p>
352 <h2><a name="changed_in_perl_5_6">CHANGED IN PERL 5.6</a></h2>
353 <p>The <code>display_format</code> class method and the corresponding
354 <code>display_format</code> object method can now be called using
355 a parameter hash instead of just a one parameter.</p>
356 <p>The old display format style, which can have values <code>&quot;cartesian&quot;</code> or
357 <code>&quot;polar&quot;</code>, can be changed using the <code>&quot;style&quot;</code> parameter.</p>
358 <pre>
359 $j-&gt;display_format(style =&gt; &quot;polar&quot;);</pre>
360 <p>The one parameter calling convention also still works.</p>
361 <pre>
362 $j-&gt;display_format(&quot;polar&quot;);</pre>
363 <p>There are two new display parameters.</p>
364 <p>The first one is <code>&quot;format&quot;</code>, which is a sprintf()-style format string
365 to be used for both numeric parts of the complex number(s). The is
366 somewhat system-dependent but most often it corresponds to <code>&quot;%.15g&quot;</code>.
367 You can revert to the default by setting the <code>format</code> to <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
368 <pre>
369 # the $j from the above example</pre>
370 <pre>
371 $j-&gt;display_format('format' =&gt; '%.5f');
372 print &quot;j = $j\n&quot;; # Prints &quot;j = -0.50000+0.86603i&quot;
373 $j-&gt;display_format('format' =&gt; undef);
374 print &quot;j = $j\n&quot;; # Prints &quot;j = -0.5+0.86603i&quot;</pre>
375 <p>Notice that this affects also the return values of the
376 <code>display_format</code> methods: in list context the whole parameter hash
377 will be returned, as opposed to only the style parameter value.
378 This is a potential incompatibility with earlier versions if you
379 have been calling the <code>display_format</code> method in list context.</p>
380 <p>The second new display parameter is <code>&quot;polar_pretty_print&quot;</code>, which can
381 be set to true or false, the default being true. See the previous
382 section for what this means.</p>
384 </p>
385 <hr />
386 <h1><a name="usage">USAGE</a></h1>
387 <p>Thanks to overloading, the handling of arithmetics with complex numbers
388 is simple and almost transparent.</p>
389 <p>Here are some examples:</p>
390 <pre>
391 use Math::Complex;</pre>
392 <pre>
393 $j = cplxe(1, 2*pi/3); # $j ** 3 == 1
394 print &quot;j = $j, j**3 = &quot;, $j ** 3, &quot;\n&quot;;
395 print &quot;1 + j + j**2 = &quot;, 1 + $j + $j**2, &quot;\n&quot;;</pre>
396 <pre>
397 $z = -16 + 0*i; # Force it to be a complex
398 print &quot;sqrt($z) = &quot;, sqrt($z), &quot;\n&quot;;</pre>
399 <pre>
400 $k = exp(i * 2*pi/3);
401 print &quot;$j - $k = &quot;, $j - $k, &quot;\n&quot;;</pre>
402 <pre>
403 $z-&gt;Re(3); # Re, Im, arg, abs,
404 $j-&gt;arg(2); # (the last two aka rho, theta)
405 # can be used also as mutators.</pre>
407 </p>
408 <hr />
409 <h1><a name="errors_due_to_division_by_zero_or_logarithm_of_zero">ERRORS DUE TO DIVISION BY ZERO OR LOGARITHM OF ZERO</a></h1>
410 <p>The division (/) and the following functions</p>
411 <pre>
412 log ln log10 logn
413 tan sec csc cot
414 atan asec acsc acot
415 tanh sech csch coth
416 atanh asech acsch acoth</pre>
417 <p>cannot be computed for all arguments because that would mean dividing
418 by zero or taking logarithm of zero. These situations cause fatal
419 runtime errors looking like this</p>
420 <pre>
421 cot(0): Division by zero.
422 (Because in the definition of cot(0), the divisor sin(0) is 0)
423 Died at ...</pre>
424 <p>or</p>
425 <pre>
426 atanh(-1): Logarithm of zero.
427 Died at...</pre>
428 <p>For the <code>csc</code>, <code>cot</code>, <code>asec</code>, <code>acsc</code>, <code>acot</code>, <code>csch</code>, <code>coth</code>,
429 <code>asech</code>, <code>acsch</code>, the argument cannot be <code>0</code> (zero). For the
430 logarithmic functions and the <code>atanh</code>, <code>acoth</code>, the argument cannot
431 be <code>1</code> (one). For the <code>atanh</code>, <code>acoth</code>, the argument cannot be
432 <code>-1</code> (minus one). For the <code>atan</code>, <code>acot</code>, the argument cannot be
433 <code>i</code> (the imaginary unit). For the <code>atan</code>, <code>acoth</code>, the argument
434 cannot be <code>-i</code> (the negative imaginary unit). For the <code>tan</code>,
435 <code>sec</code>, <code>tanh</code>, the argument cannot be <em>pi/2 + k * pi</em>, where <em>k</em>
436 is any integer. atan2(0, 0) is undefined, and if the complex arguments
437 are used for atan2(), a division by zero will happen if z1**2+z2**2 == 0.</p>
438 <p>Note that because we are operating on approximations of real numbers,
439 these errors can happen when merely `too close' to the singularities
440 listed above.</p>
442 </p>
443 <hr />
444 <h1><a name="errors_due_to_indigestible_arguments">ERRORS DUE TO INDIGESTIBLE ARGUMENTS</a></h1>
445 <p>The <code>make</code> and <code>emake</code> accept both real and complex arguments.
446 When they cannot recognize the arguments they will die with error
447 messages like the following</p>
448 <pre>
449 Math::Complex::make: Cannot take real part of ...
450 Math::Complex::make: Cannot take real part of ...
451 Math::Complex::emake: Cannot take rho of ...
452 Math::Complex::emake: Cannot take theta of ...</pre>
454 </p>
455 <hr />
456 <h1><a name="bugs">BUGS</a></h1>
457 <p>Saying <code>use Math::Complex;</code> exports many mathematical routines in the
458 caller environment and even overrides some (<a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_sqrt"><code>sqrt</code></a>, <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_log"><code>log</code></a>, <code>atan2</code>).
459 This is construed as a feature by the Authors, actually... ;-)</p>
460 <p>All routines expect to be given real or complex numbers. Don't attempt to
461 use BigFloat, since Perl has currently no rule to disambiguate a '+'
462 operation (for instance) between two overloaded entities.</p>
463 <p>In Cray UNICOS there is some strange numerical instability that results
464 in root(), cos(), sin(), cosh(), sinh(), losing accuracy fast. Beware.
465 The bug may be in UNICOS math libs, in UNICOS C compiler, in Math::Complex.
466 Whatever it is, it does not manifest itself anywhere else where Perl runs.</p>
468 </p>
469 <hr />
470 <h1><a name="authors">AUTHORS</a></h1>
471 <p>Daniel S. Lewart &lt;<em><a href="mailto:d-lewart@uiuc.edu">d-lewart@uiuc.edu</a></em>&gt;</p>
472 <p>Original authors Raphael Manfredi &lt;<em><a href="mailto:Raphael_Manfredi@pobox.com">Raphael_Manfredi@pobox.com</a></em>&gt; and
473 Jarkko Hietaniemi &lt;<em><a href="mailto:jhi@iki.fi">jhi@iki.fi</a></em>&gt;</p>
474 <table border="0" width="100%" cellspacing="0" cellpadding="3">
475 <tr><td class="block" style="background-color: #cccccc" valign="middle">
476 <big><strong><span class="block">&nbsp;Math::Complex - complex numbers and associated mathematical functions</span></strong></big>
477 </td></tr>
478 </table>
480 </body>
482 </html>