complex-numbers

How can I solve exponential equation in Maxima CAS

家住魔仙堡 提交于 2021-02-10 12:54:54
问题 I have function in Maxima CAS : f(t) := (2*exp(2*%i*%pi*t) - exp(4*%pi*t*%i))/4; here: t is a real number between 0 and 1 function should give a point on the boundary of main cardioid of Mandelbrot set How can I solve equation : eq1:c=f(t); (where c is a complex number) ? Solve doesn't work solve( eq1,t); result is empty list [] Result of this equation should give real number t ( internal angle or rotation number ) from complex point c EDIT: Thx to comment by @JosehDoggie I can draw initial

Why do negative numpy.float64 yield nan when expontiated with a fractional number?

痞子三分冷 提交于 2021-02-10 12:34:06
问题 A negative numpy.float64 exponentiated with a fractional (i.e., decimal, i.e., rational) number will yield a nan result and a warning. The same number using Python's float type returns a complex result. Here is a minimal example using Python 3.6.6 (for a comment on Python 2.7.15, see below): >>> import numpy as np >>> f = -2.0 >>> npf = np.float64(-2.0) >>> f**1.1 (-2.0386342710747223-0.6623924280875919j) >>> npf ** 1.1 __main__:1: RuntimeWarning: invalid value encountered in double_scalars

Why is complex<double> * int not defined in C++?

自作多情 提交于 2021-02-08 12:37:16
问题 The C++ program #include <complex> #include <iostream> int main() { std::complex<double> z(0,2); int n = 3; std::cout << z * n << std::endl; } yields an error: no match for ‘operator*’ in ‘z * n’. Why? I'm compiling with g++ 4.4.1. Perhaps the compiler is just following the C++ standard, in which case my question is: why does the standard not allow this? 回答1: This works: #include <complex> #include <iostream> int main() { std::complex<double> z(0,2); double n = 3.0; // Note, double std::cout

How to pass infinity values to a function and test the result

给你一囗甜甜゛ 提交于 2021-02-08 08:16:19
问题 I have this function: #include <complex.h> complex double f(complex double x, complex double y) { return x*y; } I would like to call it with x = inf + i inf and y = i inf and see what the result is. In particular I want to test if the result is an infinity value (as it should be) or if it is NaN + iNaN . The reason for this is to test different C compilers. How do you do this in C? 回答1: I would add an intermediate check, too: #include <stdio.h> #include <stdlib.h> #include <complex.h>

mathplotlib imshow complex 2D array

心不动则不痛 提交于 2021-02-06 08:55:26
问题 Is there any good way how to plot 2D array of complex numbers as image in mathplotlib ? It makes very much sense to map magnitude of complex number as "brightness" or "saturation" and phase as "Hue" ( anyway Hue is nothing else than phase in RBG color space). http://en.wikipedia.org/wiki/HSL_and_HSV But as far as I know imshow does accept only scalar values which are then mapped using some colorscale. There is nothing like ploting real RGB pictures? I thing it would be easy just implement a

mathplotlib imshow complex 2D array

自闭症网瘾萝莉.ら 提交于 2021-02-06 08:53:56
问题 Is there any good way how to plot 2D array of complex numbers as image in mathplotlib ? It makes very much sense to map magnitude of complex number as "brightness" or "saturation" and phase as "Hue" ( anyway Hue is nothing else than phase in RBG color space). http://en.wikipedia.org/wiki/HSL_and_HSV But as far as I know imshow does accept only scalar values which are then mapped using some colorscale. There is nothing like ploting real RGB pictures? I thing it would be easy just implement a

Complex literal 'i' used in function argument

放肆的年华 提交于 2021-02-04 21:58:47
问题 There seems to be a problem, using the literal i in C++ with std::complex . Consider the following code: std::complex<double> a = -1.0i * 42.0; std::complex<double> b = a + 1.0i; The second line fails to compile with: error: no match for ‘operator+’ (operand types are ‘std::complex<double>’ and ‘__complex__ double’) This also shows up when using the complex literal in function calls, e.g. std::exp<std::complex<double>>( 1.0i * 3.14159 ); How come the complex literal 1.0i is not convertible to

combining real and imag columns in dataframe into complex number to obtain magnitude using np.abs

眉间皱痕 提交于 2021-01-28 06:04:21
问题 I have a data frame that has complex numbers split into a real and an imaginary column. I want to add a column (2, actually, one for each channel) to the dataframe that computes the log magnitude: ` ch1_real ch1_imag ch2_real ch2_imag ch1_phase ch2_phase distance 79 0.011960 -0.003418 0.005127 -0.019530 -15.95 -75.290 0.0 78 -0.009766 -0.005371 -0.015870 0.010010 -151.20 147.800 1.0 343 0.002197 0.010990 0.003662 -0.013180 78.69 -74.480 2.0 80 -0.002686 0.010740 0.011960 0.013430 104.00 48

combining real and imag columns in dataframe into complex number to obtain magnitude using np.abs

不羁岁月 提交于 2021-01-28 05:56:21
问题 I have a data frame that has complex numbers split into a real and an imaginary column. I want to add a column (2, actually, one for each channel) to the dataframe that computes the log magnitude: ` ch1_real ch1_imag ch2_real ch2_imag ch1_phase ch2_phase distance 79 0.011960 -0.003418 0.005127 -0.019530 -15.95 -75.290 0.0 78 -0.009766 -0.005371 -0.015870 0.010010 -151.20 147.800 1.0 343 0.002197 0.010990 0.003662 -0.013180 78.69 -74.480 2.0 80 -0.002686 0.010740 0.011960 0.013430 104.00 48

determinant of a complex matrix in PyTorch

泪湿孤枕 提交于 2021-01-28 05:00:07
问题 Is there a way to calculate the determinant of a complex matrix in PyTroch? torch.det is not implemented for 'ComplexFloat' 回答1: Unfortunately it's not implemented currently. One way would be to implement your own version or simply use np.linalg.det . Here is a short function which computes the determinant of a complex matrix that I wrote using LU-decomposition: def complex_det(A): def complex_diag(A): return torch.view_as_complex(torch.stack((A.real.diag(), A.imag.diag()),dim=1)) #Perform LU