Go to the first, previous, next, last section, table of contents.


qt_rewrite

qt_rewrite(Expr,Rules,Mode)
:: Expr を規則集合 Rules を用いて書き換える.
return
quote型
Expr
quote型
Rules
リスト
Mode
整数

注意: 数学的には X*Y=Y*X が可換性を与える規則だが, これをそのまま規則として 与えると書き換えが停止しない. 次の例では, 上の例のように順序比較し, たとえば, 順序が大きくなる場合のみに書き換えるべきである.

import("noro_rewrite.rr");
R=[[`X*Y,`nqt_comp(Y*X,X*Y)>0, `Y*X]];
qt_rewrite(`(x-y)^2,R,2);
     出力: quote(x*x+-2*x*y+y*y)

外積代数の計算 (asir-contrib をロードした状態).

import("noro_rewrite.rr");
Rext0=[quote(X*Y),quote(qt_is_var(X) && qt_is_var(Y) && nqt_comp(Y,X)>0),
                  quote(-Y*X)];
Rext1=[quote(X^N),quote(eval_quote(N)>=2),quote(0)];
Rext2=[quote(X*X),quote(0)];
Rext=[Rext0,Rext1,Rext2];
qt_rewrite(quote( (x+2*y)*(x+4*y) ), Rext,1);
     出力: 2*x*y

qt_set_coef([a,b,c,d]);
qt_rewrite(quote((a*x+b*y)*(c*x+d*y)), Rext,1);
     出力: (d*a-c*b)*x*y

微分の計算 (asir-contrib をロードした状態).

import("noro_rewrite.rr");
qt_set_coef([a,b]);
Rd1=[`d(X+Y), `d(X)+d(Y)];
Rd2=[`d(X*Y),`d(X)*Y+X*d(Y)];
Rd3=[`d(N), `qt_is_coef(N), `0];
Rd4=[`d(x),`1];
Rd=[Rd1,Rd2,Rd3,Rd4];
B=qt_rewrite( `d( (a*x+b)^3),Rd,2);
     出力: quote(3*a^3*x*x+6*b*a^2*x+3*b^2*a)
fctr(eval_quote(B));
     出力: [[3,1],[a,1],[a*x+b,2]]
参照
section nqt_match, section nqt_match_rewrite, section qt_normalize

ChangeLog


Go to the first, previous, next, last section, table of contents.