0
0

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 3 years have passed since last update.

Maxima 手習い(Maxima で積分)

Last updated at Posted at 2021-08-28

ずっと以前から数式処理ソフトには憧れがあったのですが面倒臭そうなイメージがあってあまり調べてはいませんでした。
もう微分積分の計算方法を忘れつつあるので、せめて計算機で積分を計算できるように、やりかたを調べておこうと思いました。

お題はこんな積分です。

\int \sqrt{x + \sqrt{x + \sqrt{x + ...}}} dx

被積分関数を f とすると、上記の ... の部分もまた f と同じになるので

f = \sqrt{x + f}

と書けるはずです。Maxima でも同じく被積分関数を定義してみます:

integrand: f = sqrt(x + f);

wxMaxima で実行すると、数式を綺麗に表示してくれます。
i1_2.png

根号があると気持ち良くないので、この両辺を二乗して全体を ... = 0 の形の式に直すと:

f^2 - x - f

と変形できます。maxima 上でも、被積分関数の左辺 first(integrand) と 右辺 second(integrand) それぞれの二乗の差をとる式変形を以下のように書けます:

first(integrand)^2-second(integrand)^2

soluve を使って、この二次方程式の解を得ることができます。これで非積分関数 f を x の関数として得ることができました。

solutions: solve(first(integrand)^2-second(integrand)^2, f);

i2_2.png

ラベルを solutions と複数形にしているのは、二次方程式の2つの解が結果として得られるためです。以下のようにプロットして見ると一方は x > 0 のときに負の値をとるので前者は不適格なのだろうと思うことができますが、リスト上から不適格な解を取り除く方法を知らない Maxima 初心者なのでこのまま計算を進めることにします...

draw(map(lambda([solution], gr2d(key=string(solution), explicit(second(solution), x, 0, 20))),
         solutions));

plot_solutions.png

得られた2つの解それぞれを x で積分してみます。

map(lambda([solution], expand(integrate(second(solution), x))),
    solutions);

i3_2.png

後者の結果が求めたい計算結果となりました。

手順をまとめて書くと、以下です:

integrand: f = sqrt(x + f);
solutions: solve(first(integrand)^2-second(integrand)^2, f);
map(lambda([solution], expand(integrate(second(solution), x))),
    solutions);
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?