下载此文档

多项式数据拟合.doc


文档分类:IT计算机 | 页数:约26页 举报非法文档有奖
1/26
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/26 下载此文档
文档列表 文档介绍
该【多项式数据拟合 】是由【小果冻】上传分享,文档一共【26】页,该文档可以免费在线阅读,需要了解更多关于【多项式数据拟合 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities26
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities25
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
云南大学软件学院
专业实训〔1〕-实训作业报告
CreativeProgrammingReport
SchoolofSoftware,YunnanUniversity
个人成绩
序号
学号
姓名
成绩
1
20231120235
陈苗
2
20231120237
袁秀梅
3
20231120279
侯丽影
4
20231120230
张又
5
20231120238
李加才
学 期:2023学年春季学期
课程名称: 专业实训〔1〕
任课教师: 李劲
工程名称: 多项式数据拟合
小组长: 陈苗
联系电话: **********
电子邮件: ******@
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities2
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities25
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
成员分工明细表:
学号
姓名
分工
20231120235
陈苗
负责实验报告的简要设计、中英文摘要、问题描述;代码中取空格符函数、多项式类的设计
20231120279
侯丽影
实验报告中详细设计;代码中文件读取函数、x的m次幂计算函数、x的m次幂与y的计算、函数多项式类的设计
20231120237
袁秀梅
PPT制作和演讲、代码中矩阵求解函数、代码中画图函数设计
20231120230
张又
试验报告中代码局部;代码中画点函数、多项式类的设计
20231120238
李加才
实验报告中测试局部;主程序的测试
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities4
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities3
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
报告正文局部
中文摘要
本工程的主要目的是建立一个多项式的类,通过调用类完成多项式数据拟合。在多项式类中包含多项式的生成、加法、减法、乘法、除法、求导、输出还有赋值函数,以便用户需求。在主函数中完成数据拟合的问题,就是求出满足给定点集的最优多项式,根据老师提供的矩阵求解公式,无需调用求导函数,要涉及到储存点集文件的读取和绘点、通过读取的点的X和Y的数组,来生成一个系数矩阵和一个结果矩阵,来求出参数矩阵,将求出的参数矩阵生成为一个多项式,最
后通过赋值y,绘出多项式的曲线,完成数据拟合。结果完成了点的读取和绘制,还有参数矩阵求解。
英文摘要
Mainpurposeofthisprojectistoestablishaclassofpolynomials,by

