mid-point method Integration

1 Ansicht (letzte 30 Tage)
Tony
Tony am 4 Jan. 2014
Beantwortet: Akshay satpute am 8 Okt. 2017
Find numerically , to a 1/10000 accuracy, the values of the following definite integral:
0 to inf 1/(x^2+1) dx
use the mid-point method.
not show how to answer this i went about integrating it. My knowledge of the midpoint rule is limited.
the width of the sub intervals would be 1/10000 but how would you go about dividing it by infinity. I did the integration:
if true
% code
syms x
a1= int(1/(x^2+1),x,0,inf)
end
  2 Kommentare
John D'Errico
John D'Errico am 5 Jan. 2014
Why do you think you need an "if true" in there??????
Youssef  Khmou
Youssef Khmou am 5 Jan. 2014
the instruction if true appeared because the poster clicked on "Code" button

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Youssef  Khmou
Youssef Khmou am 5 Jan. 2014
Theoretically that integral equals pi/2, here is version, try to adjust it :
% MidPoint test integration
clear;
f=inline('1./((x.^2)+1)');
N=20000;
dx=1/1e+2;
F=0;
x1=0;
for t=1:N
xi=(dx/2)+x1;
F=F+dx*f(xi);
x1=x1+dx;
end
% For verification try :
quad(f,0,1e+18)
  2 Kommentare
Tony
Tony am 5 Jan. 2014
thank you for your time question. N should equal 10000 no? and dx=1/100 right? just don't understand why dx is 1/100.
trying to understand since i don't fairly understand the midpoint rule. it should be something like ((b-a)/subintervals) * f(x1)+f(x2)...f(xn). I don't see how it fits in that general form
Youssef  Khmou
Youssef Khmou am 5 Jan. 2014
dx was taken arbitrarily, try with dx=1e-4 . that code is based on the formula in this file, try to look at this file first

Melden Sie sich an, um zu kommentieren.


Akshay satpute
Akshay satpute am 8 Okt. 2017
tell me program of integration of {x^2 (sinh(X)+cosh(x))dx} between limit 0 to 1 in 100 parts

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by