2020年6月5日金曜日

学習環境

新装版 数学読本3 (松坂 和夫(著)、岩波書店)の第11章(立体的な広がりの中の図形 - 空間図形)、11.3(直線・平面・球の方程式)、平面の方程式の問31の解答を求めてみる。


  1. 2平面の法線ベクトルはそれぞれ

    2 , - 1 , 1 , 1 , 2 , - 4

    よって 2平面のなす角の余弦は

    cos θ = 2 , - 1 , 1 · 1 , 2 , - 4 2 , - 1 , 1 1 , 2 , - 4 = 2 - 2 - 4 4 + 1 + 1 1 + 4 + 16 = - 4 6 · 21 = - 4 3 · 2 3 · 7 = - 4 3 14 = - 4 14 3 · 14 = - 2 14 21

    よって鋭角の余弦は

    2 14 21

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Matrix, sqrt, solveset, cos, pprint, pi, Interval
from sympy.plotting import plot3d
from sympy.abc import x, y, t

print('31.')


class TestCosine(TestCase):
    def test(self):
        a = Matrix([2, -1, 1])
        b = Matrix([1, 2, -4])
        self.assertEqual(a.dot(b) / (a.norm() * b.norm()),
                         -2 * sqrt(14) / 21)


pprint([(theta, float(theta))
        for theta in solveset(cos(t) - 2 * sqrt(14) / 21,
                              domain=Interval(0, pi))])
p = plot3d(3 - (2 * x - y),
           (x + 2 * y) / 4,
           xlim=(-30, 30),
           ylim=(-30, 30),
           show=False)
p.show()
p.save('sample31.png')

if __name__ == "__main__":
    main()

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

% ./sample31.py -v
31.
⎡⎛    ⎛√110⎞                    ⎞⎤
⎢⎜atan⎜────⎟, 1.2064396014231937⎟⎥
⎣⎝    ⎝ 4  ⎠                    ⎠⎦
test (__main__.TestCosine) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.003s

OK
%

0 コメント:

コメントを投稿