2020年1月9日木曜日

学習環境

解析入門(上) (松坂和夫 数学入門シリーズ 4) (松坂 和夫(著)、岩波書店)の第8章(積分の計算)、8.2(定積分の計算)、問題1の解答を求めてみる。



    1. x = a sin t

      とおくと、

      dx dt = a cos t 0 a a 2 - x 2 dx = 0 π 2 a 2 - a 2 sin 2 t a cos t dt = a 2 0 π 2 1 - sin 2 t cos t dt = a 2 0 π 2 cos 2 t dt = a 2 0 π 2 cos 2 t + 1 2 dt = a 2 2 1 2 sin 2 t + t 0 π 2 = a 2 2 · π 2 = π a 2 4

    2. 0 a dx a 2 - x 2 = 0 π 2 a cos t a cos t dt = π 2

    3. 0 1 dx 1 + x + x 2 = 0 1 dx x + 1 2 2 + 3 4 x + 1 2 = 3 2 t dx dt = 3 2 0 1 dy 1 + x + x 2 = 3 2 1 3 3 dt 3 4 t 2 + 3 4 = 2 3 3 arctan 3 - arctan 1 3 = 2 3 3 π 3 - π 6 = 2 3 3 · π 6 = 3 9 π = π 3 3

    4. - 1 1 dy 1 + x 2 2 = 2 0 1 dx 1 + x 2 2 dx 1 + x 2 2 = 1 2 2 - 1 x x 2 + 1 + 2 · 2 - 3 dx 1 + x 2 = 1 2 x x 2 + 1 + arctan x - 1 1 dx 1 + x 2 2 = x x 2 + 1 + arctan x 0 1 = 1 2 + arctan 1 - arctan 0 = 1 2 + π 4

    5. tan θ 2 = t 1 2 cos 2 θ 2 = dt d θ 0 π d θ 1 + a cos θ = 0 1 1 + a cos θ · 2 cos 2 θ 2 dt = lim b 0 b 2 cos 2 θ 2 1 + a cos 2 θ 2 - sin 2 θ 2 dt = lim b 0 b 2 cos 2 θ 2 sin 2 θ 2 + cos 2 θ 2 + a cos 2 θ 2 - sin 2 θ 2 dt = lim b 0 b 2 t 2 + 1 + a 1 - t 2 dt = 2 lim b 0 b 1 1 - a t 2 + 1 + a dt = 2 1 - a lim b 0 b 1 t 2 + 1 + a 1 - a dt = 2 1 - a · 1 - a 1 + a lim b arctan 1 - a 1 + a t 0 b = 2 1 - a 2 lim b arctan 1 - a 1 + a b = 2 1 - a 2 · π 2 = π 1 - a 2

    6. x arcsin x 1 - x 2 dx = x arcsin 2 x - arcsin x + x 1 - x 2 arcsin x dx = x arcsin 2 x - arcsin 2 x dx - x arcsin x 1 - x 2 dx x arcsin x 1 - x 2 = 1 2 x arcsin 2 x - arcsin 2 x dx t = arcsin x dt dx = 1 1 - x 2 sin t = x arcsin 2 x dx = t 1 - x 2 2 dt = t 1 - sin 2 t 2 dt = t 2 cos t dt = t 2 sin t - 2 t sin t dt = t 2 sin t - 2 - t cos t + cos t dt - 1 1 x arcsin x 1 - x 2 dx = 1 2 x arcsin 2 x - 1 1 - 1 2 t 2 sin t - π 2 π 2 - t cos t - π 2 π 2 + sin t - π 2 π 2 = 1 2 arcsin 2 1 + arcsin 2 - 1 - 1 2 · π 2 4 · 2 + 2 = 1 2 π 2 4 + π 2 4 - π 2 4 + 2 = 2

    7. e - a x sin b x dx = - 1 a e - a x sin b x + b a e - a x cos b x dx = - 1 a e - a x sin b x + b a - 1 a e - a x cos b x - b a e - a x sin b x dx = - 1 a e - a x sin b x - b a 2 e - a x cos b x - b 2 a 2 e - a x sin b x dx 1 + b 2 a 2 e - a x sin b x dx = - 1 a e - a x sin b x - b a 2 e - a x cos b x e - a x sin b x dx = - a 2 a 2 + b 2 · 1 a e - a x sin b x + b a e - a x cos b x 0 + e - a x sin b x d x = lim A 0 A e - a x sin b x dx = - a a 2 + b 2 lim A e - a x sin b x + b a cos b x 0 A = - a a 2 + b 2 lim A e - a A sin b A + b a cos b A - sin 0 + b a cos 0 = - a a 2 + b 2 · - b a = b a 2 + b 2

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sqrt, sin, cos, asin, exp, Integral, pi, Rational, oo, plot

print('1.')

x = symbols('x')
a = symbols('a', positive=True)
b = symbols('b', nonzero=True)
fs = [sqrt(a ** 2 - x ** 2),
      1 / sqrt(a ** 2 - x ** 2),
      1 / (1 + x + x ** 2),
      1 / (1 + x ** 2) ** 2,
      1 / (1 + Rational(1, 2) * cos(x)),
      x * asin(x) / sqrt(1 - x ** 2),
      exp(-1 * 1 * x) * sin(2 * x)]


class MyTestCase(TestCase):
    def test1(self):
        self.assertEqual(Integral(fs[0], (x, 0, a)).doit(), pi * a ** 2 / 4)

    def test2(self):
        a = symbols('a', positive=True)
        self.assertEqual(Integral(fs[1], (x, 0, a)).doit(), pi / 2)

    def test3(self):
        self.assertEqual(Integral(fs[2], (x, 0, 1)).doit(), pi / (3 * sqrt(3)))

    def test4(self):
        self.assertEqual(
            Integral(fs[3], (x, -1, 1)).doit(), Rational(1, 2) + pi / 4)

    def test5(self):
        d = {a: Rational(1, 2)}
        self.assertEqual(
            Integral(fs[4].subs(d), (x, 0, pi)).doit(), (pi / sqrt(1 - a ** 2)).subs(d))

    def test6(self):
        self.assertEqual(Integral(fs[5], (x, -1, 1)).doit(), 2)

    def test7(self):
        d = {a: 1, b: 2}
        self.assertEqual(
            Integral(fs[6].subs(d), (x, 0, oo)).doit(
            ), (b / (a ** 2 + b ** 2)).subs(d))


p = plot(*[f.subs({a: 1, b: 2}) for f in fs],
         (x, -5, 5),
         ylim=(-5, 5),
         legend=True,
         show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
    o.line_color = color

p.show()
p.save('sample1.png')


if __name__ == '__main__':
    main()

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

% ./sample1.py -v
1.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok
test3 (__main__.MyTestCase) ... ok
test4 (__main__.MyTestCase) ... ok
test5 (__main__.MyTestCase) ... ok
test6 (__main__.MyTestCase) ... ok
test7 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 7 tests in 2.425s

OK
%

0 コメント:

コメントを投稿