make
must work. Otherwise that's a bug.
log(a*b) = log(a)+log(b)
, or as single valued on a principal branch (I understand this very well, I put my notes here: http://www.theoretical-physics.net/dev/math/complex.html), but then the correct formula is log(a*b) = log(a) + log(b) + 2*pi*i*floor((pi-arg(a)-arg(b))/(2*pi))
, i.e. there is a correction.
f(z) = log(z)
, we get f(z) = log|z| + i*arg(z) + 2*pi*i*n
for all integer "n", and that we just plot this in some way, for example we plot |f(z)| for all "n" and color by arg(f(z))?
RiemannSurface
object in abelfunctions
.
As far as integrating into sympy, the only hard part is to figure out how to rewrite log(z) -> w = numpy.log(R) + 1j*Theta
, so that it can be plotted. This should do it in this case:
In [4]: log(z).as_real_imag()
Out[4]: (log(│z│), arg(z))
But we need something general that works for any expression.
r
and theta
domains, transform to z
and then plot?
This might be a start:
w = sqrt(z)
w = w.subs(z,r*exp(I*theta), positive=True)
w = sympy.expand_power_base(w, force=True)
w = sympy.powdenest(w)
print w
Output:
sqrt(r)*exp(I*theta/2)
Then I blindly tried this and received an interesting error!
w = sqrt(z)
w = w.subs(z,r*exp(I*theta), positive=True)
w = sympy.expand_power_base(w, force=True)
w = sympy.powdenest(w)
R = sqrt(x**2+y**2)
Theta = sympy.atan2(y,x)
W = w.subs({r:R,theta:Theta})
Wreal = sympy.re(W)
Wimag = sympy.im(W)
sympy.plotting.plot3d(Wimag, (x,-1,1), (y,-1,1))
/Users/cswiercz/anaconda/lib/python2.7/site-packages/sympy/plotting/experimental_lambdify.py:164: UserWarning: The evaluation of the expression is problematic. We are trying a failback method that may still work. Please report this as a bug.
warnings.warn('The evaluation of the expression is'
...and then it produced the "naive" image with a jump...so that's not the right way to do it.