欢迎来到天天文库
浏览记录
ID:61460053
大小:437.00 KB
页数:11页
时间:2021-02-01
《广东工业大学实验报告.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、广东工业大学实验报告应用数学学院09信息计算专业(2)班成绩评定_______学号姓名刘艳明教师签名_______实验题目P150E9第9周星期五第1—2节编写:用牛顿、平分、成功—失败法、黄金分割法和进退法求函数f(x)的极小点的计算程序,并求解1.牛顿法:#includeusingnamespacestd;classNewton{doublex;doublef;doublee;public:Newton(doublex1,doublee1){x=x1;e=e1;f=x*x*x*x+-16*x*x*x+30*x*x+-24*x+8;}voidset(
2、doublex1,doublee1){x=x1;e=e1;f=3*x*x*x*x-16*x*x*x+30*x*x-24*x+8;}doublegetfirstf(doublex){return(12*x*x*x-48*x*x+60*x-24);}doublegetsecondf(doublex){return(36*x*x-96*x+60);}};intmain(){doublex0=3;inti=0;Newtona=Newton(x0,0.01);doublef1=a.getfirstf(x0);doublef2=a.getsecondf(x0);doublex1=x0
3、-f1/f2;while((x1-x0)>0.01
4、
5、(x0-x1)>0.01){i++;x0=x1;a.set(x0,0.01);f1=a.getfirstf(x0);f2=a.getsecondf(x0);cout<<"thex0is:"<6、ndl;return0;}2.平分法:#includeusingnamespacestd;doublef2(doublel,doubleo,doublev,doublee);doublea,b,eps,sita;intmaxstep=30;doublex[30];intmain(){cout<<"Pleaseentertheinitial区间左端点a:";cin>>a;cout<>b;cout<>e7、ps;cout<8、b-a9、:";cin>>sita;cout<10、*x[i]+1;if(df1>0)b=x[i];elsea=x[i];while(abs(df1)11、12、abs(b-a)usingnamespacestd;doublefuntion1(doubleb,doubleu,doubleg);doublefuntion2(doublex);doublechong;doubleh;doubleeps;doublemaxstep=30;intmain(){cout<<"Pleaseentert13、heinitialvaluex0:";cin>>chong;cout<0):";cin>>h;cout<0):";cin>>eps;cout<
6、ndl;return0;}2.平分法:#includeusingnamespacestd;doublef2(doublel,doubleo,doublev,doublee);doublea,b,eps,sita;intmaxstep=30;doublex[30];intmain(){cout<<"Pleaseentertheinitial区间左端点a:";cin>>a;cout<>b;cout<>e
7、ps;cout<8、b-a9、:";cin>>sita;cout<10、*x[i]+1;if(df1>0)b=x[i];elsea=x[i];while(abs(df1)11、12、abs(b-a)usingnamespacestd;doublefuntion1(doubleb,doubleu,doubleg);doublefuntion2(doublex);doublechong;doubleh;doubleeps;doublemaxstep=30;intmain(){cout<<"Pleaseentert13、heinitialvaluex0:";cin>>chong;cout<0):";cin>>h;cout<0):";cin>>eps;cout<
8、b-a
9、:";cin>>sita;cout<10、*x[i]+1;if(df1>0)b=x[i];elsea=x[i];while(abs(df1)11、12、abs(b-a)usingnamespacestd;doublefuntion1(doubleb,doubleu,doubleg);doublefuntion2(doublex);doublechong;doubleh;doubleeps;doublemaxstep=30;intmain(){cout<<"Pleaseentert13、heinitialvaluex0:";cin>>chong;cout<0):";cin>>h;cout<0):";cin>>eps;cout<
10、*x[i]+1;if(df1>0)b=x[i];elsea=x[i];while(abs(df1)11、12、abs(b-a)usingnamespacestd;doublefuntion1(doubleb,doubleu,doubleg);doublefuntion2(doublex);doublechong;doubleh;doubleeps;doublemaxstep=30;intmain(){cout<<"Pleaseentert13、heinitialvaluex0:";cin>>chong;cout<0):";cin>>h;cout<0):";cin>>eps;cout<
11、
12、abs(b-a)usingnamespacestd;doublefuntion1(doubleb,doubleu,doubleg);doublefuntion2(doublex);doublechong;doubleh;doubleeps;doublemaxstep=30;intmain(){cout<<"Pleaseentert
13、heinitialvaluex0:";cin>>chong;cout<0):";cin>>h;cout<0):";cin>>eps;cout<
此文档下载收益归作者所有