complex-numbers

Java math expression parser that can take complex numbers as a variable?

狂风中的少年 提交于 2019-12-20 02:52:20
问题 I am writing a program in Processing that transforms complex numbers. However, I want to have a method of taking an input string and calculating the transformation using a complex variable. For example: 1/(z+1) (z^2)/(z/2) where z is a complex number. Now, I've looked at JEP and some examples, but I cannot work out if it would allow you to actually enter z as a variable (and in any case it is not free). Is there an expression parser for Java (that works in processing, which uses an old

Domain coloring (color wheel) plots of complex functions in Octave (Matlab)

非 Y 不嫁゛ 提交于 2019-12-19 04:24:38
问题 I understand that domain or color wheel plotting is typical for complex functions. Incredibly, I can't find a million + returns on a web search to easily allow me to reproduce some piece of art as this one in Wikipedia: There is this online resource that reproduces plots with zeros in black - not bad at all... However, I'd like to ask for some simple annotated code in Octave to produce color plots of functions of complex numbers. Here is an example: I see here code to plot a complex function.

Domain coloring (color wheel) plots of complex functions in Octave (Matlab)

风格不统一 提交于 2019-12-19 04:24:09
问题 I understand that domain or color wheel plotting is typical for complex functions. Incredibly, I can't find a million + returns on a web search to easily allow me to reproduce some piece of art as this one in Wikipedia: There is this online resource that reproduces plots with zeros in black - not bad at all... However, I'd like to ask for some simple annotated code in Octave to produce color plots of functions of complex numbers. Here is an example: I see here code to plot a complex function.

why (0+0i)^{0} == (nan, nan) in c++

五迷三道 提交于 2019-12-18 21:13:06
问题 take a look at the code blew: #include <complex> #include <iostream> int main() { std::cout << std::pow( std::complex<double>(0,0), std::complex<double>(0,0) ) << "\n"; std::cout << std::pow( std::complex<double>(0,0), double(0) ) << "\n"; return 0; } g++(4.8.1) gives an output of (nan,nan) (-nan,-nan) while clang++(3.3) gives an out put of (-nan,-nan) (-nan,-nan) But I am expecting (1.0, 0.0). Can anyone give an explanation? 回答1: According to std::pow documentation Return value base raised

How to directly assign complex numbers to a variable?

こ雲淡風輕ζ 提交于 2019-12-18 13:22:11
问题 Using the complex class and library, how do I assign a complex number to a variable? I understand that I can set the value when I first instantiate the complex number. I also understand that I can assign one instantiated complex number to another. How can I directly assign a complex number to a variable? Reference: http://www.cplusplus.com/reference/complex/complex/operators/ Example: #include <iostream> #include <complex> int main() { complex<double> a(1.2,3.4), b; cout << a; //-> (1.2,3.4)

FFT real/imaginary/abs parts interpretation

匆匆过客 提交于 2019-12-18 11:17:15
问题 I'm currently learning about discret Fourier transform and I'm playing with numpy to understand it better. I tried to plot a "sin x sin x sin" signal and obtained a clean FFT with 4 non-zero points. I naively told myself : "well, if I plot a "sin + sin + sin + sin" signal with these amplitudes and frequencies, I should obtain the same "sin x sin x sin" signal, right? Well... not exactly (First is "x" signal, second is "+" signal) Both share the same amplitudes/frequencies, but are not the

How Do I Prevent MATLAB from Dropping the “complex” Attribute of an Array?

别等时光非礼了梦想. 提交于 2019-12-18 09:47:23
问题 The following MATLAB code snippet, which creates two arrays of complex numbers, x = complex(1:2,0:1); y = complex(zeros(1,2),0); whos x y prints Name Size Bytes Class Attributes x 1x2 32 double complex y 1x2 32 double complex as expected. However, after these two additional statements, y(1) = x(1); whos x y the following gets printed: Name Size Bytes Class Attributes x 1x2 32 double complex y 1x2 16 double How can one prevent the complex attribute from being dropped? For the record, Octave

Why does abs(complex<int>) always return zero?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 04:33:29
问题 The following code with VS2010 prints 0 , contrary to my expectations: #include <complex> #include <iostream> using namespace std; int main(void) { complex<int> z(20, 200); cout << abs<int>(z) << endl; return 0; } It works fine when the type is double . 回答1: According to the C++ ISO spec, §26.2/2: The effect of instantiating the template complex for any type other than float , double or long double is unspecified. In other words, the compiler can do whatever it wants to when you instantiate

Python augmented assignment issue

耗尽温柔 提交于 2019-12-17 23:45:21
问题 i ran into something interesting about the python augmented assignment += it seems to be automatic data type conversion is not always done for a += b if a is a 'simpler' data type, while a = a + b seems to work always cases where the conversion is done a = 1 b = 1j a = 1 b = 0.5 case where the conversion is not done from numpy import array a = array([0, 0 ,0]) b = array([0, 0, 1j]) after a += b , a remains as integer matrix, instead of complex matrix i used to think a += b is the same as a =

Formatting Complex Numbers

ⅰ亾dé卋堺 提交于 2019-12-17 19:37:31
问题 For a project in one of my classes we have to output numbers up to five decimal places.It is possible that the output will be a complex number and I am unable to figure out how to output a complex number with five decimal places. For floats I know it is just: print "%0.5f"%variable_name Is there something similar for complex numbers? 回答1: For questions like this, the Python documentation should be your first stop. Specifically, have a look at the section on string formatting. It lists all the