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
-3
votes
1 answer

How to compute a complex function in Python

I have an expression for a complex function as follows: f(z) = 1/jwC + (R1(1+jwC1) + R2(1+jwC2))/(1+jwR1C1)(1+jwR2C2) where j = sqrt(-1) How do I compute f(z) in Python, given the values of w, R1, R2, C, C1, C2 and then seperate out the real and…
Bidisha Das
  • 177
  • 2
  • 11
-3
votes
1 answer

How are complex/imaginary numbers programmed?

I am curious on how complex numbers are programmed like in Python's cmath. Is i treated similarly to a variable?
user7585900
-3
votes
2 answers

Identify a irrational or complex number

I am taking the square root of a number, and I want to find if it is irrational or complex, and return True or False test cases, where taking the square root of the number is True for irrational / complex, and False if the square root is a float or…
lol
  • 481
  • 6
  • 18
-3
votes
2 answers

c++ get negative numbers from complex

If I create a complex number with amplitude negativ (-1) and no phase (0), thus corresponding to a double of -1, and convert it back to amplitude and phase, the amplitude is not negative complex c; c = polar(-1.0, 0.0); cout << c << ", " <<…
Matthias Pospiech
  • 3,130
  • 18
  • 55
  • 76
-3
votes
1 answer

Sorting Complex Numbers c++

I am attempting to take a complex number entered by a user (3-8i or -1+5i) and then sort it in ascending order in the same format as above by real number then imaginary if the same. I start by asking the user to enter a complex number or ctr-d to…
user3602550
  • 39
  • 1
  • 7
-3
votes
3 answers

Return type of abs is complex?

Does std::abs return a complex value? That is, a real value represented as a complex number with zero imaginary part. I get this error g++ -march=native "utilities.cpp" -fpic -g -Wall -c -std=c++11 -I"/home/torbjorr/deployed" -o…
user877329
  • 6,717
  • 8
  • 46
  • 88
-3
votes
1 answer

complex numbers: why isnt this working?

When i load up this code and input some numbers and try to add the complex numbers, it force closes the app. public void complex3(View v){ EditText numAA=(EditText)findViewById(R.id.complextest1); EditText…
-3
votes
1 answer

What is Meaning of 3.3882e+004 -1.9521e+001i in Matlab?

What does this number "3.3882e+004 -1.9521e+001i" means in Matlab?
-4
votes
1 answer

store integer value in complex variable

Its very simple but Iam unable to remove error. I want to store integer value in complex variable. int int2 =2; comp *cal = int2; Thanks
Annie
  • 17
  • 5
-5
votes
3 answers

Python Real and imaginary : How to print -2-2i

Can you please help me with the below code where I am not getting the desired result: class comp: def __init__(self, real, imag): self.real=real self.imag=imag def add(self,other): print('Sum of the two Complex…
-5
votes
1 answer

How to write a toString() method that should return complex number in the form a+bi as a string?

The method should return the string representation for a complex number. The toString() method should return Complex numbers in the form a+bi as a String,where a is the real part and b is the imaginary part public class Complex { private…
-5
votes
1 answer

One of the parameters of a binary operator must be the containing type

got an error One of the parameters of a binary operator must be the containing type can not see where is wrong about the operator overloadin error at public static Complex operator +(Complex c1, Complex c2) namespace testComplex { class Program …
ControlPoly
  • 717
  • 2
  • 10
  • 21
-7
votes
1 answer

How to create a vector of complex numbers in c++?

I have two inputs(real and imaginary parts) for n complex numbers. I can't figure out how to store them together in a vector such that i can perform complex calculations with STL complex functions. This is something I tried but Time Limit gets…
-7
votes
1 answer

Function returning a vector in c++

In order to complete my project I need a to incorporate a function that return a vector (STL). The following function when run with the online compiler from http://en.cppreference.com does return a vector : #include #include…
Serge
  • 3
  • 5
-8
votes
1 answer

complex numbers

I am working on a math project.I need a programming language that allows me to evaluate users input. Like Multiplying 2 complex numbers: I can't use a regular expression since there are many possibilities( I want to include all the steps of…
neo
  • 13
  • 2
1 2 3
92
93