MATLAB已知函数y=1244*exp(-0.162 *x) + -1244*exp(-3.052*x);当y=437.15时,要使y再次达到999.2156, 5
y=437.15时, x = 0.1546
y=999.2156时, x= 1.0161
问题示意图:
x=0:0.005:5;y=1244*exp(-0.162 *x) + -1244*exp(-3.052*x);plot(x,y);hold on;
yy=437.15; plot(x,yy,'r-');hold on
yyy=999.2156; plot(x,yyy,'r-')
割线法求解:
ger.m
function y=ger(x0,x1);
x2=x1-fc(x1)*(x1-x0)/(fc(x1)-fc(x0));
n=1;
while((abs(x1-x0)>=1.0e-5)&(n<=10000000))
x0=x1;x1=x2;
x2=x1-fc(x1)*(x1-x0)/(fc(x1)-fc(x0));
n=n+1;
end
x2
n
function y=fc(x)
%y=1244*exp(-0.162 *x) + -1244*exp(-3.052*x)-437.15;
y=1244*exp(-0.162 *x) + -1244*exp(-3.052*x)-999.2156;
>>ger(0.1,0.2) %y=437.15时
>>ger(0.1,2) %y=999.2156时