File:5th-root-of-unity.jpg
From testwiki
Jump to navigation
Jump to search
5th-root-of-unity.jpg (553 × 543 pixels, file size: 62 KB, MIME type: image/jpeg)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| Description5th-root-of-unity.jpg |
English: Function |
| Date | |
| Source | Own work |
| Author | Rumil |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
| This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
| The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
Source code
Python code
import math, cmath
from cmath import exp, sin, cos
from math import pi, tanh
import numpy as np
from numpy import vectorize
import matplotlib as mp
import matplotlib.pyplot as plot
from colorsys import hls_to_rgb
# line width of the frame grid
lw_grid=2
# color of the axes
axes_color = [0.28,0.28,0.26]
# lightness gradient
Lgrad = 0.7
# darkness factor
darkness = 0.7
# number of iterations
# 100: preview
# 1000: publication
N = 100
# viewport
X=[-2,2]
Y=[-2,2]
# function to be graphed
def f1(z):
return z**5-1
style = {
"axes.linewidth": lw_grid,
"xtick.labelsize": 16,
"ytick.labelsize": 16
}
mp.rcParams.update(style)
def colorize(z):
n,m = z.shape
c = np.zeros((n,m,3))
c[np.isinf(z)] = (1.0, 1.0, 1.0)
c[np.isnan(z)] = (0.5, 0.5, 0.5)
index = ~(np.isinf(z) + np.isnan(z))
# hue
H = 1.0-np.angle(z[index])/(2*pi)
# lightness
L = (1.0 - 1.0/(1.0+darkness*abs(z[index])**Lgrad))
c[index] = [hls_to_rgb(h,l,1.0) for h,l in zip(H,L)]
return c
fig = plot.figure()
ax = fig.add_subplot(1,1,1)
ax.spines['bottom'].set_color(axes_color)
ax.spines['top'].set_color(axes_color)
ax.spines['right'].set_color(axes_color)
ax.spines['left'].set_color(axes_color)
ax.xaxis.set_tick_params(width=lw_grid,length=-6,pad=10,color=axes_color)
ax.yaxis.set_tick_params(width=lw_grid,length=-6,pad=10,color=axes_color)
ax.set_aspect('equal')
ax.axis(X+Y)
ax.set_xticks(range(X[0],X[1]+1,1))
ax.set_yticks(range(Y[0],Y[1]+1,1))
axis_x = np.linspace(X[0],X[1],N)
axis_y = np.linspace(Y[0],Y[1],N)
x,y = np.meshgrid(axis_x,axis_y)
z = x - y*1j
w = np.zeros((N,N),dtype='complex')
w = vectorize(f1)(z).conj()
ax.imshow(colorize(w), interpolation='none',
extent=(X[0],X[1],Y[0],Y[1]))
# contour lines
cl = ax.contour(x, -y, abs(w), [0.5,1,2,5,10],
colors="#606060", alpha=0.4, linewidths=3.2)
ax.clabel(cl, inline=1, fontsize=16, fmt="%g", colors="#000000",
manual=[[-0.5,-1.5],[-0.4,-1.2],[-0.3,-0.8],[-0.5,-0.5]])
plot.savefig("plot.jpg",bbox_inches='tight')
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
22 February 2018
image/jpeg
17894ebea4aaf7461bba9bb4d1f1c5af75d1089e
63,412 byte
543 pixel
553 pixel
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 12:42, 22 February 2018 | 553 × 543 (62 KB) | wikimediacommons>Rumil | User created page with UploadWizard |
File usage
The following page uses this file:
