format long
fplot('exp(x).*sin(x)',[0,pi]);
grid
s=quadl('exp(x).*sin(x)',0,pi)
a=0;b=pi;
e=1;
whilee>1e-6; c=(a+b)/2; s1=quadl('exp(x).*sin(x)',0,c); ifs1>s/2; b=c; else s1<s/2; a=c; end e=abs(s1-s/2);
end
c hold on plot([c,c],[0,8],'r'); e1=1; g=0;h=7; while e1>1e-6; m=(g+h)/2; x1=fsolve(@(x)exp(x).*sin(x)-m,0); x2=fsolve(@(x)exp(x).*sin(x)-m,pi); s2=quad('exp(x).*sin(x)',x1,x2)-(x2-x1)*m; if s2<s/2; h=m; else g=m; end e1=abs(s2-s/2); end plot([0,3.4],[m,m],'g');