I am using Jupyter in particular. e.g from the equation e2+j, how can I seperate it in it's real part (e2) and into it's imaginary (ej)?
I have tried:
exp(complex(2,1)).real
However the error that follows it is: 'Mul' object has no attribute 'real'.
An other solution might be to implement the eulers formula to seperate it as cos(2)+j·sin(1) but no success so far. Generally the problem is when complex numbers appear in power position rather than in usual format (2+j). If someone has any idea upon this matter would be greatly appreciated!
Important edit that fits more in my problem:
In my case the complex equation that i have, came through the dsolve() for a 2nd order differential equation. For the exp() element that exist in nympy this is a valid solution, it's not the same as an arbitary equation. However my equation is just a the above one regarding it's complexity
I include my code:
import scipy as sp
from sympy import*
import sympy as syp
from scipy.integrate import odeint
t, z, w, C2=symbols('t, z, w, C2')
x=Function('x')
eq=x(t).diff(t,2)+2*z*w*x(t).diff(t,1)+w**2*x(t)
sol=dsolve(eq,x(t),ics={x(0):0,x(t).diff(t,1).subs(t,0):2*C2*w*sqrt(z**2-1)})
next I want to substitute the z,w parameters in order to fit my data and then with a loop to make an array that takes the numerical solutions in order to plot them. I've tried the following:
for i in range(1000):
step.append(i)
numdata=[]
for i in range(1000):
numdata.append(N(sol.rhs.subs(t,i).subs(w,10).subs(z,0.001)))
However this can't work as the sol
is an complex function. After this long journey I try to find (meaning of my life) ways to seperate the real and imaginary parts of this kind of function.
Thank you for being with me so far, you are a hero reagrdless of the result.