Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- clc
- disp('f(x)=ln(x)/x, x=[1,8]')
- q=input('Step number (must be even): ');
- a=input('Lower bound: ');
- b=input('Upper bound: ');
- for n=2:2:q
- h=(b-a)/n;
- for i=1:(n+1)
- x(i)=a+h*(i-1);
- f(i)=log(x(i))/x(i);
- end
- m=(h/3)*(f(1)+f(n+1)+4*(sum(f(2:2:n-1)))+2*(sum(f(3:2:n))));
- s(n)=m;
- end
- plot(2:2:q,s(2:2:q))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement