最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python/Matplotlib繪制復(fù)變函數(shù)圖像教程

 更新時(shí)間:2019年11月21日 09:19:08   作者:落葉_小唱  
今天小編就為大家分享一篇python/Matplotlib繪制復(fù)變函數(shù)圖像教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

今天發(fā)現(xiàn)sympy依賴的庫(kù)mpmath里也有很多數(shù)學(xué)函數(shù),其中也有在復(fù)平面繪制二維圖的函數(shù)cplot,具體例子如下

from mpmath import *

def f1(z):
 return z

def f2(z):
 return z**3

def f3(z):
 return (z**4-1)**(1/4)

def f4(z):
 return 1/z

def f5(z):
 return atan(z)

def f6(z):
 return sqrt(z)

cplot(f1)
cplot(f2)
cplot(f3)
cplot(f4)
cplot(f5)
cplot(f6)

參照matlab繪制復(fù)變函數(shù)的例子,使用python實(shí)現(xiàn)繪制復(fù)變函數(shù)圖像,網(wǎng)上還沒搜到相關(guān)的文章,在這里分享出來供大家學(xué)習(xí)。

'''
參照matlab繪制復(fù)變函數(shù)的例子,創(chuàng)建函數(shù)cplxgrid,cplxmap,cplxroot
'''
# 1.導(dǎo)入相關(guān)庫(kù)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import *

# 2.創(chuàng)建函數(shù)
def cplxgrid(m):
 '''Return polar coordinate complex grid.

 Parameters
 ----------
 m: int

 Returns
 ----------
 z: ndarray,with shape (m+1)-by-(2*(m+1))
 '''
 m = m
 r = np.arange(0,m).reshape(m,1) / m
 theta = np.pi * np.arange(-m,m) / m
 z = r * np.exp(1j * theta)

 return z

def cplxroot(n=3,m=20):
 '''
 cplxroot(n): renders the Riemann surface for the n-th root
 cplxroot(): renders the Riemann surface for the cube root.
 cplxroot(n,m): uses an m-by-m grid. Default m = 20.

 Use polar coordinates, (r,theta).
 Use polar coordinates, (r,theta).

 Parameters
 ----------
 n: n-th root
 m: int

 Returns
 ----------
 None: Plot the Riemann surface
 '''
 m = m+1
 r = np.arange(0,m).reshape(m,1) / m
 theta = np.pi * np.arange(-n * m, n * m) / m
 z = r * np.exp(1j * theta)
 s = r * (1/n) * np.exp(1j * theta / n)
 fig = plt.figure()
 ax = fig.add_subplot(111,projection='3d')
 # ax.plot_surface(np.real(z),np.imag(z),np.real(s),color = np.imag(s))
 ax.plot_surface(np.real(z),np.imag(z),np.real(s),cmap = plt.cm.hsv)
 ax.set_xlim((-1,1))
 ax.set_ylim((-1,1))
 ax.set_xlabel('Real')
 ax.set_ylabel('Imag')
 ax.set_xticks([])
 ax.set_yticks([])
 ax.set_zticks([])
 ax.set_autoscalez_on(True)#z軸自動(dòng)縮放 
 ax.grid('on')
 plt.show()

def cplxmap(z,cfun):
 '''
 Plot a function of a complex variable.

 Parameters
 ----------
 z: complex plane
 cfun: complex function to plot

 Returns
 ----------
 None: Plot the surface of complex function
 '''
 blue = 0.2
 x = np.real(z)
 y = np.imag(z)
 u = np.real(cfun)
 v = np.imag(cfun)
 M = np.max(np.max(u))#復(fù)變函數(shù)實(shí)部最大值
 m = np.min(np.min(u))#復(fù)變函數(shù)實(shí)部最大值
 s = np.ones(z.shape)
 fig = plt.figure()
 ax = fig.add_subplot(111,projection='3d')
 # 投影部分用線框圖
 surf1 = ax.plot_wireframe(x,y,m*s,cmap=plt.cm.hsv)
 surf2 = ax.plot_surface(x,y,u,cmap=plt.cm.hsv)

 #繪制復(fù)變函數(shù)1/z時(shí)會(huì)出錯(cuò),ValueError: Axis limits cannot be NaN or Inf
 # ax.set_zlim(m, M) 
 ax.set_xlim((-1,1))
 ax.set_ylim((-1,1))
 ax.set_xlabel('Real')
 ax.set_ylabel('Imag')
 ax.set_xticks([])
 ax.set_yticks([])
 ax.set_zticks([])
 ax.set_autoscalez_on(True)#z軸自動(dòng)縮放

 ax.grid('on')
 plt.show()

def _test_cplxmap():
 '''測(cè)試cplxmap函數(shù)'''
 z = cplxgrid(30)
 w1 = z
 w2 = z**3
 w3 = (z**4-1)**(1/4)
 w4 = 1/z
 w5 = np.arctan(2*z)
 w6 = np.sqrt(z)
 w = [w1,w2,w3,w4,w5,w6]
 for i in w:
 cplxmap(z,i)

