2020年2月29日土曜日

数学 - Python - 解析学 - 多変数の関数 - ベクトルの微分 - 微分係数 - 曲線と平面の交点

1. $\begin{array}{l}3·2{t}^{2}-14\left(1-t\right)+3+{t}^{2}-10=0\\ 7{t}^{2}+14t-21=0\\ {t}^{2}+2t-3=0\\ \left(t+3\right)\left(t-1\right)=0\\ t=1,-3\end{array}$

よって、求める曲線と平面の交点は

$\begin{array}{l}\left(2,0,4\right)\\ \left(18,4,12\right)\end{array}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, solveset
from sympy.plotting import plot3d_parametric_line, plot3d

print('19.')

t, x, y = symbols('t, x, y', real=True)
x0 = 2 * t ** 2
y0 = 1 - t
z0 = 3 + t ** 2

class MyTestCase(TestCase):
def test(self):
ts = solveset(3 * x0 - 14 * y0 + z0 - 10, t)
self.assertEqual(ts, {1, -3})

p = plot3d_parametric_line(
2 * t ** 2, 1 - t, 3 + t ** 2,
(t, -5, 2),
legend=True, show=False)

p.append(plot3d(-(3 * x - 14 * y - 10), show=False)[0])

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('sample19.png')

if __name__ == "__main__":
main()


% ./sample19.py -v
19.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.033s

OK
%