新聞中心
如何用python表示三角函數(shù)如題,能不能
Python編碼下面的三角函數(shù)包括以下種類:
“只有客戶發(fā)展了,才有我們的生存與發(fā)展!”這是創(chuàng)新互聯(lián)公司的服務(wù)宗旨!把網(wǎng)站當(dāng)作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個(gè)不僅審美在線,而且實(shí)用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對(duì)網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、網(wǎng)站制作、網(wǎng)站開(kāi)發(fā)、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無(wú)止境。
12345678910
acos(x) //返回x的反余弦弧度值。 asin(x) //返回x的反正弦弧度值。 atan(x) //返回x的反正切弧度值。 atan2(y, x) //返回給定的 X 及 Y 坐標(biāo)值的反正切值。 cos(x) //返回x的弧度的余弦值。 hypot(x, y) //返回歐幾里德范數(shù) sqrt(x*x + y*y)。 sin(x) //返回的x弧度的正弦值。 tan(x) //返回x弧度的正切值。 degrees(x) //將弧度轉(zhuǎn)換為角度,如degrees(math.pi/2) , 返回90.0 radians(x) //將角度轉(zhuǎn)換為弧度
下面介紹了Python計(jì)算三角函數(shù)之a(chǎn)sin()方法的使用(其它只需替換上述方法即可),返回x的反正弦,以弧度表示,代碼如下:
12345678910111213
#!/usr/bin/python import math print "asin(0.64) : ", math.asin(0.64) print "asin(0) : ", math.asin(0) print "asin(-1) : ", math.asin(-1) print "asin(1) : ", math.asin(1) #運(yùn)行結(jié)果如下:asin(0.64) : 0.694498265627asin(0) : 0.0asin(-1) : -1.57079632679asin(1) : 1.57079632679
如何用python完成:用自頂向下設(shè)計(jì)方法編寫程序:在屏幕上打印三角函數(shù)y = sin(x)的圖像。
I wrote this in Tkinter for you, in case you don't know Tkinter, it is a built-in module for most python versions.
If you want a commandline version, you can ask me, but tell you what, since those values are all
float numbers, so it's hard to get a precise graph in commandline window.
Well, in this version, I enlarged each element's position by 40 and then change them to integer, guess this is an endurable loss of precision.
#
from?math?import?radians
from?math?import?sin
from?Tkinter?import?*
pos?=?[]
xPos?=?0
centerX?=?0
centerY?=?0
for?deg?in?range(-360,?361,?10):
pos.append([xPos,?int(40*(sin(radians(deg))))])?#1000?too?big?for?my?screen
xPos+=1
if?deg?==?0:
centerX?=?xPos-1
centerY?=?pos[-1][1]
root?=?Tk()
root.title('trianble?graph?from?-180?to?180')
width,?height?=?550,?450
mHei?=?height/2
mWid?=?width/2
canvas?=?Canvas(root,?width=width,?height=height)
canvas.create_line(0,?mHei,?width,?mHei)???#x?axis
canvas.create_line(mWid,?0,?mWid,?height)??#y?axis
xStep?=?(width-150)/len(pos)
yStep?=?(height-150)/len(pos)
radius?=?3
#?the?middle?point?(sin(0)?is?first?drawn?and?used?as?position?reference?for?all
canvas.create_oval(mWid-radius,?mHei-radius,?mWid+radius,?mHei+radius,?fill='green')
print?pos
print?xStep,?yStep,?centerX,?centerY
#exit(0)
for?i?in?pos:
if?i[0]?==?centerX:?#center?processed?already.
continue
x?=?mWid?+?xStep*(i[0]-centerX)
#?y?is?smaller,?the?bigger?the?value,?so?use?minus
y?=?mHei?-?yStep*(i[1]-centerY)
canvas.create_oval(x-radius,?y-radius,?x+radius,?y+radius,?fill='green')
canvas.pack()
root.mainloop()
如何用python表示三角函數(shù)
在python中,有一個(gè)math module,你可以import math,里面有math.sin(), math.cos(), math.asin()和math.acos()四個(gè)函數(shù)。相信你也知道asin和acos的意思,就是arcsin和arccos。有了這四個(gè)函數(shù)你就可以求函數(shù)值和角度了。但是要注意括號(hào)里面填的數(shù)值,要用弧度制。
簡(jiǎn)單python語(yǔ)言編程:采用自頂向下設(shè)計(jì)方法編寫程序:在屏幕上打印三角函數(shù)y = sin(x)的圖像。
I just wrote an simple one for one other guy.
You may check it here and see if it's useful for you.
如何在python中表達(dá)三角函數(shù),比如sin(x),tan(x),謝謝
在python中,有一個(gè)math
module,你可以import
math,
里面有math.sin(),math.cos(),math.asin()和math.acos()四個(gè)函數(shù).
有了這四個(gè)函數(shù)你就可以求函數(shù)值和角度了.
注意:括號(hào)里面填的數(shù)值,要用弧度制.
sin15°用Python怎么表示?
Python的三角函數(shù)sin(),輸入?yún)?shù)必須是弧度,所以要把角度變換為弧度
import math
# .... 輸入度數(shù)到 degrees 變量....
# 例子里用 30度計(jì)算
degrees=30
radians = degrees * math.pi / 180.0
value = round( math.sin(radians), 4)
print(value)
當(dāng)前題目:python繪制三角函數(shù) python用三角函數(shù)
標(biāo)題鏈接:http://fisionsoft.com.cn/article/dosoggi.html