十二指肠溃疡会便血吗:对于函数f(X)=X+cosX,在[0,pi/2]上验证拉格朗日微分中值定理。

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/26 09:22:11
应Matlab编一个动画。

Matlab源程序:

function y=sss()
a=0;b=pi;
dif=(temp(b)-temp(a))/(b-a);
x0=a:0.01:b;
y0=temp(x0);
widths=pi/4;
n=length(x0);
for i=1:n
x1=(x0(i)-widths):0.01:(x0(i)+widths);
dd=dtemp(x0(i));
y1=(x1-x0(i))*dd+y0(i);
plot(x0,y0,'-r');
hold on;
axis([0 pi 0 5]);
plot([a b],[temp(a),temp(b)],'-b');
plot(x1,y1,'-.k');
tutu = legend('f(x)=x+sin(x)','端点割线','切线');
set(tutu,'fontname','宋体','fontsize',10,'FontWeight','demi');
title('用函数f(x)=x+sin(x)验证Lagrange中值定理',...
'fontname','宋体','fontsize',9,'FontWeight','demi','Color','black');
plot(x0(i),y0(i),'-ro','markersize',4);
pause(0.001);
hold off;
if abs(dd-dif)<0.000001
ta=[' \leftarrow 该点满足Lagrange中值定理','(',num2str(x0(i)),',',num2str(x0(i)),')'];
text(x0(i),y0(i),ta,'FontSize',9);
return;
end
end

function y=temp(x)
n=length(x);
for i=1:n
y(i)=x(i)+sin(x(i));
end

function y=dtemp(x)
syms a;
yt=diff(temp(a));
y=subs(yt,'a',x);

'VB写的
Function f(ByVal x As Single) As Single
f = x + Cos(x)
End Function

Function df(ByVal x As Single) As Single
df = 1 - Sin(x)
End Function

Private Sub Command1_Click()

tmp = (f(2 * Atn(1)) - f(0)) / (2 * Atn(1))
Form1.Line (Form1.ScaleLeft, tmp)-(Form1.ScaleWidth, tmp), vbRed
For i = 0 To 2 * Atn(1) Step 0.001
Form1.Line (i, df(i))-(i + 0.001, df(i + 0.001)), vbBlue
Next

End Sub

Private Sub Form_Load()
ScaleTop = 1
ScaleLeft = -1
ScaleHeight = -2
ScaleWidth = 2
BackColor = vbBlack
Top = 0
Left = 0
Height = Screen.Height
Width = Screen.Width
End Sub