Questions tagged [complex-numbers]

Questions about complex numbers (numbers in the form of x + y∙i where i² = -1), types to represent them in programming languages, and libraries to manipulate them

The complex numbers extend the real numbers to allow negative numbers to have a square root. Every complex number can be expressed in the form x + y * i where x and y are real numbers and i² = -1; this is called the rectangular form of the number. The rectangular form leads to an interpretation of complex numbers as points on a plane, the same way real numbers are akin to points on a line. If y = 0, the number is a real number; if x = 0, the number is called an imaginary number.

A nonzero complex number has a family of representations in the form r exp(i φ) with r > 0, called the polar representation.

Representation and manipulation in programming languages

Floating point complex numbers

1395 questions
-2
votes
3 answers

Parsing a complex number

I am trying to take a complex number input from the user in a form of a char or string like: 88.90-55.16i or -3.67+5i and then convert it to float keeping the same format as above. Not (x,y). char user[100]; vector < float > V; for (int y =…
Bob Jack
  • 3
  • 2
-2
votes
1 answer

Finding Laurent Series Of a function using Python

I've been assigned to write a program which then calculates the Laurent series of a function using Python. I've already found a library called SymPy for symbolical computations in Python but the problem is I have no idea how should I produce the…
Ahmad Siavosh
  • 646
  • 1
  • 9
  • 22
-2
votes
1 answer

Coding in C# for complex number

how to normalize the complex numbers in c#?when i have saved the text file of complex number in notepad.then i want to use these complex numbers in my c# code.And can be read text file of complex number in c#? Current code used: using (TextReader…
Ara
  • 11
  • 2
-2
votes
1 answer

Check if a ^ b is a complex number

Considering I have a ^ b where both are real numbers, for which values of a and b I will have a complex answer $(m+n*i)$. I figured out that one case is when the following is true: a<0 and b = (2*k+1)/(2n) ; k in Z and n in N Any ideas how can this…
SuTron
  • 387
  • 5
  • 16
-2
votes
2 answers

real and imaginary part of a complex number

I have 2 pointers which points to two 20 member arrays. My arrays contains complex numbers. I want to make element by element division for that complex numbers that is why I need to separate numbers to real and imaginary parts. I tried the following…
puCCa
  • 1
  • 1
  • 2
-2
votes
2 answers

Add complex numbers code

class complex1 { public: int real,img; complex1(){} complex1(int a) { real=a; img=a; } complex1(int a,int b) { real=a; img=b; …
-2
votes
1 answer

Fortran complex type VS C++ class performance

I would like to write some performance-sensitive numerical code involving long formulas with complex numbers. Consider something simple like a=(b+c)*(d+e+f). I prefer to use C++ (which has the std::complex class), but I'm worried about the fact that…
felix
  • 647
  • 1
  • 6
  • 10
-2
votes
2 answers

How do I compare these complex signals in matlab?

So I have two signals signal1 and signal2, both signal were initiated with: signal1=zeros(x,1) and signal2=zeros(y,1). The data for signal one looks like this 1.0000+1.0000i 1.0000-1.0000i 1.0000+1.0000i 1.0000-1.0000i 0.0000 + 0000i…
user8572
  • 1
  • 2
-2
votes
1 answer

get real part from fftw_complex in FFTW

this is maybe newbei question , but i dont know how to fast acces to real part of fftw_complex with FFFTW, i cant use .real() method, I need convert this to double array, dynamic array in c++;
user3042563
  • 19
  • 1
  • 7
-2
votes
2 answers

Using cin for input complex number in C++11

#include #include using namespace std; int main(){ complex p; cin >> p.real() >> p.imag(); } In g++4.7.2 it works successfully, but in C++11 failed to compile. Why? It gives me following error…
gnhankz
  • 21
  • 1
  • 3
-2
votes
1 answer

Python: Making a class to use complex numbers

I am currently trying to write a program that deals with complex numbers. I have to use classes and methods. I am trying to be able to add, subtract, multiply etc., complex numbers, as well as compare them to one another. I think I have gotten a…
xrocker15
  • 51
  • 2
  • 2
  • 6
-3
votes
2 answers

How to safely compare std::complex with Zero with some precision Epsilon?

I need to safely check is my complex number a zero (or very similar to it). How can I do it for floating point numbers? Can I use something like: std::complex a; if(std::abs(std::real(a)) <= std::numerical_limits::epsilon() &&…
Robotex
  • 1,064
  • 6
  • 17
  • 41
-3
votes
2 answers

trying to rotate a triangle with complex numbers in tkinter python

the first method is mine, the other two are from here http://effbot.org/zone/tkinter-complex-canvas.htm so i call the rotate method that calls the second one that calls the first one. the first one gets the xy coordinates from the angle that is…
fps6
  • 1
  • 1
  • 3
-3
votes
1 answer

Convert complex to integer matrix in python

Is there a way to convert a complex matrix to an integer matrix in python? Solution in Wolfram Mathematica . E. g. import numpy as np A=np.zeros((6,6),dtype=complex) A[1,1]= 1.+1j A[3,2]= 2.1-1j print(A) returns [[0. +0.j 0. +0.j 0. +0.j 0. +0.j…
jset
  • 1
  • 2
-3
votes
1 answer

How to determine the number of elements of a complex array in cpp?

I have a complex number array. I want to know the number of elements in that array. For a complex number array, a pair of real and imaginary element will be considered as 1 element. I have declared my complex array using std::vector<…
KharoBangdo
  • 321
  • 5
  • 14
1 2 3
92
93