読者です 読者をやめる 読者になる 読者になる

solvex 例

ソース http://d.hatena.ne.jp/ehito/20170106/1483705734 を見て戴くと判りますが,solvex には様々なスイッチがあり,説明が必要なのですが,それはまた後日とし(苦),ここではまずどんなものが解けるのか?をご紹介します.

係数にパラメータを含む不等式.

(%i1) solvex(x^2-2*x>a,x);
Evaluation took 10.7700 seconds (19.8400 elapsed) using 595.634 MB.
(%o1) [[x < 1-sqrt(a+1)],[sqrt(a+1)+1 < x],[a < -1]]

係数に冪乗根を含む不等式.

(%i2) solvex(x^2<=sqrt(3),x);
Evaluation took 11.4000 seconds (19.3700 elapsed) using 809.069 MB.
(%o2) [[-3^(1/4) <= x,x <= 3^(1/4)]]

次の例では計算時間短縮のため,幾つかの簡約を off にしています.

(%i3) solvex(x^2-sqrt(8)*x-1<0,x),presimp:off,ncondtype:off,postsimp:off;
Evaluation took 6.2600 seconds (9.4200 elapsed) using 333.642 MB.
(%o3) [[sqrt(2)-sqrt(3) < x,x < sqrt(3)+sqrt(2)]]

連立不等式.

(%i4) solvex([[x^2>a,x>1]],x);
Evaluation took 16.9000 seconds (32.2600 elapsed) using 989.834 MB.
(%o4) [[sqrt(a) < x,1 < x],[1 < x,a < 0]]

主係数にパラメータを含む方程式.

