LoginSignup
0
0

More than 1 year has passed since last update.

「pythonを便利に使おう第四回!行列編!」を参考にWolframAlphaとSymPy Liveでやってみたい。

Last updated at Posted at 2021-07-12

original link

WolframAlphaで

 第一問 行列の計算

結果:
次をお試しください:違う表現や表記法をお使いください。。。。。。。

結果:
(-7 | -21
-8 | -18)

第二問 行列の積

結果:
次をお試しください:違う表現や表記法をお使いください。。。。。。。

結果:
(5
5)

結果:
(13 | 7
20 | 10)

第三問 次のrankを求めなさい。

行列の階数:
2

第四問 次の逆行列を求めなさい。

逆数:
(6 | 1 | -7
7 | 1 | -9
-1 | 0 | 1)

第五問 次の行列式を求めなさい。

行列式:
-1

SymPy Liveで

以下のソースコードを貼り付けて、Evaluateです。

from sympy import *
print("#第一問",3*Matrix([[1,-3],[2,-4]])-2*Matrix([[5,6],[7,3]]))
print("#第二問",Matrix([[1,2],[3,1]])*Matrix([[1],[2]]))
print("#第二問",Matrix([[1,3],[2,4]])*Matrix([[4,1],[3,2]]))
print("#第三問",Matrix([[-1,1,-1], [2,0,1] ,[1,-3,2]]).rank())
print("#第四問第五問 コメント文を見て下さい。")
#第一問 Matrix([[-7, -21], [-8, -18]])
#第二問 Matrix([[5], [5]])
#第二問 Matrix([[13, 7], [20, 10]])
#第三問 2
#第四問第五問 コメント文を見て下さい。
#
# 以下調査中:文字化けしない方法を教えて下さい。よろしくお願いします。
#
# ('#\xe7\xac\xac\xe4\xb8\x80\xe5\x95\x8f', Matrix([
# [-7, -21],
# [-8, -18]]))
# ('#\xe7\xac\xac\xe4\xba\x8c\xe5\x95\x8f', Matrix([
# [5],
# [5]]))
# ('#\xe7\xac\xac\xe4\xba\x8c\xe5\x95\x8f', Matrix([
# [13,  7],
# [20, 10]]))
# ('#\xe7\xac\xac\xe4\xb8\x89\xe5\x95\x8f', 2)
# #第四問第五問 コメント文を見て下さい。
0
0
1

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