久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

如何用Python畫各種著名數(shù)學圖案 | 附圖 代碼

 _王文波 2017-04-27

Python繪制著名的數(shù)學圖片或動畫,,

展示數(shù)學中的算法魅力,。

代碼:46 lines (34 sloc) 1.01 KB



reddit discussion: https://www./r/math/comments/2abwyt/smooth_colour_mandelbrot/


'''


import numpy as np


fromPILimport Image


v = np.log2(i +1- np.log2(np.log2(abs(z)))) /5


if v 1.0:


return v**4, v**2.5, v


v =max(0, 2-v)


return v, v**1.5, v**3


z =0j


if z.real*z.real + z.imag*z.imag RADIUS:


return color(z, i)


z = z*z + c


x = np.linspace(xmin, xmax, width)


y = np.linspace(ymax, ymin, height)


z = x[None, :] + y[:, None]*1j


red, green, blue = np.asarray(np.frompyfunc(iterate, 1, 3)(z)).astype(np.float)


img = np.dstack((red, green, blue))


Image.fromarray(np.uint8(img*255)).save('mandelbrot.png')

播放GIF

代碼鏈接:https://github.com/neozhaoliang/pywonderland/tree/master/src/domino

正二十面體萬花筒

代碼:53 lines (40 sloc) 1.24 KB



'''


A kaleidoscope pattern with icosahedral symmetry.


'''


return1728* (z * (z**10+11* z**5-1))**5/ \


'''


map the complex plane to Riemann's sphere via stereographic projection


'''


t =1+ z.real*z.real + z.imag*z.imag


return2*z.real/t, 2*z.imag/t, 2/t-1


'''


distort the result image by a mobius transformation


'''


x = np.linspace(-6, 6, imgsize)


y = np.linspace(6, -6, imgsize)


# define colors in hsv space


H = np.sin(z[0]*np.pi)**2


S = np.cos(z[1]*np.pi)**2


V =abs(np.sin(z[2]*np.pi) * np.cos(z[2]*np.pi))**0.2


HSV= np.dstack((H, S, V))


# transform to rgb space


img = hsv_to_rgb(HSV)


Image.fromarray(np.uint8(img*255)).save('kaleidoscope.png')


import time


start = time.time


main(imgsize=800)


end = time.time


print('runtime: {:3f} seconds'.format(end - start))

Newton 迭代分形

代碼:46 lines (35 sloc) 1.05 KB



# define functions manually, do not use numpy's poly1d funciton!


@jit('complex64(complex64)', nopython=True)


# z*z*z is faster than z**3


num =0


whileabs(f(z)) 1e-4:


num += np.exp(-1/abs(w-z))


z = w


x = np.linspace(-1, 1, imgsize)


y = np.linspace(1, -1, imgsize)


img = np.frompyfunc(iterate, 1, 1)(z).astype(np.float)


fig = plt.figure(figsize=(imgsize/100.0, imgsize/100.0), dpi=100)


ax = fig.add_axes([0, 0, 1, 1], aspect=1)


ax.axis('off')


ax.imshow(img, cmap='hot')


fig.savefig('newton.png')


import time


render(imgsize=400)


print('runtime: {:03f} seconds'.format(end - start))

李代數(shù)E8 的根系

代碼鏈接:https://github.com/neozhaoliang/pywonderland/blob/master/src/misc/e8.py

模群的基本域

代碼鏈接:

彭羅斯鋪砌

播放GIF

代碼鏈接:

Wilson 算法

播放GIF

代碼鏈接:https://github.com/neozhaoliang/pywonderland/tree/master/src/wilson

反應擴散方程模擬

播放GIF

代碼鏈接:

120 胞腔

代碼:69 lines (48 sloc) 2.18 KB



from itertools import combinations, product


import numpy as np


self.num_lines = num_lines


self.shift = shift


self.thin_color = thin_color


self.fat_color = fat_color


self.objs =self.compute_pov_objs(**config)


for rhombi, color inself.tile:


p1, p2, p3, p4 = rhombi


polygon = Polygon(5, p1, p2, p3, p4, p1,


Texture(Pigment('color', color), config['default']))


objects_pool.append(polygon)


cylinder = Cylinder(p, q, config['edge_thickness'], config['edge_texture'])


objects_pool.append(cylinder)


x, y = point


sphere = Sphere((x, y, 0), config['vertex_size'], config['vertex_texture'])


objects_pool.append(sphere)


color =self.thin_color


else:


point = (Penrose.GRIDS[r] * (ks -self.shift[s])


- Penrose.GRIDS[s] * (kr -self.shift[r])) *1j/ Penrose.GRIDS[s-r].imag


index = [np.ceil((point/grid).real + shift)


for grid, shift inzip(Penrose.GRIDS, self.shift)]


for index[r], index[s] in [(kr, ks), (kr+1, ks), (kr+1, ks+1), (kr, ks+1)]:


vertices.append(np.dot(index, Penrose.GRIDS))


vertices_real = [(z.real, z.imag) for z in vertices]


for r, s in combinations(range(5), 2):


for kr, ks in product(range(-self.num_lines, self.num_lines+1), repeat=2):


yieldself.rhombus(r, s, kr, ks)


return Object(self.objs, *args)

本文經(jīng)授權(quán)轉(zhuǎn)載自大數(shù)據(jù)文摘

編輯:yangfz

近期熱門文章Top10

↓ 點擊標題即可查看 ↓

點此查看以往全部熱門文章

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約