Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to calculate pi with Python

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use Python to calculate pi". In daily operation, I believe many people have doubts about how to calculate pi with Python. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use Python to calculate pi". Next, please follow the editor to study!

I. the history of pi

1. China

During the ★ Wei and Jin dynasties, Liu Hui used the method of gradually increasing the number of edges of regular polygons to approach the circumference of the circle, and obtained the approximate value of 3.1416 of π.

During the ★ Han Dynasty, Zhang Heng concluded that the square of π divided by 16 is equal to 5 to 8, that is, π is equal to the square of 10 (about 3.162). Although this value is not very accurate, it is easy to understand, so it has been popular in Asia for a while.

★ Wang Fan found another value of pi, which is 3.156, but no one knows how he got it (ps. There is no open source! ).

In the 5th century AD, Zu Chongzhi and his son calculated a positive 24576 polygon and calculated a pi of about 355 pi. Compared with the real value, the error was less than 1/800000000. The record was not broken until a thousand years later. (ps. In an age when most people don't know the Pythagorean theorem, it's awesome! )

2. India

★ in about 530 AD, the mathematician Ayebodo used the perimeter of 384polygons to calculate that the pi was about √ 9.8684.

★ Brahmin Gupta uses a different method to infer that pi is equal to the square root of 10. (ps. The result is the same as that of Boss Zhang Heng, but the process is different)

3. Europe

★ Fibonacci calculated that pi was about 3.1418.

★ Weida calculated 3.1415926535 using Archimedes's method.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 213

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report