LoginSignup
0
2

More than 5 years have passed since last update.

sympyで「楕円の面積」をやってみた

Posted at

(参考)モンテカルロ法で楕円の面積を求めてみる
https://qiita.com/jp_yen/items/5d561ada97dd4fc6d558
(参考)Ellipses>area
https://docs.sympy.org/latest/modules/geometry/ellipses.html
(参考)高校数学の美しい物語>楕円の面積公式の3通りの導出
https://mathtrain.jp/sofdaen

fullscript.py
from sympy import *
p1 = Point(0, 0)
e1 = Ellipse(p1, 160, 90)
print(e1.area)                                # 14400*pi
print(float(e1.area))                        # 45238.93421169302
#
var("x, y, a, b")
p1 = Point(x, y)
e1 = Ellipse(p1, a, b)
print(e1.area)                               # pi*a*b
print(float(e1.area.subs(a,160).subs(b,90))) # 45238.93421169302
#
var("aa, bb")
f=4*bb*(1-x**2/aa**2)**(1/2)
print(integrate(f, (x, 0, aa)))   #4.0*aa*bb*hyper((-0.5, 1/2), (3/2,), exp_polar(2*I*pi))
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2