func7p1.m
资源名称:数值分析课程设计.zip [点击查看]
上传用户:zhdd911129
上传日期:2007-05-11
资源大小:722k
文件大小:1k
源码类别:
matlab例程
开发平台:
Matlab
- %func7p1.m二分法解方程
- %(1)
- s=1;f=3;tol=0.01;i=0
- difference=1
- while(abs(difference)>tol)
- if(sub7p11((s+f)/2)>0)
- f=(s+f)/2;
- else
- s=(s+f)/2;
- end
- difference=sub7p11((s+f)/2);
- i=i+1
- end
- %用四次循环得到解 1.9375,误差0.004
- %(2)
- s=0;f=1.5;tol=0.01;i=0
- difference=1
- while(abs(difference)>tol)
- if(sub7p12((s+f)/2)>0)
- f=(s+f)/2;
- else
- s=(s+f)/2;
- end
- difference=sub7p12((s+f)/2);
- i=i+1
- end
- % 用6次循环得到解 1.1133,误差0.0012