欢迎来到天天文库
浏览记录
ID:16196526
大小:25.50 KB
页数:3页
时间:2018-08-08
《vc课程设计报告 分别用牛顿迭代法、弦截法和二分法求根源程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#includedoublef(doublex);doubleniudun(doublex);doubleerfen(doublex1,doublex2);doublexuanqie(doublex1,doublex2);doubleroot(doublex1,doublex2);doublepoint(doublex1,doublex2);voidmain(){doublex1,x2,y1,y2,x,x0,y0,q,w,e;x1=-1;x2=1;x0=0.5;y0=f
2、(x0);y1=f(x1);y2=f(x2);q=niudun(x);w=erfen(x1,x2);e=xuanqie(x1,x2);cout<<"牛顿迭代法得x="<3、1-x2)>1e-6);cout<<"x="<=1e-6);cout<<"x="<4、2){doubley1,y2,x;y1=f(x1);y2=f(x2);cout<<"两端点的值为["<0){y1=y;x1=x;}els5、ex2=x;}while(fabs(y)>=0.000001);returnx;}doublepoint(doublex1,doublex2){doubley;y=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));returny;}
3、1-x2)>1e-6);cout<<"x="<=1e-6);cout<<"x="<4、2){doubley1,y2,x;y1=f(x1);y2=f(x2);cout<<"两端点的值为["<0){y1=y;x1=x;}els5、ex2=x;}while(fabs(y)>=0.000001);returnx;}doublepoint(doublex1,doublex2){doubley;y=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));returny;}
4、2){doubley1,y2,x;y1=f(x1);y2=f(x2);cout<<"两端点的值为["<0){y1=y;x1=x;}els
5、ex2=x;}while(fabs(y)>=0.000001);returnx;}doublepoint(doublex1,doublex2){doubley;y=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));returny;}
此文档下载收益归作者所有