(%i5) solvex(a*x=b,x);
Evaluation took 6.8400 seconds (25.5400 elapsed) using 424.958 MB.
(%o5) [[a = 0,b = 0],[b = 0,x = b/a],[b # 0,x = b/a]]

簡約が不充分なので...

(%i6) nnscandc(ora(%));
Evaluation took 2.9800 seconds (5.6700 elapsed) using 252.291 MB.
(%o6) ((a = 0) %and (b = 0)) %or (x = b/a)

連立方程式

(%i7) solvex([[a*x+b*y=c,x+y=1]],x,y);
Evaluation took 32.3900 seconds (69.1900 elapsed) using 2624.115 MB.
(%o7) [[b-a = 0,c-a = 0,y = 1-x],[x = b/(b-a)-c/(b-a),y = c/(b-a)-a/(b-a)]]

こちらの方が見易い?

(%i8) factor(%);
Evaluation took 0.0000 seconds (0.0000 elapsed) using 101.938 KB.
(%o8) [[b-a = 0,c-a = 0,y = -(x-1)],[x = -(c-b)/(b-a),y = (c-a)/(b-a)]]

絶対値を含む方程式.

(%i9) solvex(abs(x-a)+abs(x-b)=c,x);
Evaluation took 111.1600 seconds (149.5500 elapsed) using 12527.014 MB.
(%o9) [[0 <= c-b+a,0 <= c+b-a,x = (-c/2)+b/2+a/2],
       [0 <= c-b+a,0 <= c+b-a,x = c/2+b/2+a/2],
       [(-c/2)+b/2+a/2 <= x,c-b+a = 0,x <= c/2+b/2+a/2],
       [(-c/2)+b/2+a/2 <= x,c+b-a = 0,x <= c/2+b/2+a/2]]

このような式には logical factor 関数(開発中)が有効です.

(%i10) lfactor(%);
Evaluation took 0.0200 seconds (0.0300 elapsed) using 3.229 MB.
(%o10) [[(c-b+a = 0) %or (c+b-a = 0),(-c/2)+b/2+a/2 <= x,x <= c/2+b/2+a/2],
        [(x = (-c/2)+b/2+a/2) %or (x = c/2+b/2+a/2),0 <= c-b+a,0 <= c+b-a]]

こちらの方が見易い?

(%i11) factor(%);
Evaluation took 0.0100 seconds (0.0100 elapsed) using 2.139 MB.
(%o11) [[(c-b+a = 0) %or (c+b-a = 0),-(c-b-a)/2 <= x,x <= (c+b+a)/2],
        [(x = -(c-b-a)/2) %or (x = (c+b+a)/2),0 <= c-b+a,0 <= c+b-a]]

主係数にパラメータを含む不等式.

(%i12) solvex(a*x>b,x);
Evaluation took 6.3000 seconds (14.1600 elapsed) using 505.691 MB.
(%o12) [[0 < a,b/a < x],[x < b/a,a < 0],[a = 0,b < 0]]

無理関数で表された不等式.

(%i13) solvex(sqrt(x)>x-1,x);
Evaluation took 14.7900 seconds (26.1800 elapsed) using 659.776 MB.
(%o13) [[0 <= x,x < 1],[3/2-sqrt(5)/2 < x,x < sqrt(5)/2+3/2]]

簡約が不充分なので...

(%i14) nnscandc(ora(%));
Evaluation took 10.7700 seconds (16.4800 elapsed) using 428.886 MB.
(%o14) (0 <= x) %and (x < sqrt(5)/2+3/2)

高次不等式.

(%i15) solvex(x*(x^2-2)*(x^2-3)<0,x);
Evaluation took 45.8000 seconds (86.6800 elapsed) using 1963.461 MB.
(%o15) [[-sqrt(2) < x,x < 0],[sqrt(2) < x,x < sqrt(3)],[x < -sqrt(3)]]

eqx の出力を入力にすると...

(%i16) qex(x=sqrt(2)-sqrt(3));
Evaluation took 0.6100 seconds (1.0100 elapsed) using 27.529 MB.
(%o16) (x < 0) %and (x^2-3 < 0) %and (x^4-10*x^2+1 = 0)
(%i17) solvex(%,x);
Evaluation took 6.8200 seconds (15.1000 elapsed) using 284.881 MB.
(%o17) [[x = sqrt(2)-sqrt(3)]]

方程式と不等式との系.

(%i18) solvex([[x+y=1,y>2*x,x^2+y^2=2]],y,x);
Evaluation took 13.3600 seconds (24.1100 elapsed) using 652.512 MB.
(%o18) [[x = 1/2-sqrt(3)/2,y = sqrt(3)/2+1/2]]

係数にパラメータを含む...

(%i19) solvex([[x+y>1,y>2*x,x^2+y^2=a]],y,x);
Evaluation took 40.5400 seconds (67.2100 elapsed) using 2450.850 MB.
(%o19) [[1/2-sqrt(2*a-1)/2 < x,x < sqrt(a/5),y = sqrt(a-x^2)]]

これまでの qe では

(%i20) qe([[E,x],[E,y]],(x^2+y^2<3*y) %and (y>1) %and (x+y=a));
Evaluation took 0.4100 seconds (0.6200 elapsed) using 29.980 MB.
(%o20) (4*a^2-12*a-9 < 0) %and ((a > 0) %or (a^2-2*a-1 < 0))

ここまででしたが,solvex なら

(%i21) solvex(%);
Evaluation took 24.3600 seconds (41.4200 elapsed) using 1047.936 MB.
(%o21) [[0 < a,a < 3/sqrt(2)+3/2],[1-sqrt(2) < a,a < sqrt(2)+1]]

と解けます.でもまだ簡約が不充分なので

(%i22) nnscandc(ora(%));
Evaluation took 13.0000 seconds (20.4000 elapsed) using 545.835 MB.
(%o22) (1-sqrt(2) < a) %and (a < 3/sqrt(2)+3/2)

合成して実行.

(%i23) solvex(qex([[X1,x]],sqrt(x)+a=abs(x-b)),a);
Evaluation took 25.9000 seconds (43.3900 elapsed) using 1935.237 MB.
(%o23) [[-b < a,b < a],[1/4 < b,a = -sqrt(b)],[a = (-b)-1/4,b <= 1/4]]