package Current.popups.Polynomial; import Current.*; import Current.basic.*; import java.applet.Applet; import java.awt.event.*; import java.awt.*; /*This class does some basic manipulations with polynomials with Complex coefficients. I set the maximum degree at 100*/ public class Polynomial { Complex[] z=new Complex[100]; //the coefficients int D; //the degree /**basic constructors*/ public Polynomial() { D=0; for(int i=0;i<100;++i) z[i]=new Complex(0,0); } public Polynomial(Complex[] w,int d) { D=d; for(int i=0;i<100;++i) z[i]=new Complex(0,0); for(int i=0;i<=d;++i) z[i]=new Complex(w[i].x,w[i].y); } public void print() { System.out.println("Polynomial:"); for(int i=0;i<=D;++i) { Integer I=new Integer(i); System.out.print("k^"+I.toString()+" "); z[i].print();} } /**vector space operations*/ public Polynomial scale(Complex w) { Polynomial P=new Polynomial(); P.D=D; for(int i=0;i<=D;++i) { P.z[i]=w.times(this.z[i]); } return(P); } public Polynomial plus(Polynomial P) { int d; d=this.D; if(d.0001) return(1); } return(0); } /**This routine is applied to a sequence (encoded as a polynomial) f(0),f(1),f(2),f(3),... Assuming that these numbers are the output of a polynomial f, this routine takes successive differences and tried to find the degree. If the degree is higher than the number of terms, meaning that taking successive differences does not reveal a pattern, then -1 is returned*/ public int effectiveDegree() { int test=0; Polynomial P=new Polynomial(this.z,this.D); for(int i=0;i0;--i) { B1=A1.termFromGrowth(i); B2=B1.createValues(this.D); A1=A1.minus(B2); A2=A2.plus(B1); } return(A2); } }