函數關系
主要看看圖形是怎么樣的
#三角函數的自變量是角度 import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.pi, 50) y = np.sin(x) plt.plot(x, y) plt.title('sin(x)') plt.xticks( (0, np.pi * 0.5, np.pi, np.pi * 1.5, np.pi * 2), ('0', '2/π', 'π', '1.5π', '2π') ) plt.annotate(s='sin(2/π)=1',xy=(np.pi * 0.5,1),xytext=(0.5,0.5),color='red',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red')) plt.annotate(s='sin(π)=1',xy=(np.pi,0),xytext=(0.5,-0.5),color='red',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red')) plt.show()
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.pi, 50) y = np.cos(x) plt.plot(x, y) plt.title('cos(x)') plt.xticks( (0, np.pi * 0.5, np.pi, np.pi * 1.5, np.pi * 2), ('0', '2/π', 'π', '1.5π', '2π') ) plt.annotate(s='cos(2/π)=1',xy=(np.pi * 0.5,0),xytext=(0.5,0.5),color='red',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red')) plt.annotate(s='cos(π)=1',xy=(np.pi,-1),xytext=(0.5,-0.5),color='red',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red')) plt.show()
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.pi, 50) y = np.sin(x)/np.cos(x) plt.plot(x, y) plt.title('tan(x)') plt.xticks( (0, np.pi * 0.5, np.pi, np.pi * 1.5, np.pi * 2), ('0', '2/π', 'π', '1.5π', '2π') ) plt.show()
lnx是以e為底的對數函數,其中e是一個無du限不循環小數,其值約等於2.718281828459…
函數的圖象是過點(1,0)的一條C型的曲線,串過第一,第四象限,且第四象限的曲線逐漸靠近Y
軸,但不相交,第一象限的曲線逐漸的遠離X軸。
其定義域:x>0 值域:y(無窮);一般表示方法為lnx。數學中也常見以logx表示自然對數
import matplotlib.pyplot as plt import numpy as np x=np.arange(0.1,1000) y=np.log(x) plt.plot(x, y) plt.title('lnx 或者是 logx') plt.annotate(s='ln1=0',xy=(1,0),xytext=(0.5,0.5),color='red',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red')) plt.show()
log10(x)又叫lg(x)是以10為底的對數
import matplotlib.pyplot as plt import numpy as np x=np.arange(0.1,50) y=np.log10(x) plt.plot(x, y) plt.title('lgx') plt.annotate(s='lg10=1',xy=(10,1),xytext=(0.5,0.5),color='red',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red')) plt.show()