アプリ版:「スタンプのみでお礼する」機能のリリースについて

こんにちは。いまMaximaを使っているのですが、式が長すぎて表示できないというようなエラーがでてしまいます。このような場合どうすればいいのですか?行列のある成分だけをとりだして、ある文字についてとくというようなことをしたいのですが。どなたかお願いします。

A 回答 (4件)

具体的な入力例が欲しいトコですね。



大体のトコ、入力式に

ratsimp
factor

辺りのコマンドを噛ませば、式が整理されて出てくる筈なんですが。

この回答への補足

S1:matrix([%e^b*x1,%e^(-b*x1)],[b*%e^(b*x1),-b*%e^(-b*x1)]);に、
{k:2*%pi/l; b:sqrt(B^2-k^2*1.5^2);として}これの、逆行列などを掛けたりして計算していたんですけど。式を整理する方法があるんですね。まだ、このソフトを使いはじめたばかりなので…

補足日時:2008/03/07 21:36
    • good
    • 0

数式見る限り、微分絡みかしら?



まあ、それはさておき、こちらで試した限り、問題は特に生じなかったですね。
以下のような計算を試したんじゃないかな、とか思ってますが。
(ひょっとしたら、教えて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の値を求めるということをしたいのです
が。教えてもらっている立場なのに本当申し訳ないです。

出力番号を入力するとその結果を使えるんですね!勉強になりま
す。

補足日時:2008/03/08 17:20
    • good
    • 0

>(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に付いて微分せよ」と指定して入力を減らすテもあります。
    • good
    • 0
この回答へのお礼

>一つ気になったんですが、各行列の第二行はすべて第一行の微分でしょ?

まさにそうです。タイプミスが多いもので。

丁寧に回答していただき大変助かりました。もう少し落ち着いてやらなくてはいけませんね。
しっかりと勉強してこのソフトを使いこなせるようになりたいと思います。ありがとうございました!

お礼日時:2008/03/08 20:53

おっと、Typoです。



>y:e^(b*x)とでも定義しておいて、

y:%e^(b*x)

ですね。失礼致しました。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!