0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

sympy で二段階以上の有理化は apart()

Last updated at Posted at 2023-05-27

以下の式の分母を有理化する

$$
\frac{\sqrt{5} - \sqrt{6} + \sqrt{11}}{\sqrt{5} + \sqrt{6} + \sqrt{11}}
$$

>>> from sympy import sqrt, apart, var, factor
>>> var('d')  # 以下に使うだけなので,変数名は何でもよい
>>> f = (sqrt(5) - sqrt(6) + sqrt(11)) / (sqrt(5) + sqrt(6) + sqrt(11))
>>> apart(f, d)
-sqrt(30)/5 + sqrt(55)/5

$$
\frac{-\sqrt{7} + \sqrt{5} + 2 \sqrt{3} + 2 \sqrt{6}}{\sqrt{7} + \sqrt{5} + 2 \sqrt{3} + 2 \sqrt{6}}
$$


$$
-\frac{-9420 - 1526\sqrt{30} - 708\sqrt{70} - 936\sqrt{21} - 924\sqrt{2} + 631\sqrt{35} + 2506\sqrt{15} + 1680\sqrt{42}}{8279}
$$
になります。

いや,一段階だって,色々苦労している人がいるようですが,apart() で一発です。

>>> f = (3 + sqrt(8)) / (1 - sqrt(5))
>>> factor(apart(f, d))
-(2*sqrt(2) + 3 + 2*sqrt(10) + 3*sqrt(5))/4
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?