学習環境
新装版
数学読本3 (松坂
和夫(著)、岩波書店)の第11章(立体的な広がりの中の図形
- 空間図形)、11.3(直線・平面・球の方程式)、平面の方程式の問30の解答を求めてみる。
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Matrix, solve, Rational
from sympy.abc import x, y, z, t
print('30.')
ls = [Matrix([1, 2, 3]) + t * (Matrix([3, 1, -5]) - Matrix([1, 2, 3])),
Matrix([-1, 2, 3]) + t * Matrix([4, 0, 7]),
Matrix([1, -1, -2]) + t * Matrix([1, 4, -1])]
class Test(TestCase):
def test1(self):
t0 = solve(ls[0][2], t)[0]
self.assertEqual(ls[0].subs({t: t0}),
Matrix([Rational(7, 4), Rational(13, 8), 0]))
def test2(self):
t0 = solve(ls[0][1], t)[0]
self.assertEqual(ls[0].subs({t: t0}),
Matrix([5, 0, -13]))
def test3(self):
t0 = solve(
(x - 4 * y + 4 * z - 19).subs(dict(zip([x, y, z], ls[1]))))[0]
self.assertEqual(ls[1].subs({t: t0}),
Matrix([1, 2, Rational(13, 2)]))
def test4(self):
t0 = solve(
(2 * x + 2 * y + z - 7).subs({x: 1 + t, y: -1 + 4 * t, z: -2 - t}))[0]
self.assertEqual(ls[2].subs({t: t0}),
Matrix([2, 3, -3]))
if __name__ == "__main__":
main()
0 コメント:
コメントを投稿