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

af::array::device doesn't work with complex arrays

I just want to "use" a complex af::array for a Cuda kernel. Unfortunately, the transformation which is described in the af documentation (http://arrayfire.org/docs/interop_cuda.htm) doesn't work here: #include #include…
fabs
  • 1
  • 2
-2
votes
1 answer

sorting by imaginary part in R

I want to sort a few complex numbers by ascending order of their imaginary parts. I've read the document but I still don't know how to do this in a single line command by using sort function. (I've tried r[order(Im(r))], which is the answer provided…
Aria
  • 1
  • 2
-2
votes
1 answer

How to calculate the inverse of a non-square complex matrix in Java?

We've already found the algorithm to calculate the inverse of a square matrix containing complex numbers. Now, the problem is that we don't know how to calculate the inverse of a complex matrix while it is non-square?
zahra.bsh
  • 21
  • 2
-2
votes
1 answer

Plotting natural logarithm function in Octave

I have to plot the function f(x) = ln(20 - e^x) in Octave, and I use the command: x = -5:0.1:5; y = log(20 - exp(x)); plot(x,y) But the graph is not correct, because when I check in Wolfram Alpha it is not the same. Any help is appreciated!
mandella
  • 180
  • 1
  • 17
-2
votes
1 answer

Data.Complex package gives strange result for cube root of -8 + 0i ((-8):+0)

I have to say, math is not my strong suit. I was hoping to get a decent result for How to find the cube root of a negative integer such that it does not return NaN? by using the Data.Complex package but when i do like *Main> ((-8):+0) ** (1/3) 1.0…
Redu
  • 25,060
  • 6
  • 56
  • 76
-2
votes
1 answer

Complex numbers using struct

I want to write a program that reads an array of complex numbers until 0+0j is entered and calculates the absolute value of these numbers and gives the maximum value. i create a struct which includes im and re. i take numbers from user and check…
overflush
  • 25
  • 1
  • 7
-2
votes
3 answers

Implementing the Java comparable interface?

I am not sure how to implement a comparable interface into my complex class. I have the following example code that I am using to try and get my head around it. I know it should be something like public double compareTo (Complex o) and something…
Kamal
  • 37
  • 2
  • 10
-2
votes
3 answers

How to Print Out the Square Root of A Negative Number with i Displayed in C

I am trying to figure out how to display the square root of a number if it happens to be negative (as it is entered by the user), and if so, display it correctly with the "i" displayed as well. When I do the normal sqrt function, the result is…
-2
votes
3 answers

How do I output my results in GUI C#

I am trying to add two complex numbers from an GUI. I create 4 text-boxes - 2 are real number and 2 are imaginary numbers. I created an enter button. So, when I press enter it will display my results in a MessageBox. I need help with displaying my…
Lebron Jamess
  • 109
  • 2
  • 12
-2
votes
4 answers

What does %di specifier do in C programming?

%d specifier inside the printf function means that we're going to display the variable as a decimal integer and %f specifier would display it as a float number and so on. But what does %di specifier does ? I found this specifier in this program(C…
makkBit
  • 373
  • 2
  • 14
-2
votes
1 answer

real numbers become complex in python

the code is : A = b/a B = c/a C = d/a Q = (A**2-3*B)/9 R = (2*A**3-9*A*B+27*C)/54 M = R**2-Q**3 p = (3*B-A**2)/3 q = (2*A**3-9*A*B+27*C)/27 delta = (q/2)**2+(p/3)**3 if M <= 0 : from math import sqrt,acos,cos,pi Z = acos(R/sqrt(Q**3)) …
MAE
  • 72
  • 1
  • 11
-2
votes
2 answers

Problems with personally constructed complex number class

I am having trouble figuring out why my complex number class isn't adding correctly or working exactly how I want it to. When I add two complex numbers together I get something really weird that isn't supposed to be. I keep trying to figure out…
apples123
  • 13
  • 3
-2
votes
1 answer

Inizialize a complex array

I'm trying to solve a system of complex differential equation. I would like to fill the complex vector xi[n] with a gaussian valued function. But, when I check the output file, it gives me just a lot of zeros. I gave the input values using the cin…
-2
votes
1 answer

Complex number input in c

I am trying to get my program to do some basic operations with 2 complex numbers, which user will enter. I am using complex.h. How can I use scanf() to scan for complex number(a+bi)?
ssekav
  • 1
  • 1
-2
votes
1 answer

Random complex points from a circle and certain operation with them

My assingment is to write a progmar which chechs wether certain function defined as f(a,b,c) works. The function returns 0j if the given points on a complex plain (complex(a,b)) are in the same circle which center is 0. I can create the random…
Oliver
  • 19
  • 5