thepolynomialclassformation,addition,subtraction,multiplication,Division,differentiation,outputaswellasassignment,,isseekingoutmeettofixed-pointsetofoptimalmoreitemtype,underteacherprovidesofmatrixsolutionformula,withoutcalledderivationfunction,toinvolvesstoragepointssetfileofreadandpaintedpoints,andbyreadofpointsofxandyofarray,togeneratedacoefficientmatrixandaresultsmatrix,toseekingoutparametermatrix,willseekingoutofparametermatrixhealthbecameamoreitemtype,lastbyassignedvaluey,paintedoutmoreitemtypeofcurve,,thereareparametersmatrix.
问题描述
工程背景:是求解多项式的一种方法。在实际应用中,由一组样本点集,求得自变量和因变量之间的近似函数关系。对于解决复杂的数学问题有很大的应用价值。
工程内容:本工程运用JAVA编程语言,编写程序,来完成多项式数据拟合问题。编程内容包括多项式类的编写和数据拟合主程序的编写。多项式类是为主函数做根底,用于主函数的调用。在主函数中要完成点集文件内容的读取来绘制样本点集,再通过最优多项式求解方法,从而得到最优多项式。然而,在本工程设计中,不需要对设定的每一个参数求偏导,只要运用老师提供的矩阵乘法公式求解,因此要完成矩阵的生成、矩阵的赋值还有矩阵求解得到参数矩阵,从而得到最优多项式,完成多项式的图形绘制。
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities4
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities25
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
概要设计
设计包括两个方面:
多项式类的建立。本工程要用到的函数包括以下子函数:
();程序中定义了两个生成函数,两个函数不同的是,一个传递的参数double型的数组,另一个传递的参数是int型的数组长度,如下:
①publicPolynomial(double[]cs){……};
②publicPolynomial(intcslen){……};
这样以便不同参数生成多项式。在这两个生成多项式函数中都要用到计算度函数polynDeg()〔度就是多项式中自变量X的最高次幂,从0开始〕,定义和运用度函数,是为了完成多项式的输出函数toString〔〕;在第二个以长度为参数的多项式生成函数中要用到数组长度计算函数polynLen()〔数组长度就是度加1〕。
(doubleX)();这个函数是给定X值来求Y值。
多项式数据拟合。
要完成多项式数据拟合,需要包括以下步骤:
读入文件。本局部主要目的是将老师提供的文本文档读入,采用逐行读取的方式,每读入一行就对这行进行操作split,不同的分割方式分割出我们想要的字符串局部,然后插入队列里,之后采用一个将字符串转化成为double型数值的函数,将队列中的字符串分别转换成为数值,最后得到存储x值的数值和存储y值的数组。
在坐标系中画出读入的数据:就是建立坐标系,将每个点以小圆圈的形式画出。
计算参数局部思想:要先设置系数个数M,然后生成含有未知系数的多项式,把点x带入多项式中求得t,t与y做差的平方迭代求和chahe,差和对各未知系数求偏导得到多个式子,让式子等于0,继而得到系数矩阵和常数矩阵,通过矩阵运算求得参数矩阵,最后得到多项式,然后通过算出的多项式,给出不同的x,得到不同的y值,绘制出多项式曲线。
详细设计
多项式类的设计
多项式生成〔传递数组和数组长度两种生成方法〕;
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities26
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities5
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
publicPolynomial(double[]cs){
inti;
if(>0)
coefs=newdouble[];
for(i=0;i<;i++)
coefs[i]=cs[i];
degree=polynDeg();
}//传递数组
publicPolynomial(intcslen){
inti;
coefslen=cslen;
if(coefslen>=0)
coefs=newdouble[coefslen];
for(i=0;i<coefslen;i++)
coefs[i]=0;
degree=polynDeg();
}//传递数组长度
多项式的各种操作,包括加法,减法,乘法,求导,x值求y值,求多项式的度,多项式的长度。
度的计算:
privateintpolynDeg(){
for(inti=-1;i>=0;i--)
{
if([i]==0)
continue;
=i;break;
}
;
对于度的计算,采用倒序判断,从最后一项开始判断,如果它的系数不为0,那么它的指数就是度,反之,系数数组减1,向前移位判断;而多项式的长度就等于它的度加1。
加法:
publicPolynomialplus(Polynomialrhs){
intmaxlen=0,minlen=0,i;
maxlen=((),());
minlen=((),());
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities6
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities25
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
Polynomialresult=newPolynomial(maxlen);
for(i=0;i<minlen;i++)
[i]=[i]+[i];
if(()<())
for(i=minlen;i<maxlen;i++)
[i]=[i];
else
for(i=minlen;i<maxlen;i++)
[i]=[i];
=();
returnresult;
}
乘法局部:
publicPolynomialtimes(Polynomialrhs){
inti,j;
Polynomial
c=newPolynomial(()+()+1);
for(i=0;i<=();i++)
for(j=0;j<=();j++)
[i+j]+=[i]*[j];
=();
returnc;
}
字符串返回输出。
publicStringtoString(){
inti;
if(==0)
return""+coefs[0];
s=""+coefs[0];
for(i=1;i<=;i++){
if([i]==0)continue;
elseif([i]>0)s+="+"+coefs[i];
elses+="-"+(-[i]);
if(i==1)s+="X";
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities26
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities7
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
elses+="X^"+i;
}
returns;
}
〔二〕,多项式数据拟合的设计
1,文件的读入:本局部采用逐行读取的方式,每读入一行就对这行进行操作split,不同的分割方式分割出我们想要的字符串局部,然后插入队列里,之后采用一个将字符串转化成为double型数值的函数,将队列中的字符串分别转换成为数值,存入数组中,此时数组中存有所有读取的x,y的值,并且是奇数项为x值,偶数项为y值的顺序,最后将这个数组通过奇偶分开成两个数组,分别为x数组和y数组。
publicdouble[]read(StringfileName)读取函数
//本局部并不是完整代码,而是代码中重要的局部
{
FileReadera=null;
BufferedReaderin=newBufferedReader(a);
Strings="";
Strings1[],s2[],s3[],s4[];
Queuex1=newQueue();
while((s=())!=null)
{
s1=(",");
s2=s1[0].split("=");
((s2[1]));
s3=s1[1].split("\\)");//括号属于函数计算操作不写“〕〞
s4=s3[0].split("=");
((s4[1]));
();//读入\n
();//读入\r
}
();//关闭文件流
();//关掉文件,以免浪费内存
doublezhi[]=newdouble[()];
inti=0;
Stringc="";
while(()!=true)//队列不空
{
c=(String)();
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities8
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities25
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
zhi[i]=(c);
i++;
}
returnzhi;
}
从初数组中分出x,y数组的函数
publicvoidsetXY(doublea[])
{
inti=0,j=0;
=newdouble[];
=newdouble[];
for(i=0;i<;)
{
x[j]=a[i];
i++;
y[j]=a[i];
i++;
j++;//把值中的数值分给x,y数组
}
因为测试过程数值中间总间杂空格,所以建立一个去空格函数
@@注意有两种空格格式,都要写进去!
publicstaticStringtrim(Stringa)
{
inti=0;
Stringb="";
for(i=0;i<();i++)
{
if((i)!=''&&(i)!='‘
b+=(i);
}
returnb;
}
2,在坐标系中画出读入的数据:就是将每个点以小圆圈的形式画出,这局部只要对xy的范围进行熟悉,画出适宜大小的坐标系,然后画图就好。
(-1,8,);
CreativeProgrmmingReport
创新设计报告
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities26
SchoolofSoftware,YunnanUniversity.(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities9
云南大学软件学院(2023)
ofruraldrinkingwatersources,protectionofdrinkingwatersourcesinruralareasbytheendofthedelimitationofthescopeofprotection,completewithwarningsigns,isolatingnetworkprotectionfacilities
(-4,5,);
();
publicvoiddrawPoints(Colorcolor)画图
计算局部思想:设置系数个数M
|
生成含有未知参数的多项式
|

把点x带入多项式中求得t,t与y做差的平方迭代求和chahe
|
差和对各未知参数求偏导得到多个式子,让式子等于0,继而得到系数矩阵和常熟矩阵,通过矩阵运算求得各系数的具体值
对应函数:publicPolynomialqiujie()
比拟关键的局部
MatrixMA=newMatrix(xishu);
(1,2);
MatrixMb=newMatrix(changshu);
(1,2);
Matrixx1=(Mb);
(1,2)

多项式数据拟合 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数26
  • 收藏数0 收藏
  • 顶次数0
  • 上传人小果冻
  • 文件大小312 KB
  • 时间2022-12-07
最近更新