网站大量收购独家精品文档,联系QQ:2885784924

工程常用算法作业第一次.docx

  1. 1、本文档共13页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
工程常用算法作业第一次

《工程常用算法》综合实践作业一 作业名称:非线性方程求根 完成日期: 2016年3月 28 组号:52 班级 学号 姓名 主要工作说明 自评成绩2013071421 辛超俊 设计算法,编写程序 A2013071524 张宁 用Visio软件绘制流程图 作业题目: 已知方程,请分别用二分法、牛顿法和割线法求此方程的根。误差限取:。注意先确定出方程的有根区间 程序框图: 牛顿法: 二分法: 割线法: 牛顿法源程序: #includestdio.h #includemath.h #includestring.h double NextNumber(double a)//产生下一个数 { return a-(a*a*a+2*a*a-exp(a))/(3*a*a+4*a); } double func(double x)//原函数 { return x*x*x+2*x*x-exp(x); } void main() { double a=1;//A(k) int i=1; double fx=0; double b=NextNumber(1);//A(k+1) double ex=pow(10.0,-12);//精度 fx=func(b); printf(第%2d次 X=%.12f f(x)=%.12f\n,i,a,fx); while(fabs(a-b)exfx!=0) { i++; a=b; b=NextNumber(a); fx=func(b); printf(第%2d次 X=%.12f f(x)=%.12f\n,i,a,fx); } getchar(); } 牛顿法运行结果: 二分法源程序: #includestdio.h #includemath.h #includestring.h double func(double x)//原函数 { return x*x*x+2*x*x-exp(x); } /* 输入参数:区间[a,b]、区间精度ex、函数精度ey */ void main(void) { double a=0;//前一个数 double b=5;//后一个数 double c=0;//中间的数 double fx=0;//函数结果 int i=1; double ex=pow(10.0,-12); c=(a+b)/2.0; fx=func(c); printf(第%2d次 X=%.12f f(x)=%.12f\n,i,c,fx); while((b-a)exfx!=0) { i++; c=(a+b)/2.0; fx=func(c); if(fx==0) { b=c; printf(第%2d次 X=%.12f f(x)=%.12f\n,i,c,fx); break; } else { if(fx0) b=c; else a=c; printf(第%2d次 X=%.12f f(x)=%.12f\n,i,c,fx); } } getchar(); }} 二分法运行结果: 割线法源程序: #includestdio.h #includemath.h #includestring.h double func(double x)//原函数 { return x*x*x+2*x*x-exp(x); } double NextNumber(double a,double b)//产生下一个数 { double fx=b-func(b)*(b-a)/(func(b)-func(a)); return fx; } void main() { double a=0;//A(k-1) double b=3.0;//A(k) int i=1; double c=0;// A(k+1) double ex=pow(10.0,-12);//精度 double fx=0; c=NextNumber(b,a);// fx=func(c); printf(第%d次 X=%.12f f(x)=%.12f\n,i,

您可能关注的文档

文档评论(0)

zilaiye + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档