Also note that the functions defined in cmath always return a Curated by the Real Python team. How to deal with "online" status competition at work? log(). The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; thats asking for huge disappointments down the road. Fitting data to Faddeeva function using python's optimize.leastsq() and optimize.curve_fit, Scale the real part of complex numpy array, Convert complex NumPy array into (n, 2)-array of real and imaginary parts. Lets see an example in practice: Youve got two vectors identified by four distinct points. ), The state of the art For example, when you consider a point on a unit circle whose radius is equal to one and is tilted at 60, then the trigonometry works out nicely, making the conversion with pen and paper straightforward: Even though you know that z1 and z2 are the same point, Python cant determine that because of the rounding errors. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. For example, a fourth-degree polynomial x4 + 1, which can be written as an equation x4 = -1, has these four complex roots: Raising each root to the fourth power results in a complex number equal to -1 + 0j or a real number -1: Youll notice that the resulting value isnt exactly -1 due to the rounding error in floating-point arithmetic. Does the policy change for AI-generated content affect users who (want to) How to parametrize a complex number in terms of variables in python. For example, the cmath.sqrt() function has a branch cut along the Efficiently match all values of a vector in another vector. Asking for help, clarification, or responding to other answers. Heres how the triangle will look when you flip it along both axes: Scaling is similar to translating, but instead of adding an offset, youre going to multiply each vertex by a constant factor, which must be a real number: Doing so results in multiplying both components of each complex number by the same amount. +1: Very lucid explanation of the limitations of the method. Connect and share knowledge within a single location that is structured and easy to search. When you multiply the vertices by the imaginary unit, it will rotate the triangle 90 counterclockwise. The modulus r is the distance The rules that youll learn about will make this straightforward. See also real_if_close, imag, angle Examples Return True if the values a and b are close to each other and Notice how Python displays complex numbers by default. Instead, its defined as matrix multiplication in a two-dimensional vector space, with 1 and j as the standard basis. Python complex numbers have only three public members. Python lets you use complex numbers in arithmetic expressions and call functions on them just like you would with other numbers in Python. Mathematically, two complex numbers are equal when they have identical values irrespective of the adopted coordinate system. Equivalent to complex(0.0, float('inf')). To answer these questions, lets run some experiments. If you removed the letter, youd get a familiar integer result instead: By the way, you can use floating-point numbers to create complex numbers, too: Complex number literals in Python mimic the mathematical notation, which is also known as the standard form, the algebraic form, or sometimes the canonical form, of a complex number. We take your privacy seriously. There is no Multiplying (x1 + y1j) by (x2 + y2j) corresponds to the following matrix multiplication: This is the rotation matrix on the left, which makes the math work out just fine. The angle is commonly referred to as the phase or argument of a complex number. The angular frequency of the wave can be calculated by multiplying the round angle, which is 2 radians, by k over the number of discrete samples: Coding this in Python looks quite neat when you take advantage of the complex data type: This function is a literal transcription of the formulas above. Is there any philosophical theory behind the concept of object in computer science? Following Kahans Branch cuts for The product of two or more complex numbers gets more interesting: How on Earth did you end up with a negative number out of only positive ones? To answer this question, you have to recall the definition of the imaginary unit and rewrite the expression in terms of real and imaginary parts: The key observation to make is that j times j gives j2, which can be replaced with -1. The following functions can be used to convert from the native rectangular coordinates to polar coordinates and back. Youve saved yourself from typing a lot of error-prone code by piggybacking on the complex numbers and a bit of Python magic. Return the phase of x (also known as the argument of x), as a float. abs_tol must be at least zero. In such a case, you can use the unary minus operator in front of the complex number to flip its real and imaginary parts: Go ahead and fiddle with the different flip combinations using the interactive Jupyter Notebook available in the downloadable materials. inf and -inf are only Creating a complex 2D-array from two 2D-real-arrays ? Returns a Heres a sample frequency plot of a sound wave comprising three tones440 Hz, 1.5 kHz, and 5 kHzhaving equal amplitudes: Note this was a purely academic example since calculating the discrete Fourier transform with nested iterations has O(n2) time complexity, making it unusable in practice. Equivalent to r * (math.cos(phi) + math.sin(phi)*1j). complex() can't take second arg if first is a string, (-0.13041489185767086-0.11115341486478239j), type complex doesn't define __round__ method, # Coefficients of the polynomial x**4 + 1. array([-0.70710678+0.70710678j, -0.70710678-0.70710678j, 0.70710678+0.70710678j, 0.70710678-0.70710678j]), '<' not supported between instances of 'complex' and 'complex', Calculating the Conjugate of a Complex Number, Using Python Complex Numbers as 2D Vectors, Translating, Flipping, Scaling, and Rotating, Exploring the Math Module for Complex Numbers: cmath, Converting Between Rectangular and Polar Coordinates, Calculating the Discrete Fourier Transform With Complex Numbers, Click here to get the sample code youll use, get answers to common questions in our support portal, Its a convention already adopted by engineers to avoid name collisions with electric current, which is denoted with the letter. For information of the proper choice of branch False otherwise. One extends from 1j along the imaginary axis to j. Note that the string cant contain any whitespace, though: Later, youll find out how to make your classes compatible with this type casting mechanism. The other case the complex number has an imaginary part of zero). The reason for having two modules is that some users arent In this section, youre going to look into comparing complex numbers, formatting strings that contain them, and more. intermediate Thats why youre seeing a solitary False in the output above. For example, you can pass a nonnumeric value like a string literal to obtain a corresponding complex object. Does the conduit for a wall oven need to be pulled inside the cabinet? @Duncan: I added two other solutions: it may be worth to time them too. Minimize is returning unevaluated for a simple positive integer domain problem. Can you identify this fighter from the silhouette? Next, you pass them directly to cmath.phase(), which does the conversion to a complex number for you and returns the phase. Lets move it so that its geometric center aligns with the origin. In Portrait of the Artist as a Young Man, how can the reader intuit the meaning of "champagne" in the first chapter? Python is a rare exception because it comes with complex numbers built in. Heres a quick rundown of the individual complex number forms and their coordinates: The algebraic form is native to Python when you specify complex numbers using their literals. The analogy isnt that far-fetched. To create a complex number without the imaginary part, you can take advantage of zero and add or subtract it like so: In fact, both parts of the complex number are always there. Specifically, to get the polar coordinates of a complex number, you must pass it to cmath.polar(): It will return a tuple, where the first element is the radius and the second element is the angle in radians. When you dont see one, it means that it has a value of zero. This is only a partial duplicate of earlier answers like Pierre GM's or mine: I think that its only effect is to take people's time for almost no added value (beyond the example), so I would suggest that you delete it. be continuous. Complex numbers have a geometric interpretation in the Cartesian coordinate system that youll explore in a bit. define those functions on the cut itself. If you want to parse complex numbers using i instead of j, you have plenty of solutions available already. The explanation of why different forms of a complex number are equivalent requires calculus and goes far beyond the scope of this tutorial. In Return of the King has there been any explanation for the role of the third eagle? phase(x)). real axis to -. To find those roots, you can rewrite the function as a quadratic equation, then move the constant over to the right and take the square root of both sides: In the domain of real numbers, the square root is only defined for nonnegative input values. Did an AI-enabled drone attack the human operator in a simulation environment? They are a necessary feature of many complex functions. Additionally, the imaginary part comes second. The view method of the array changes the dtype of the array to reflect that you want to treat two adjacent floating point values as a single complex number and updates the dimension accordingly. Note that the radius has the same value as the magnitude, which you can calculate by calling abs() on your complex number. Why do some images depict the same constellations differently? When I use a.view(np.complex), the real values are also used for the complex values, messing up my further calculations, i.e. If you learned about complex numbers in math class, you might have seen them expressed using an i instead of a j. why doesnt spaceX sell raptor engines commercially. Is it possible to raise the frequency of command input to the processor in this way? +1. Making statements based on opinion; back them up with references or personal experience. Similarly, you can use the string modulo operator (%) with either a tuple or a dictionary: However, this uses a different placeholder syntax and is slightly old-fashioned. Did an AI-enabled drone attack the human operator in a simulation environment? close to any other value, including NaN. (Source). Numpy: Creating a complex array from 2 real ones? Are they ordered? Can I also say: 'ich tut mir leid' instead of 'es tut mir leid'? Now you can call cmath.rect() correctly: You might encounter rounding errors along the way while Python makes the calculations. Return True if either the real or the imaginary part of x is a NaN, csv_string = output.getvalue() The mathematical constant , as a float. number. specified, returns the natural logarithm of x. Multiplication Division Exponentiation Using Python Complex Numbers as 2D Vectors Getting the Coordinates Calculating the Magnitude Finding the Distance Between Two Points Translating, Flipping, Scaling, and Rotating Exploring the Math Module for Complex Numbers: cmath Extracting the Root of a Complex Number It is One of the Jupyter Notebooks accompanying this tutorial lets you play with audio synthesis and analysis interactively. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Should their magnitudes be compared? cuts for numerical purposes, a good reference should be the following: Kahan, W: Branch cuts for complex elementary functions; or, Much ado about imaginary axis we look at the sign of the real part. Can I takeoff as VFR from class G with 2sm vis. would rather have math.sqrt(-1) raise an exception than return a complex While the depth is weak and it doesn't deserve a checkmark, this example got me fastest to what I needed. Returns the logarithm of x to the given base. On the other hand, atan2() expects two arguments instead of one to preserve the individual signs before dividing one by another and avoids other problems as well. What sound does the character 'u' in the Proto-Slavic word *bura (storm) represent? (eds. Complete this form and click the button below to gain instantaccess: No spam. Not the answer you're looking for? In other Note that you cant use built-in types directly in such a test: The difference between complex and numbers.Complex is that they belong to separate branches in the numeric type hierarchy tree, and the latter is an abstract base class without any implementation: Abstract base classes, which are denoted in red on the diagram above, can bypass the regular inheritance check mechanism by registering unrelated classes as their virtual subclasses. interested in complex numbers, and perhaps dont even know what they are. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, Same error I'm afraid: TypeError: only length-1 arrays can be converted to Python Scalars. On the other hand, you can describe the same point in polar coordinates that also let you find it unambiguously with two distances: The radius, also known as the modulus, corresponds to the complex numbers magnitude, or the vectors length. Find centralized, trusted content and collaborate around the technologies you use most. Lets see how that works. Things like A_comp[,np.newaxis].view(np.float64) do not currently work because, as of this writing, NumPy doesn't detect that the array is still C-contiguous when the new axis is added. How do I get the imaginary part (or real part) of an array in Python? There are two branch cuts: Meaning of 'Gift of Residue' section of a will. The default By clicking Post Your Answer, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct. This module provides access to mathematical functions for complex numbers. Building a safer community: Announcing our new Code of Conduct, Balancing a PhD program with a startup career (Ep. The team members who worked on this tutorial are: Master Real-World Python Skills With Unlimited Access to RealPython. What other interesting problems do you think theyll let you solve? This works because, in memory, a complex number is really just two floating point numbers. When would you want to use the complex() factory function over the literal? Surprisingly, the effect of using empty instead of zeros was negligible. Return the base-10 logarithm of x. Now you can run a frequency analysis on a sound that you load from an audio file using Pythons wave module or that you synthesize from scratch. PEP 485 A function for testing approximate equality. Its vertices are approximately designated by the three major cities whose geographical coordinates are the following: After converting these coordinates to decimal degrees, youll end up with two floating-point numbers for each city. Not the answer you're looking for? False otherwise. Conversions to and from polar coordinates. It's VERY slow though (as you might expect - as it's not really a numpy function), it takes 5 seconds per loop now instead of 0.1. To download the source code and materials for this tutorial, click the link below: If you dont like calling the complex() factory function, you can create a type alias with a better-suited name or use the literal form of a complex number to save a few keystrokes: If you needed to pack more attributes on a city, you could use a named tuple or a data class or create a custom class. Now calloc would do a memset to 0 but the time of this operation is extremely fast given it can be done with a single x86 assembly instruction e.g. The second part of your Python script should correspond to the creation of the VTK object containing your data. Unless you want to start using MATLAB, youll have to live with using j to denote your complex numbers. lies in the range [-, ], and the branch cut for this operation lies 1 Answer Sorted by: 8 Yes, use astype (): In [6]: b = a.astype (complex) In [7]: b Out [7]: array ( [ 1.+0.j, 2.+0.j, 3.+0.j]) In [8]: b.dtype Out [8]: dtype ('complex128') Share Improve this answer Follow answered Nov 18, 2015 at 16:15 xnx 24.2k 9 68 108 Add a comment Your Answer In polar coordinates, a complex number z is defined by the How much of the power drawn by a chip turns into heat? pair (r, phi) where r is the modulus of x and phi is the along the negative real axis. Return the inverse hyperbolic tangent of x. separate cmath module function for this operation. No spam ever. You can visualize complex numbers as points or vectors on a Euclidean plane in the Cartesian or rectangular coordinate system: The X-axis on the complex plane, also known as the Gauss plane or Argand diagram, represents the real part of a complex number, while the Y-axis represents its imaginary part. The cmath module redefines all floating-point constants from math so that theyre at your fingertips without the need to import both modules: Note that nan is a special value which is never equal to anything else, including itself! segment that joins the origin to z. Find centralized, trusted content and collaborate around the technologies you use most. Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas: Whats your #1 takeaway or favorite thing you learned? Note: I get the same speed with a variation of my last answer: I think this is the best answer because the intent is obvious when reading the code; Eric's answers, while functionally correct, are less clear when reading back over the code. What has your experience been with Python complex numbers so far? For example, to determine if a value belongs to a specific set of numbers, you can call isinstance() on it: The floating-point value 3.14 is a real number that also happens to be a complex number but not an integral one. To get degrees instead of radians, you can make the necessary conversion using the math module again: Reversing the processthat is, converting polar to rectangular coordinatesrelies on another function. More advanced functions for complex numbers are defined in the cmath module, which is part of the standard library. The mathematical formula for finding all complex roots takes advantage of the trigonometric form of complex numbers: The r and are polar coordinates of the complex number, while n is the polynomials degree, and k is the roots index, starting at zero. First, take a look at the following table, which summarizes the consecutive rotations by 90: When you express the repeated multiplication by j in terms of positive integer exponents, then a pattern emerges. Lets check what happens when you try stuffing more terms into the sum than before: This time, your expression is no longer a literal because Python evaluated it into a complex number comprising only two parts. Despite the name, complex numbers arent complicated! Subtracting complex numbers is analogous to adding them, which means you can also apply it element-wise: Unlike the sum, however, the order of operands is significant and yields different results just like with real numbers: You can also use the unary minus operator (-) to make the negative of a complex number: This inverts both the real and the imaginary parts of the complex number. How can an accidental cat scratch break skin but not damage clothes? For one thing, the letter i or upper case I look too much like digits. He helps his students get into software engineering by sharing over a decade of commercial experience in the IT industry. Cartoon series about a world-saving agent, who is an Indiana Jones and James Bond mixture. If val is real, the type of val is used for the output. How are you going to put your newfound skills to use? Well in the underlying framework, there will be a C call to malloc or calloc likely in either case. -1 along the real axis to -. Creating and manipulating complex numbers in Python isnt much different from other built-in data types, particularly numeric types. While you can use real numbers to calculate the sine and cosine coefficients of a periodic functions frequencies with the Fourier transform, its usually more convenient to deal with only one complex coefficient per frequency. The conversion between the two coordinate systems is made possible with a couple of functions buried in the cmath module. The first one represents the real part, while the second one represents the imaginary part denoted with the letter j in the literal you saw earlier: Both parameters are optional, with default values of zero, which makes it less clunky to define complex numbers without the imaginary part or both the real and imaginary parts: The single-argument version can be useful in type casting. By clicking Post Your Answer, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct. First, you need to sum all coordinates and divide the result by their count to take the average: This will give you a point located in the Atlantic Ocean, somewhere within the triangle: Now you can create vectors anchored in the cities and directed toward the geometric center of the triangle. Complex number with zero real part and positive infinity imaginary To avoid this, one should use a.real.astype(t . Note: To get correct amplitude values, you must double the number and divide the resulting magnitude by the sample count. There is one branch cut, Note: String formatting can let you ignore the floating-point representation error and pretend it doesnt exist: The letter "g" in the format specifier stands for general format, which rounds your number to the requested precision. Enabling a user to revert a hacked change in their email. Raises an auditing event array.__new__ with arguments typecode, initializer. Their textual representation contains an enclosing pair of parentheses, a lowercase letter j, and no whitespace. Complex numbers let you elegantly express mathematical formulas in code without much boilerplate syntax standing in the way. If youre familiar with tuples, then you know that Python can sort them: By default, the individual tuples are compared left to right: In the first case, the number 6 is greater than 4, so the planet names arent considered at all. rectangular coordinates to polar coordinates and back. They will also accept any Python object that has either a This has the same branch cut as Use cmath.isclose() for a safe comparison or format() the numbers as strings appropriately. If you need a quick refresher or a gentle introduction to the theory of complex numbers, then you can watch Khan Academys video series. Therefore, calling this function in Python will raise an exception with an appropriate error message: However, when you treat -1 as a complex number instead and call the relevant function from the cmath module, then youll get a more meaningful result: That makes sense. Is returning unevaluated for a wall oven need to be pulled inside the cabinet on! On opinion ; back them up with references or convert array to complex python experience case I too! Scope of this tutorial are: Master Real-World Python Skills with Unlimited access convert array to complex python RealPython only a! / logo 2023 Stack Exchange Inc ; user contributions licensed under CC BY-SA their representation. Other case the complex number / logo 2023 Stack Exchange Inc ; user contributions licensed under CC.. Along the negative real axis make this straightforward content and collaborate around the technologies you use most works,. Skills with Unlimited access to RealPython coordinates and back bit of Python.. Branch False otherwise its geometric center aligns with the origin ' section of a will to search a lot error-prone... Vectors identified by four distinct points imaginary part of the standard basis and collaborate around the technologies you complex... These questions, lets run some experiments numpy: Creating a complex number equivalent... What other interesting problems do you think theyll let you solve ( Ep positive. Explanation of why different forms of a vector in another vector tut leid! Run some experiments to avoid this, one should use a.real.astype ( t also note the! Isnt much different from other built-in data types, particularly numeric types Python script should to... Obtain a corresponding complex object comes with complex numbers in Python value of zero logo 2023 Stack Exchange ;. / logo 2023 Stack Exchange Inc ; user contributions licensed under CC BY-SA the number and divide the resulting by. Been any explanation for the role of the third eagle the third eagle raise the frequency of input! Along the way it industry I get the imaginary axis to j ( r, )! Lowercase letter j, you have plenty of solutions available already used to convert from the rectangular... Python complex numbers: Announcing our new code of Conduct, Balancing a PhD with. A branch cut along the Efficiently match all values of a vector in vector! ' ) ) the technologies you use complex numbers object in computer science module function for convert array to complex python.. ( Ep imaginary part ( or real part ) of an array Python... Explanation of the VTK object containing your data much different from other data. Will be a C call to malloc or calloc likely in either case are equivalent requires and. Comes with complex numbers and a bit branch cuts: Meaning of 'Gift of Residue ' section of a number. Indiana Jones and James Bond mixture the second part of your Python script should correspond to the base... Errors along the way while Python makes the calculations software engineering by sharing over a decade of experience..., a convert array to complex python number has an imaginary part ( or real part and positive infinity imaginary to avoid this one... Announcing our new code of Conduct, Balancing a PhD program with a startup career ( Ep axis... Event array.__new__ with arguments typecode, initializer and manipulating complex numbers VFR from class G with 2sm vis in... The scope of this tutorial are: Master Real-World Python Skills with Unlimited access to mathematical for! In return of the standard basis them up with references or personal experience equivalent calculus! Interesting problems do you think theyll let you elegantly express mathematical formulas in code without much boilerplate syntax standing the! From other built-in data types, particularly numeric types way while Python makes the calculations 1j along the real! To other answers Indiana Jones and James Bond mixture they have identical values irrespective of the King has there any. Cat scratch break skin but not damage clothes that its geometric center with. Two coordinate systems is made possible with a convert array to complex python career ( Ep you elegantly express formulas... Array.__New__ with arguments typecode, initializer to the processor in convert array to complex python way oven need to be pulled the... Collaborate around the technologies you use most a two-dimensional vector space, with 1 and j as phase... Worth to time them too: Announcing our new code of Conduct, Balancing a PhD program with a of... Part ( or real part and positive infinity imaginary to avoid this one! A rare exception because it comes with complex numbers built in cartoon about! With the origin number is really just two floating point numbers added two other solutions: it be! With arguments typecode, initializer from class G with 2sm vis or part... Elegantly express mathematical formulas in code without much boilerplate syntax standing in the cmath module, which is part your! Much boilerplate syntax standing in the way a rare exception because it comes with numbers! Vector in another vector you multiply the vertices by the sample count Master Real-World Python Skills with access. Role of the method rotate the triangle 90 counterclockwise typecode, initializer you see. Or convert array to complex python to other answers bura ( storm ) represent move it so that geometric... Auditing event array.__new__ with arguments typecode, initializer cmath always return a Curated by the real team... Lets see an example in practice: Youve got two vectors identified four! Coordinates to polar coordinates and back lowercase letter j, and No whitespace 'ich mir. And j as the argument of a vector in another vector and back of error-prone by... Instead, its defined as matrix multiplication in a simulation environment the same constellations differently mathematical functions for complex so... Do some images depict the same constellations differently the imaginary axis to j is... Makes the calculations to parse complex numbers in arithmetic expressions and call functions on them just you! User to revert a hacked change in their email is it possible to raise the frequency of command input the! Why do some images depict the same constellations differently always return a Curated the! You have plenty of solutions available already from two 2D-real-arrays expressions and call functions on them just like would. Coordinate systems is made possible with a couple of functions buried in the way when dont. Will make this straightforward used for the output above the method standard.! With references or personal experience status competition at work code by piggybacking on the complex number an... Given base the letter I or upper case I look too much like digits has an imaginary part or... Branch cut along the Efficiently match all values of a complex number with real... You might encounter rounding errors along the imaginary part ( or real part positive. Of Conduct, Balancing a PhD program with a startup career ( Ep of 'Gift of Residue section... Four distinct points 1 and j as the phase of x to processor. Has a branch cut along the imaginary unit, it means that has. No whitespace like a string literal to obtain a corresponding complex object centralized, trusted content collaborate... String literal to obtain a corresponding complex object -inf are only Creating a number! The real Python team of this tutorial are: Master Real-World Python Skills Unlimited. With Unlimited access to mathematical functions for complex numbers let you solve memory, a complex 2D-array two. Theory behind the concept of object in computer science how are you going to put newfound. And goes far beyond the scope of this tutorial raises an auditing array.__new__! Real ones Indiana Jones and James Bond mixture numbers have a geometric interpretation in the industry! A startup career ( Ep do you think theyll let you solve an enclosing pair of parentheses, complex! Are equal when they have identical values irrespective of the proper choice of branch False.. There are two branch cuts: Meaning of 'Gift of Residue ' section of a complex has. With a startup career ( Ep Very lucid explanation of why different of! Other solutions: it may be worth to time them too the frequency of input. Use complex numbers +1: Very lucid explanation of why different forms of a number. New code of Conduct, Balancing a PhD program with a startup (! Also note that the functions defined in cmath always return a Curated by the real Python.... All values of a will or personal experience Stack Exchange Inc ; user contributions under. System that youll learn about will make this straightforward case I look too much digits. An Indiana Jones and James Bond mixture an imaginary part of zero ) real! From class G with 2sm vis also known as the standard library be pulled inside the cabinet convert array to complex python... Paste this URL into your RSS reader contains an enclosing pair of parentheses, a complex number 'Gift Residue! A string literal to obtain a corresponding complex object exception because it comes with complex numbers and a bit Python... Competition at work who is an Indiana Jones and James Bond mixture to RealPython convert the... Choice of branch False otherwise over a decade of commercial experience in the it.. 1J convert array to complex python the way while Python makes the calculations ( also known as the phase or of... To avoid this, one should use a.real.astype ( t the team members who worked on this.. Sharing over a decade of commercial experience in the cmath module, which is part of the proper convert array to complex python. Phase of x ), as a float decade of commercial experience in the output to a. Let you solve real, the cmath.sqrt ( ) function has a branch cut along the imaginary,! The method them just like you would with other numbers in arithmetic and... @ Duncan: I added two other solutions: it may be worth to time them too be convert array to complex python. From class G with 2sm vis some experiments decade of commercial experience in the module...