Created
December 15, 2022 16:34
-
-
Save Gro-Tsen/fa1f2c6ee425a87618763afe897f448e to your computer and use it in GitHub Desktop.
Graphical representation of the Riemann mapping theorem for a square (inside and out) and an ellipse (inside and out)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Square of eccentricity (but not that of the drawn ellipse): | |
modparm = 3/4 | |
# The size of the drawn ellipse (semimajor and semiminor) is computed | |
# below. | |
### Mapping the inside of the disk to the inside of the ellipse: | |
prescale = N(modparm^(-1/4)) | |
postscale = N(pi/(2*elliptic_kc(modparm))) | |
# The conformal map taking the unit disk in CC to the inside of the | |
# ellipse, and 0 to 0: | |
def phi(z): | |
z = N(z) | |
t = N(asin(CC(z*prescale))) | |
u = N(elliptic_f(t, modparm)) | |
return N(sin(postscale*u)) | |
# A memoized version of phi, for efficiency: | |
phi_tab = {} | |
def memoize_phi(z): | |
z = N(z) | |
if z in phi_tab: | |
return phi_tab[z] | |
phi_tab[z] = phi(z) | |
return phi_tab[z] | |
# Convenience function for plotting phi(rad*exp(2*I*pi*ang)): | |
def plothelp(rad, ang): | |
return memoize_phi(rad*exp(2*I*pi*ang)) | |
def plothelp_x(rad, ang): | |
return real(plothelp(rad,ang)) | |
def plothelp_y(rad, ang): | |
return imag(plothelp(rad,ang)) | |
circplots = [parametric_plot([lambda t: plothelp_x(i/10, t), lambda t: plothelp_y(i/10, t)], (0,1)) for i in range(11)] | |
radplots = [parametric_plot([lambda t: plothelp_x(t, i/24), lambda t: plothelp_y(t, i/24)], (0,1)) for i in range(24)] | |
# sum(circplots + radplots) | |
### Mapping the outside of the disk to the outside of the ellipse: | |
#semimajor = real(phi(1)) | |
#semiminor = imag(phi(I)) | |
semimajor = N(cosh((pi/4)*elliptic_kc(1-modparm)/elliptic_kc(modparm))) | |
semiminor = N(sinh((pi/4)*elliptic_kc(1-modparm)/elliptic_kc(modparm))) | |
# The conformal map taking the complement of the unit disk in CC to | |
# the complement of the ellipse, and infinity to infinity: | |
def phi2(z): | |
z = N(z) | |
return N(((semimajor+semiminor)/2)*z + ((semimajor-semiminor)/2)/z) | |
# Convenience function for plotting phi2(rad*exp(2*I*pi*ang)): | |
def plothelp2(rad, ang): | |
return phi2(rad*exp(2*I*pi*ang)) | |
def plothelp2_x(rad, ang): | |
return real(plothelp2(rad,ang)) | |
def plothelp2_y(rad, ang): | |
return imag(plothelp2(rad,ang)) | |
circplots2 = [parametric_plot([lambda t: plothelp2_x(1+i/10, t), lambda t: plothelp2_y(1+i/10, t)], (0,1), color="red") for i in range(11)] | |
radplots2 = [parametric_plot([lambda t: plothelp2_x(t, i/24), lambda t: plothelp2_y(t, i/24)], (1,2), color="red") for i in range(24)] | |
sum(circplots + radplots + circplots2 + radplots2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Mapping the inside of the disk to the inside of the square: | |
cst = N(elliptic_kc(-1)) | |
# In fact, cst is equal to: | |
# cst = N(gamma(1/4)^2/(4*sqrt(2*pi))) | |
# The conformal map taking the unit disk in CC to the square [-1,1]+I*[-1,1], | |
# and 0 to 0: | |
def phi(z): | |
z = N(z) | |
t = N(asin(CC(z*(1-I)/sqrt(2)))) | |
u = N(elliptic_f(t, -1)) | |
return N(u*(1+I)/cst) | |
# A memoized version of phi, for efficiency: | |
phi_tab = {} | |
def memoize_phi(z): | |
z = N(z) | |
if z in phi_tab: | |
return phi_tab[z] | |
phi_tab[z] = phi(z) | |
return phi_tab[z] | |
# Convenience function for plotting phi(rad*exp(2*I*pi*ang)): | |
def plothelp(rad, ang): | |
return memoize_phi(rad*exp(2*I*pi*ang)) | |
def plothelp_x(rad, ang): | |
return real(plothelp(rad,ang)) | |
def plothelp_y(rad, ang): | |
return imag(plothelp(rad,ang)) | |
circplots = [parametric_plot([lambda t: plothelp_x(i/10, t), lambda t: plothelp_y(i/10, t)], (0,1)) for i in range(11)] | |
radplots = [parametric_plot([lambda t: plothelp_x(t, i/24), lambda t: plothelp_y(t, i/24)], (0,1)) for i in range(24)] | |
# sum(circplots + radplots) | |
### Mapping the outside of the disk to the outside of the square: | |
cst2 = N(2*elliptic_ec(-1) - 2*elliptic_kc(-1)) | |
# The conformal map taking the complement of the unit disk in CC to | |
# the complement of the square [-1,1]+I*[-1,1], and infinity to infinity: | |
def phi2(z): | |
z = N(z) | |
zz = N(((1+I)/sqrt(2))/z) | |
t = N(asin(CC(zz))) | |
u = N(sqrt(1-zz^4)/zz) - 2*N(elliptic_f(t, -1)) + 2*N(elliptic_e(t, -1)) | |
return N(u*(1+I)/cst2) | |
# A memoized version of phi2, for efficiency: | |
phi2_tab = {} | |
def memoize_phi2(z): | |
z = N(z) | |
if z in phi2_tab: | |
return phi2_tab[z] | |
phi2_tab[z] = phi2(z) | |
return phi2_tab[z] | |
# Convenience function for plotting phi2(rad*exp(2*I*pi*ang)): | |
def plothelp2(rad, ang): | |
return memoize_phi2(rad*exp(2*I*pi*ang)) | |
def plothelp2_x(rad, ang): | |
return real(plothelp2(rad,ang)) | |
def plothelp2_y(rad, ang): | |
return imag(plothelp2(rad,ang)) | |
circplots2 = [parametric_plot([lambda t: plothelp2_x(1+i/10, t), lambda t: plothelp2_y(1+i/10, t)], (0,1), color="red") for i in range(11)] | |
radplots2 = [parametric_plot([lambda t: plothelp2_x(t, i/24), lambda t: plothelp2_y(t, i/24)], (1,2), color="red") for i in range(24)] | |
sum(circplots + radplots + circplots2 + radplots2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment