




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
反反复复二分法:#include#includemath.h#define E 0.01void main() float a,b,x,erfen(float a,float b); printf(Enter a,bn); scanf(%f,%f,&a,&b); x=erfen(a,b); printf(x=%fn,x); float erfen(float a,float b) float c,df(float x); while (fabs(a-b)E) c=(a+b)/2; if(df(c)=0) break; else if(df(a)*df(c)0) b=c; else a=c; return c; float df(float x)return 2*x-6;黄金分割法:#include#includemath.h#define E 0.001#define H 0.618void main() float a,b,x; float goldcut(float a,float b); printf(Enter a,bn); scanf(%f,%f,&a,&b); x=goldcut(a,b); printf(x*=%fn,x); float goldcut(float a,float b) float x1,x2,y1,y2; float f(float x); x2=a+H*(b-a); x1=a+b-x2; y1=f(x1); y2=f(x2); while(fabs(y1-y2)=E) if(y1y2) a=x1; x1=x2; y1=y2; x2=a+H*(b-a); y2=f(x2); else b=x2; x2=x1; y2=y1; x1=a+(1-H)*(b-a); y1=f(x1); return (x1+x2)/2; float f(float x) return x*x-6*x+2;进退法:#include#includemath.hvoid main() float x0,h,x1,jintui(float x0, float h); printf(Enter x0,h:n); scanf(%f,%f,&x0,&h); x1=jintui(x0, h); printf(%f,%f)n,x0,x1);float jintui(float x0,float h) float f(float x),x1,march(float x0,float h); if(f(x0)f(x0+h) x1=march(x0,h); else h=-h; x1=march(x0,h); return x1; float f(float x) return x*x-6*x+2; float march(float x0,float h) float x1=x0+h; while(f(x0)f(x1) x0=x1; h=2*h; x1=x0+h; return x1; 牛顿法:#include#includemath.h#define E 0.0001void main() float x,x0,f(float x); float newton(float x); printf(Enter xn); scanf(%f,&x); x0=newton(x); printf(%f,%f)n,x0,f(x0);float newton(float x) float x1; float f(float x),df(float x),ddf(float x); while (fabs(df(x)E) x1=x-df(x)/ddf(x); x=x1; return x; float f(float x) return x*x-6*x+2; float df(float x) return 2*x-6; float ddf(float x) return 0*x+2;进退法与二分法结合:#include#includemath.h#define E 0.001void main() float x0,h,x1,x2; float jintui(float x0,float h); float erfen(float x0,float x1); printf(Enter x0,hn); scanf(%f,%f,&x0,&h);x1=jintui(x0,h); printf(%f,%f)n,x0,x1);x2=erfen(x0,x1); printf(%fn,x2);float jintui(float x0,float h)float x1;float f(float x);float march(float x0,float h);if(f(x0)f(x0+h) x1=march(x0,h);else h=-h; x1=march(x0,h); return x1;float f(float x) return x*x-6*x+2;float march(float x0,float h) float x1=x0+h;while(f(x0)f(x1) x0=x1; h=2*h; x1=x0+h; return x1;float erfen(float x0,float x1)float c,df(float x);while(fabs(x0-x1)E) c=(x0+x1)/2; if(df(c)=0) break; else if(df(x0)*df(c)0) x1=c; else x0=c; return c;float df(float x)return 2*x-6;进退与黄金法结合:#include#includemath.h#define H 0.618#define E 0.001void main() float x0,h,a,b,x1,x2; float jintui(float x0,float h); float goldcut(float a,float b); printf(Enter x0,hn); scanf(%f,%f,&x0,&h);x1=jintui(x0,h); printf(%f,%f)n,x0,x1);x2=goldcut(x0,x1); printf(x2*=%fn,x2); float jintui(float x0,float h) float x1,f(float x),march(float x0,float h); if(f(x0)f(x0+h) x1=march(x0,h); else h=-h;x1=march(x0,h); return x1;float march(float x0,float h) float x1=x0+h; while(f(x0)f(x1) x0=x1; h=2*h; x1=x0+h; return x1; float goldcut(float a,float b) float x1,x2,y1,y2; float f(float x); x2=a+H*(b-a); x1=a+b-x2; y1=f(x1); y2=f(x2); while(fabs(y1-y2)=E
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 抖音商户场控直播网络稳定性保障制度
- 抖音商户直播话题热度跟踪制度
- 全球教育变革中2025年跨文化交流能力培养的课程开发研究
- 全球铀矿资源地理分布与核能产业未来发展挑战研究报告
- Carbonic-anhydrase-inhibitor-30-生命科学试剂-MCE
- 黑龙江农业职业技术学院《制药工程综合设计》2023-2024学年第一学期期末试卷
- 嵩山少林武术职业学院《电影镜头画面创作》2023-2024学年第一学期期末试卷
- 广东省中学山市四中学2024-2025学年数学七上期末学业质量监测模拟试题含解析
- 公路货运行业数字化转型与效率提升的智能化运输装备应用报告
- 食物安全管理培训课件
- 完整版:美制螺纹尺寸对照表(牙数、牙高、螺距、小径、中径外径、钻孔)
- 湖南大众传媒职业技术学院辅导员考试题库
- GB/T 3608-2008高处作业分级
- 医院就诊告知书
- 职业暴露(锐器伤)应急预案演练脚本
- 首届全国报刊编校技能大赛决赛试卷(一)及答案
- 材料出入库表格范本
- DB14∕T 2442-2022 政务数据分类分级要求
- 医务人员行为规范以及服务礼仪
- 医用手套的研究进展
- 华为要求终端结构件Cpk及SPC执行操作规范V20
评论
0/150
提交评论