Java 多项式求值
来源:互联网 发布:多目标 优化 编辑:程序博客网 时间:2024/05/28 11:50
多项式求值:
package ceshi;import java.awt.Polygon;import java.text.DecimalFormat;public class duoxiangshiqiuzhi {//一维多项式求值 n为多项试系数 数组a为存放多项式系数的n个系数 x为指定变量值 public static double yiwei(double a[],int n,double x){int i;double f,result;f=-1.0;result=a[n-1];for(i=n-2;i>0;i--){result += a[n-2]*x;f=result;}return f;}public static void main(String[] args) {int i;//系数从小到大double a[]={-15.0,-7.0,7.0,2.0,-3.0,7.0,3.0};double[] x={-2.0,-0.58,1.0,2.0,3.7,4.0};double result;DecimalFormat df=new DecimalFormat("0.0000000E000");DecimalFormat df1=new DecimalFormat("0.00");for(i=0;i<6;i++){result =yiwei(a,7,x[i]);System.out.println("x="+df1.format(x[i])+"时,p(x)"+df.format(result));}}//二维多项式求值public static double erwei(double a[][],int m,int n,double x,double y){double result,tt,temp;int i,j;tt=1.0;result = 0.0;for(i=0;i<n;i++){temp= a[i][n-1]*tt;for(j=n-2;j>0;j--){temp = temp*y+a[i][j]*tt;}result+=temp;tt*=x;}return result;}}
阅读全文
1 0
- Java 多项式求值
- java 一维多项式求值
- 多项式求值
- 多项式求值
- 多项式求值
- 多项式求值
- 多项式求值
- 多项式求值
- 多项式求值
- 多项式求值
- 用拉格朗日插值多项式求值
- 多项式求和和求值
- 一维多项式求值
- 4-2 多项式求值
- 4-2 多项式求值
- 4-2 多项式求值
- 4-2 多项式求值
- 4-2 多项式求值
- 自定义WinForm控件无法拖动到窗口
- 服务器常用的状态码及其对应的含义
- Linux-Ubuntu入门笔记
- redis总结1-Redis简介、安装、集群
- 为自定View添加相应属性,在XML可以直接使用
- Java 多项式求值
- python os.stat() 和 stat模块详解
- node.js学习笔记2——querystring (查询字符串,参数处理)
- Git高频命令(长期更新)
- C语言指针学习笔记
- 数据结构编程笔记十七:第六章 树和二叉树 赫夫曼树的实现
- 史上最科学!Swift 3 UITableView最佳实践 XIB极速实现UITableViewCell,UITableViewHeaderFooterView
- requests库入门-5-带参数的请求类型
- 微服务的设计原则