• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python使用三角迭代计算圆周率PI的方法

python使用三角迭代计算圆周率PI的方法

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python pi,python math.pi,python中pi,python np.pi,raspberry pi python等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python使用三角迭代计算圆周率PI的方法。分享给大家供大家参考。具体如下:

方法1:
# FB36 - 20130825
import math
x = 1.0
y = 1.0
z = 1.0
w = 1.0
v = 1.0
u = 1.0
for i in range(30):
 
    x = math.sin(x) + x
    y = math.cos(y) + y
    z = math.cos(z) + math.sin(z) + z
    w = math.cos(w) - math.sin(w) + w
    v =  math.cos(v) * math.sin(v) + v
    u =  math.cos(u) / math.sin(u) + u
    print i
    print x, y * 2.0, z * 4.0 / 3.0, w * 4.0, v * 2.0, u * 2.0
    print</div>

方法2:
# FB36 - 20130901
import math
def sin2(x):
    return ((math.e ** complex(0.0, x) - math.e ** complex(0.0, -x)) / 2.0).imag
def cos2(x):
    return ((math.e ** complex(0.0, x) + math.e ** complex(0.0, -x)) / 2.0).real
x = 1.0
y = 1.0
x2 = 1.0
y2 = 1.0
for i in range(5):
    x = math.sin(x) + x
    y = math.cos(y) + y
    x2 = sin2(x2) + x2
    y2 = cos2(y2) + y2
    print i, x, x2, y * 2.0, y2 * 2.0</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python 通过pip安装Django详细介绍
  • 用pickle存储Python的原生对象方法
  • 详解Python之数据序列化(json、pickle、shelve)
  • windows下安装Python和pip终极图文教程
  • python一键升级所有pip package的方法
  • 用python记录运行pid,并在需要时kill掉它们的实例
  • python 根据pid杀死相应进程的方法
  • windows及linux环境下永久修改pip镜像源的方法
  • Python切换pip安装源的方法详解
  • Python实现更改图片尺寸大小的方法(基于Pillow包)

相关文章

  • Python实现的飞速中文网小说下载脚本
  • Python中的time模块与datetime模块用法总结
  • Python多线程结合队列下载百度音乐的方法
  • Python 网络编程起步(Socket发送消息)
  • python 实现自动远程登陆scp文件实例代码
  • python实现将英文单词表示的数字转换成阿拉伯数字的方法
  • pyv8学习python和javascript变量进行交互
  • 详解Python中的__getitem__方法与slice对象的切片操作
  • 在Python中使用Mako模版库的简单教程
  • python获取元素在数组中索引号的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python根据经纬度计算距离示例
    • Python 字典与字符串的互转实例
    • python比较两个列表大小的方法
    • 利用python实现数据分析
    • Python ftp上传文件
    • Using Django with GAE Python 后台抓取多个网站的页面全文
    • Python实现备份文件实例
    • 详解Python中expandtabs()方法的使用
    • python获取局域网占带宽最大3个ip的方法
    • 浅谈Python程序与C++程序的联合使用

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有