var i,p,q,r,s,UCLN,BCNN: integer; m,a,b,c,d,e,f,g,h,j,k,x,y,z,t,o: real; begin write('a='); readln(a); write('b='); readln(b); write('c='); readln(c); write('d='); readln(d); write('e='); readln(e); if a=1 then write('x^4') else begin if a>0 then write(a:0:0,'x^4'); if a=-1 then write('-x^4'); if a<0 then if a<>-1 then write('-',-a:0:0,'x^4'); end; if b=1 then write('+x^3') else begin if b>0 then write('+',b:0:0,'x^3'); if b=-1 then write('-x^3'); if b<0 then if b<>-1 then write('-',-b:0:0,'x^3'); end; if c=1 then write('+x^2') else begin if c>0 then write('+',c:0:0,'x^2'); if c=-1 then write('-x^2'); if c<0 then if b<>-1 then write('-',-c:0:0,'x^2'); end; if d=1 then write('+x') else begin if d>0 then write('+',d:0:0,'x'); if d=-1 then write('-x'); if d<0 then if b<>-1 then write('-',-d:0:0,'x'); end; if e>0 then write('+',e:0:0); if e<0 then write('-',-e:0:0); write('=0'); x:= 8*a*a*a ; y:=-4*a*a*c; z:=-8*e*a*a+2*a*d*b; t:=4*e*c*a-a*d*d-e*b*b; m:=0; begin for i:=1 to 100 do m:=m-(x*m*m*m+y*m*m+z*m+t)/(3*x*m*m+2*y*m+z); end; g:=2*sqrt(-4*c*a+8*a*a*m+b*b)*a; h:=sqrt(-4*c*a+8*a*a*m+b*b)*b-8*a*a*m-b*b+4*c*a; j:=2*sqrt(-4*c*a+8*a*a*m+b*b)*m*a+2*a*d-2*b*m*a; p:=trunc(g); q:=trunc(h); r:=trunc(j); begin BCNN:=p*q; s:= q mod p; While s <> 0 do Begin s:= p MOD q; p:= q; q:= s; End; BCNN:=p*r; s:= r mod p; While s <> 0 do Begin s:= p MOD r; p:= r; r:= s; End; end; g:=g/p; h:=h/p; j:=j/p; writeln(' '); write('('); if g=1 then write('x^2') else begin if g>0 then write(g:0:0,'x^2'); if g=-1 then write('-x^2'); if g<0 then if g<>-1 then write('-',-g:0:0,'x^2'); end; if h=1 then write('+x') else begin if h>0 then write('+',h:0:0,'x'); if h=-1 then write('-x'); if h<0 then if h<>-1 then write('-',-h:0:0,'x'); end; if j>0 then write('+',j:0:0); if j<0 then write('-',-j:0:0); write(')'); g:=2*sqrt(-4*c*a+8*a*a*m+b*b)*a; k:=sqrt(-4*c*a+8*a*a*m+b*b)*b+8*a*a*m+b*b-4*c*a; o:=2*sqrt(-4*c*a+8*a*a*m+b*b)*m*a-2*a*d+2*b*m*a; p:=trunc(g); q:=trunc(k); r:=trunc(o); begin BCNN:=p*q; s:= q mod p; While s <> 0 do Begin s:= p MOD q; p:= q; q:= s; End; BCNN:=p*r; s:= r mod p; While s <> 0 do Begin s:= p MOD r; p:= r; r:= s; End; end; g:=g/p; k:=k/p; o:=o/p; write('('); if g=1 then write('x^2') else begin if g>0 then write(g:0:0,'x^2'); if g=-1 then write('-x^2'); if g<0 then if g<>-1 then write('-',-g:0:0,'x^2'); end; if k=1 then write('+x') else begin if k>0 then write('+',k:0:0,'x'); if k=-1 then write('-x'); if k<0 then if k<>-1 then write('-',-k:0:0,'x'); end; if o>0 then write('+',o:0:0); if o<0 then write('-',-o:0:0); write(')=0'); readln; end.Đây là đoạn code pascal do mình tự viết dùng để phân tích phương trình bậc 4 thành 2 tam thức bậc 2.
Ý tưởng của đoạn code trên:
B1: Nhập PT bậc 4: $f(x)=a x^4+bx^3+cx^2+dx+e$
B2: tìm nghiệm của phương trình ẩn $m$: $8a^3m^3-4a^2cm^2-(8ea^2-2abd)m+4eca-ad^2-eb^2=0$
bằng công thức truy hồi:
x:= 8*a*a*a ; y:=-4*a*a*c; z:=-8*e*a*a+2*a*d*b; t:=4*e*c*a-a*d*d-e*b*b; m:=0; begin for i:=1 to 100 do m:=m-(x*m*m*m+y*m*m+z*m+t)/(3*x*m*m+2*y*m+z); end;B3: Gán giá trị:
g:=2*sqrt(-4*c*a+8*a*a*m+b*b)*a; h:=sqrt(-4*c*a+8*a*a*m+b*b)*b-8*a*a*m-b*b+4*c*a; j:=2*sqrt(-4*c*a+8*a*a*m+b*b)*m*a+2*a*d-2*b*m*a; k:=sqrt(-4*c*a+8*a*a*m+b*b)*b+8*a*a*m+b*b-4*c*a; o:=2*sqrt(-4*c*a+8*a*a*m+b*b)*m*a-2*a*d+2*b*m*a;Khi đó $f(x) \Leftrightarrow (gx^2+hx+j)(gx^2+kx+o)=0$
B4: Rút gọn dưới dạng tối giản !!!
_____
P/s: Đây là bản thử nghiệm nên không thể chính xác tuyệt đối được !
VD: Không giải được phương trình $x^4-1=0$ do Pascal không hiểu $\sqrt{0}$
Bài viết đã được chỉnh sửa nội dung bởi nthoangcute: 11-10-2012 - 20:46