二维多项式包含X,Y两个变量的多项式,其一般形式为:
P(x,y)=ΣΣaijxiyj
等价于:p(x,y)=Σ(Σ(aijxi)yj)
令ti=Σ(aijxi)yj
Rn-1=a

i,n-1

x

i

;R

j

=R

j+1

y+a

ij

x

j

,j=n-2,...1,0。

 


代码段:
public class Hanshujiaohuan {
	public static double sun(double a[][],int m,int n,double x,double y) {
		double result=0.0;
		double temp,t=1.0;
		int i,j;
		for(i=0;i<m;i++) {
			temp=a[i][n-1]*t;
			for(j=n-2;j>=0;j--) {
				temp=temp*y+a[i][j]*t;
			}
			result+=temp;
			t*=x;
		}
		return result;
	}
	public static void main(String []args) {
		int i;
		double result;
		double x=0.5;
		double y=-2.0;
		DecimalFormat df=new DecimalFormat("0.000E000");
		double a[][]= {{1.0,2.0,3.0,4.0,5.0},{6.0,7.0,8.0,9.0,10.0},{11.0,12.0,13.0,14.0,15.0},{16.0,17.0,18.0,19.0,20.0}};
		System.out.println("二维多项式求值: \n");
		result=sun(a,4,5,x,y);
		System.out.print("p("+x+","+y+")="+df.format(result)+"\n");
		System.out.print("\n");
	}
}