出力の簡約
QEPCAD B,従って,qepmax では
(%i1) qe([],x^2=1); (%o1) (x - 1 <= 0) %and (x + 1 >= 0) %and ((x - 1 = 0) %or (x + 1 = 0)) (%i2) qe([[X2,x]],x^2+a*x+1=0); (%o2) (a - 2 # 0) %and (a + 2 # 0) %and ((a - 2 > 0) %or (a + 2 < 0))
のように簡約が充分でない(と人間には見える)出力になる場合があります.
こうした出力に対して,等価性を保ち,出来るだけ多くの式を取り除く関数 nns を作りました.
(%i3) nns(f):= block([cl,L,fk],cl(f,g):=length(f)<=length(g), L:sort(rest(full_listify(powerset(setify(args(f))))),cl), if op(f)="%and" then for k:1 thru length(L) do (fk:substpart("%and",part(L,k),0), if qe([],(fk)%eq(f))=true then return(fk)) elseif op(f)="%or" then for k:1 thru length(L) do (fk:substpart("%or",part(L,k),0), if qe([],(fk)%eq(f))=true then return(fk)) else f)$ (%i4) nns(%o1); (%o4) (x - 1 = 0) %or (x + 1 = 0) (%i5) nns(%o2); (%o5) (a - 2 > 0) %or (a + 2 < 0) (%i6) qe([[X3,x]],(x^2+a*x+1)*(x-2)=0); (%o6) (a - 2 # 0) %and (a + 2 # 0) %and (2 a + 5 # 0) %and ((a - 2 > 0) %or (a + 2 < 0)) (%i7) nns(%); (%o7) (2 a + 5 # 0) %and ((a - 2 > 0) %or (a + 2 < 0)) (%i8) qe([[X1,x]],1/x=a*x+b); 2 (%o8) (a <= 0) %and ((a = 0) %or (b + 4 a = 0)) %and (b # 0) 2 %and (b + 4 a >= 0) (%i9) nns(%); 2 (%o9) ((a = 0) %or (b + 4 a = 0)) %and (b # 0)