化专012 闵建中12102914
1.解:
(1):
x = -2:0.1:0;
y1 = 3*x.^3-2*x+2;
y2 = 0;
plot(x,y1,'b-',x,y2,'r-')
由图可以看出,方程的有根区间为[-1.2,-1]
2.解:
(1) 使用二分法求满足精度要求的解:
a=-1.2;b=-1;delta=0.01;
f=@(x) ( 3*x.^3-2*x+2);
[c]=bisect(f,a,b,delta)
有结果如下:
c = -1.1187
(2)(3)小题同上!
3.试位法的matlab实现:
function [c,k]=fapo(f,a,b,epsilon,max1)
% Use false position to find the root of function
% Input : f = the function
% a,b = left and right brackets of root
% epsilon = the tolerance for the value of f at the zero
% max1 = the maximum number of iterations
% Output : c = estimate of the root