I've got the below code which get the value of s for n=100 , this is an example for Rectangular Numerical integration for F(x)= 4/1+x^2, I want to make a command to get the value of n? for s= 3.1515 , I've tried to do it with if command but for some reason I keep getting errors, I appreciate any help!
f = @(x) 4/(1+x^2);a=0;b=1;s=0;n=100h=(b-a)/n;for i=0:1:n-1 s=s+f(a+i*h);end;s=s*h;fprintf("%f\n", s);
Best Answer