python画三角函数图 三角函数Python

如何用python表示三角函数如题,能不能

Python编码下面的三角函数包括以下种类:

站在用户的角度思考问题,与客户深入沟通,找到曲江网站设计与曲江网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计制作、网站制作、企业官网、英文网站、手机端网站、网站推广、空间域名、虚拟主机、企业邮箱。业务覆盖曲江地区。

12345678910

acos(x) //返回x的反余弦弧度值。 asin(x) //返回x的反正弦弧度值。 atan(x) //返回x的反正切弧度值。 atan2(y, x) //返回给定的 X 及 Y 坐标值的反正切值。 cos(x) //返回x的弧度的余弦值。 hypot(x, y) //返回欧几里德范数 sqrt(x*x + y*y)。 sin(x) //返回的x弧度的正弦值。 tan(x) //返回x弧度的正切值。 degrees(x) //将弧度转换为角度,如degrees(math.pi/2) , 返回90.0 radians(x) //将角度转换为弧度

下面介绍了Python计算三角函数之asin()方法的使用(其它只需替换上述方法即可),返回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) #运行结果如下:asin(0.64) : 0.694498265627asin(0) : 0.0asin(-1) : -1.57079632679asin(1) : 1.57079632679

简单python语言编程:采用自顶向下设计方法编写程序:在屏幕上打印三角函数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表示三角函数

Python编码下面的三角函数包括以下种类:acos(x)//返回x的反余弦弧度值。asin(x)//返回x的反正弦弧度值。atan(x)//返回x的反正切弧度值。atan2(y,x)//返回给定的X及Y坐标值的反正切值。cos(x)//返回x的弧度的余弦值。hypot(x,y

描述

sin()返回的x弧度的正弦值。

语法

以下是sin()方法的语法:

importmath

math.sin(x)

注意:sin()是不能直接访问的,需要导入math模块,然后通过math静态对象调用该方法。

参数

x--一个数值。

返回值

返回的x弧度的正弦值,数值在-1到1之间。

实例

以下展示了使用sin()方法的实例:

#!/usr/bin/python

import math

print "sin(3) : ", math.sin(3)

print "sin(-3) : ", math.sin(-3)

print "sin(0) : ", math.sin(0)

print "sin(math.pi) : ", math.sin(math.pi)

print "sin(math.pi/2) : ", math.sin(math.pi/2)

以上实例运行后输出结果为:

sin(3) : 0.14112000806

sin(-3) : -0.14112000806

sin(0) : 0.0

sin(math.pi) : 1.22460635382e-16

sin(math.pi/2) : 1

总结

以上就是本文关于Python入门之三角函数sin()函数实例详解的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:python正则表达式re之compile函数解析、Python中enumerate函数代码解析、简单了解Python中的几种函数等,有什么问题可以随时留言,小编会及时回复大家的。感谢朋友们对本站的支持!

如何用python完成:用自顶向下设计方法编写程序:在屏幕上打印三角函数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()

如何使用软件绘画三角函数图像

用origin7.0

1在菜单栏下面一排选第6个按钮(New Function)

2在跳出的窗口里输入 sin(x)

3然后点OK

4在出现的图的上方点 Rescale 按钮

大功告成

如何在python中表达三角函数,比如sin,tan

在python中,有一个math module,你可以import math,

里面有math.sin(),math.cos(),math.asin()和math.acos()四个函数.

有了这四个函数你就可以求函数值和角度了.

注意:括号里面填的数值,要用弧度制.


新闻标题:python画三角函数图 三角函数Python
当前网址:http://myzitong.com/article/hhhgoc.html