用java中的数组求多项式的导数
我是一名编程新手,在尝试使用数组编程多项式的导数时遇到困难。下面是我必须获得用户输入的内容用java中的数组求多项式的导数,java,arrays,derivative,Java,Arrays,Derivative,我是一名编程新手,在尝试使用数组编程多项式的导数时遇到困难。下面是我必须获得用户输入的内容 Scanner sc=new Scanner(System.in); System.out.print("Enter the degree: "); int degree = sc.nextInt(); System.out.print("Enter "+(degree+1)+" coefficients: "); double[] C = new double[degree+1]; for(int i=
Scanner sc=new Scanner(System.in);
System.out.print("Enter the degree: ");
int degree = sc.nextInt();
System.out.print("Enter "+(degree+1)+" coefficients: ");
double[] C = new double[degree+1];
for(int i=0; i<C.length;i++) {
C[i]=sc.nextDouble();
}
Scanner sc=新扫描仪(System.in);
系统输出打印(“输入学位:”);
int degree=sc.nextInt();
系统输出打印(“输入”+(度+1)+“系数:”);
double[]C=新的double[度+1];
对于(int i=0;i让我们假设数组C
包含按次数降序排列的n次多项式的系数(例如,对于f(x)=C[0]*x^n+…+C[n-1]*x+C[n]
)
然后D
是您的衍生产品数组:
double D[] = new double[C.length-1];
for(int i = 0; i < C.length-1; i++)
D[i] = C[i]*(C.length-i-1);
double D[]=新的double[C.length-1];
对于(int i=0;i
假设多项式是这样的
f(x)=C[0]*x^n+C[1]*x^(n-1)…C[n]
经过推导,它变成
f'(x)=C[0]*(n)x^(n-1)+C[1](n-1)*x^(n-2)+0*C[n]
Scanner sc=新扫描仪(System.in);
系统输出打印(“输入学位:”);
int degree=sc.nextInt();
系统输出打印(“输入”+(度+1)+“系数:”);
double[]C=新的double[度+1];
对于(int i=0;我能在纸上手工做这个吗?我的意思是,你在数学或编程方面有困难吗?所以现在在你读到的双数组上循环,计算导数多项式的系数。这不是答案(因为问题不清楚),但你可能会有兴趣阅读关于你可以在适当的地方做这件事的文章
Scanner sc=new Scanner(System.in);
System.out.print("Enter the degree: ");
int degree = sc.nextInt();
System.out.print("Enter "+(degree+1)+" coefficients: ");
double[] C = new double[degree+1];
for(int i=0; i<C.length;i++) {
C[i]=sc.nextDouble();
}
double derivative[] = new double[C.length-1];
for(int i=0;i<derivative.length;i++){
derivative[i] = C[i]*(C.length - 1 -i );
}