def _test_cplxroot():
 '''測(cè)試cplxroot函數(shù)'''
 cplxroot(n=2)
 cplxroot(n=3)
 cplxroot(n=4)
 cplxroot(n=5)

if __name__ == '__main__':
 _test_cplxmap()
 _test_cplxroot()

以上這篇python/Matplotlib繪制復(fù)變函數(shù)圖像教程就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python3和pyqt5實(shí)現(xiàn)控件數(shù)據(jù)動(dòng)態(tài)顯示方式

    Python3和pyqt5實(shí)現(xiàn)控件數(shù)據(jù)動(dòng)態(tài)顯示方式

    今天小編就為大家分享一篇Python3和pyqt5實(shí)現(xiàn)控件數(shù)據(jù)動(dòng)態(tài)顯示方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • Python+PyQt5開發(fā)一個(gè)圖片尺寸修改器

    Python+PyQt5開發(fā)一個(gè)圖片尺寸修改器

    我們?cè)谌粘^k公時(shí),經(jīng)常需要將圖片進(jìn)行修改尺寸,本文將使用python和PyQt5開發(fā)一個(gè)方便圖片修改尺寸工具,感興趣的小伙伴可以了解一下
    2025-03-03
  • Python學(xué)習(xí)工具jupyter notebook安裝及用法解析

    Python學(xué)習(xí)工具jupyter notebook安裝及用法解析

    這篇文章主要介紹了Python學(xué)習(xí)工具jupyter notebook安裝及用法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-10-10
  • python神經(jīng)網(wǎng)絡(luò)Keras實(shí)現(xiàn)LSTM及其參數(shù)量詳解

    python神經(jīng)網(wǎng)絡(luò)Keras實(shí)現(xiàn)LSTM及其參數(shù)量詳解

    這篇文章主要為大家介紹了python神經(jīng)網(wǎng)絡(luò)Keras實(shí)現(xiàn)LSTM及其參數(shù)量詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • 解決reload(sys)后print失效的問題

    解決reload(sys)后print失效的問題

    這篇文章主要介紹了解決reload(sys)后print失效的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • Python函數(shù)參數(shù)的4種方式

    Python函數(shù)參數(shù)的4種方式

    本文主要介紹了Python函數(shù)參數(shù)的4種方式,主要包括必選參數(shù),默認(rèn)參數(shù),可選參數(shù),關(guān)鍵字參數(shù),具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-01-01
  • Python利用PyPDF2庫(kù)處理PDF文件的基本操作

    Python利用PyPDF2庫(kù)處理PDF文件的基本操作

    PyPDF2是一個(gè)Python庫(kù),用于處理PDF文件,包括合并、分割、旋轉(zhuǎn)和提取文本等操作,它是一個(gè)功能強(qiáng)大且靈活的工具,可用于自動(dòng)化處理PDF文件,適用于各種應(yīng)用,從文檔管理到數(shù)據(jù)分析,本文將深入介紹PyPDF2庫(kù),掌握如何利用它來處理PDF文件,需要的朋友可以參考下
    2023-11-11
  • python docx 中文字體設(shè)置的操作方法

    python docx 中文字體設(shè)置的操作方法

    今天小編就為大家分享一篇python docx 中文字體設(shè)置的操作方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • Python字體反爬實(shí)戰(zhàn)案例分享

    Python字體反爬實(shí)戰(zhàn)案例分享

    這篇文章主要介紹了Python字體反爬實(shí)戰(zhàn)案例分享,文章基于python的相關(guān)資料利用實(shí)習(xí)?x站點(diǎn)實(shí)戰(zhàn)案例,具有一定的的參考價(jià)值,需要的小伙伴可以參考一下
    2022-06-06
  • pytorch實(shí)現(xiàn)多項(xiàng)式回歸

    pytorch實(shí)現(xiàn)多項(xiàng)式回歸

    這篇文章主要為大家詳細(xì)介紹了pytorch實(shí)現(xiàn)多項(xiàng)式回歸,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-04-04

最新評(píng)論

凤城市| 昂仁县| 云霄县| 平利县| 子洲县| 呼伦贝尔市| 怀化市| 长汀县| 宜兰市| 天柱县| 黄平县| 八宿县| 大方县| 长宁县| 乌兰察布市| 黔东| 郓城县| 章丘市| 栾城县| 桃源县| 武强县| 茂名市| 秦皇岛市| 新宁县| 甘德县| 蒙阴县| 汉源县| 扎囊县| 台湾省| 钟山县| 沙湾县| 凌海市| 阜宁县| 高邮市| 丹阳市| 长泰县| 漳州市| 宁南县| 宜宾市| 乐业县| 资兴市|