这是一个多项式的乘法问题。
A(X)=amx^m+am-1x^m-1+.....a1x+a0
B(x)=bnx^n+bn-1x^n-1+.....b1x+b0
这两个多项式的项目分别为m+1和n+1,最高次分别为m和n,
现在需要求解A*B的值。
/**
* @author LilyLee
* @date 2017年4月23日
* @time 下午10:05:24
* @Version 1.0
* @email lilylee_1213@foxmail.com
*
*/
public class polynomial_mul {
static void Polynomial_mul(double A[],int m,double B[],int n,double R[]){
int k=m+n;//K是乘积的最高项系数
for(int x=0;x<k;x++){R[x]=0;}//初始化
for(int i=0;i<=m;i++){
for(int j=0;j<=n;j++){
R[i+j]+=(A[i]*B[j]);
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
double A[]={-4,5,2,-1,3,2};
double B[]={-3,-2,1,3};
double R[]=new double[9];
int m=5;
int n=3;
in