
No.3ベストアンサー
- 回答日時:
>(S1の逆行列)(T1)(S2の逆行列)(T2)の積を計算したいんです。
ここまでコッチでもやってみましたが、問題無かったですよ。
/*
wxMaxima 0.7.1 http://wxmaxima.sourceforge.net
Maxima 5.12.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) k:2*%pi/l;
(%o1) (2*%pi)/l
(%i2) b:sqrt(B^2-k^2*1.5^2);
(%o2) sqrt(B^2-(9.0*%pi^2)/l^2)
(%i3) a:sqrt(B^2-k^2*1.55^2);
(%o3) sqrt(B^2-(9.610000000000001*%pi^2)/l^2)
(%i4) S1:matrix(
[%e^(b*x1),%e^(-b*x1)],
[b*%e^(b*x1),-b*%e^(-b*x1)]
);
(%o4) matrix([%e^(x1*sqrt(B^2-(9.0*%pi^2)/l^2)),%e^(-x1*sqrt(B^2-(9.0*%pi^2)/l^2))],[sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x1*sqrt(B^2-(9.0*%pi^2)/l^2)),-sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(-x1*sqrt(B^2-(9.0*%pi^2)/l^2))])
(%i5) T1:matrix(
[%e^(a*x1),%e^(-a*x1)],
[a*%e^(a*x1),-a*%e^(-a*x1)]
);
(%o5) matrix([%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)),%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))],[sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)),-sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))])
(%i6) S2:matrix(
[%e^(a*x2),%e^(-a*x2)],
[a*%e^(a*x2),-a*%e^(-a*x2)]
);
(%o6) matrix([%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)),%e^(-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))],[sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)),-sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))])
(%i7) T2:matrix(
[%e^(b*x2),%e^(-b*x2)],
[b*%e^(b*x2),-b*%e^(-b*x2)]
);
(%o7) matrix([%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)),%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2))],[sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)),-sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2))])
(%i8) invert(S1) . T1 . invert(S2) . T2;
(%o8)
matrix([(%e^(-x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2)-sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))))/(2*sqrt(B^2-(9.0*%pi^2)/l^2))+(%e^(-x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))+%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2)))/2,(%e^(-x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))-sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2))/2)))/(2*sqrt(B^2-(9.0*%pi^2)/l^2))+(%e^(-x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2))/2)+%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))))/2],[(%e^(x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))+%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2)))/2-(%e^(x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2)-sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.0*%pi^2)/l^2)+x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))))/(2*sqrt(B^2-(9.0*%pi^2)/l^2)),(%e^(x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2))/2)+%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))))/2-(%e^(x1*sqrt(B^2-(9.0*%pi^2)/l^2))*(sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*(%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))/2-(sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(-x2*sqrt(B^2-(9.0*%pi^2)/l^2)-x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)))-sqrt(B^2-(9.610000000000001*%pi^2)/l^2)*%e^(-x1*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))*((sqrt(B^2-(9.0*%pi^2)/l^2)*%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2)))/(2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2))+%e^(x2*sqrt(B^2-(9.610000000000001*%pi^2)/l^2)-x2*sqrt(B^2-(9.0*%pi^2)/l^2))/2)))/(2*sqrt(B^2-(9.0*%pi^2)/l^2))])
一つ気になったんですが、各行列の第二行はすべて第一行の微分でしょ?
そうすると、例えば、微分演算子をDとすると、
D(e^(b*x))=b*e^(b*x)
が成り立ってるんですが、そうすると入力は
%e^b*x
ではなくって
%e^(b*x)
としなければいけません。計算機の約束事で言うと、前者はeのb乗に係数xをかけたもの、と解釈されてしまいます。入力したい数式はそうじゃないでしょ?
ないしは、ショートカットとして
y:e^(b*x)
とでも定義しておいて、
diff(y,x)
として「yをxに付いて微分せよ」と指定して入力を減らすテもあります。
>一つ気になったんですが、各行列の第二行はすべて第一行の微分でしょ?
まさにそうです。タイプミスが多いもので。
丁寧に回答していただき大変助かりました。もう少し落ち着いてやらなくてはいけませんね。
しっかりと勉強してこのソフトを使いこなせるようになりたいと思います。ありがとうございました!
No.2
- 回答日時:
数式見る限り、微分絡みかしら?
まあ、それはさておき、こちらで試した限り、問題は特に生じなかったですね。
以下のような計算を試したんじゃないかな、とか思ってますが。
(ひょっとしたら、教えてGooのせいで崩れた表示になるかもしれませんがご勘弁を)
Maxima 5.12.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) k:2*%pi/l;
2 %pi
(%o1) -----
l
(%i2) b:sqrt(B^2-k^2*1.5^2);
2
2 9.0 %pi
(%o2) sqrt(B - --------)
2
l
(%i3) S1:matrix(
[%e^(b*x1),%e^(-b*x1)],
[b*%e^(b*x1),-b*%e^(-b*x1)]
);
[ 2 ]
[ 2 9.0 %pi ]
[ x1 sqrt(B - --------) ]
[ 2 ]
[ l ]
[ %e ]
[ ]
(%o3) Col 1 = [ 2 ]
[ 2 9.0 %pi ]
[ x1 sqrt(B - --------) ]
[ 2 2 ]
[ 2 9.0 %pi l ]
[ sqrt(B - --------) %e ]
[ 2 ]
[ l ]
[ 2 ]
[ 2 9.0 %pi ]
[ - x1 sqrt(B - --------) ]
[ 2 ]
[ l ]
[ %e ]
[ ]
Col 2 = [ 2 ]
[ 2 9.0 %pi ]
[ - x1 sqrt(B - --------) ]
[ 2 2 ]
[ 2 9.0 %pi l ]
[ - sqrt(B - --------) %e ]
[ 2 ]
[ l ]
(%i4) invert(%);
[ 2 2 ]
[ 2 9.0 %pi 2 9.0 %pi ]
[ - x1 sqrt(B - --------) - x1 sqrt(B - --------) ]
[ 2 2 ]
[ l l ]
[ %e %e ]
[ -------------------------- -------------------------- ]
[ 2 2 ]
[ 2 9.0 %pi ]
[ 2 sqrt(B - --------) ]
[ 2 ]
[ l ]
(%o4) [ ]
[ 2 2 ]
[ 2 9.0 %pi 2 9.0 %pi ]
[ x1 sqrt(B - --------) x1 sqrt(B - --------) ]
[ 2 2 ]
[ l l ]
[ %e %e ]
[ ------------------------ - ------------------------ ]
[ 2 2 ]
[ 2 9.0 %pi ]
[ 2 sqrt(B - --------) ]
[ 2 ]
[ l ]
(%i5) (%o3) . (%o4);
[ 1 0 ]
(%o5) [ ]
[ 0 1 ]
(%i6)
とまあ行列A×Aの逆行列は単位行列となって問題は生じません。
まず「一々入力するのはメンド臭い」ので、一旦入力した値、または計算/出力された値を再度入力しなおすのはメンド臭いんで、上手い具合出力番号(%o何とか)を使って操作してください。なお、(%)とだけ入力すると、直前に出力された結果が用いられます。
invert()と言う命令は「逆行列を求める」命令です。
また、「通常の掛け算」は確かにアスタリスク(*)を用いますが、Maximaでは行列同士の積を計算する場合、ピリオド(.)を用います。多分ここが操作ミスでしょう。行列同士で(*)を用いた場合、いわゆる行列同士の積の計算結果は求まらず、代わりに成分同士を掛け合わせただけの行列が返されます。上の例で言うと、出力番号%o3と%o4を用いて、
(%o3) . (%o4)
と記述するのが正しいやり方です。
この回答への補足
すいません。説明不足でした。
S1:matrix([%e^b*x1,%e^(-b*x1)],[b*%e^(b*x1),-b*%e^(-b*x1)]);
T1:matrix([%e^a*x1,%e^(-a*x1)],[a*%e^(a*x1),-a*%e^(-a*x1)]);
S2:matrix([%e^a*x2,%e^(-a*x2)],[a*%e^(a*x2),-a*%e^(-a*x2)]);
T2:matrix([%e^b*x2,%e^(-b*x2)],[b*%e^(b*x2),-b*%e^(-b*x2)]);
{k:2*%pi/l; b:sqrt(B^2-k^2*1.5^2);a:sqrt(B^2-k^2*1.55^2);}
とした時、(S1の逆行列)(T1)(S2の逆行列)(T2)
の積を計算したいんです。このあとは、S3…、T3…などもつくりC、x3
などの定数を追加して同じような積の計算をしてこの行列の(2,2)成分
をfとした時のf=0とした時のBの値を求めるということをしたいのです
が。教えてもらっている立場なのに本当申し訳ないです。
出力番号を入力するとその結果を使えるんですね!勉強になりま
す。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
改行の正規表現について
-
vba 正規表現について教えてく...
-
画像生成AIのプロンプトの作り...
-
pythonでのローカルファイルか...
-
CSVファイルの複数行削除
-
今のプログラミング言語
-
プログラム言語
-
Pythonのエラーメッセージをコ...
-
vba クリップボードクリアにつ...
-
if関数とは?
-
uwscでPauseキーが押されたら、...
-
Geminiフォーム 画像生成で 人...
-
COPYコマンドで、最後に1文字...
-
IT業で開発をされてる方々に質...
-
著作権法について
-
プログラミングについて
-
自作scratch アニメの商用利用
-
数学、プログラミング、物理、...
-
pip --versionがエラーになる
-
pythonの実行に関する質問
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
FlexGridで文字色を変更。
-
Matlabでsin波を使って矩形波を...
-
SavePictureで保存できない
-
ピッ、ってアルファベットでど...
-
ボールが壁に当たって跳ね返る...
-
Matlab/SimulinkのChirp信号に...
-
C言語のOpenGLで複数のテクスチ...
-
SCALEの使い方教えてください
-
もぐらたたきのプログラミング
-
一次元静電粒子コードについて...
-
VBによる回帰直線のプログラム
-
クリップボードにアクティブウ...
-
画像処理
-
picture boxの画像をimageに上...
-
消す軌跡と残す軌跡
-
マウスポインタの変更
-
EmEditor使い方
-
画像の90度回転表示の処理時間...
-
RadioButtonについて
-
VBA public変数はどのようなこ...
おすすめ情報