Breaking down a numerical integration into two parts
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Luqman Saleem
am 6 Mär. 2024
Kommentiert: Luqman Saleem
am 6 Mär. 2024
Sorry for this stupic question.
Suppose we have this integral
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636431/image.png)
Of couse this can be solved analytically. But I still want to solve it numerically as:
dx = 0.01;
x = 1:dx:4;
fx = x.^2 + 5*x;
I = trapz(x,fx)
Now, we break down this integral into two part. Analytically, we write it as:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636436/image.png)
I am confused about the lower limit of the second integral
when solving it numerically. Should it be 2 or
. If we use 2, will not it mean that we are counting one point two times, once in
and once in
?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636441/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636446/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636451/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636456/image.png)
0 Kommentare
Akzeptierte Antwort
Torsten
am 6 Mär. 2024
I1 = dx/2 * f(x0) + dx * sum_{i=1}^{n-1} f(xi) + dx/2 * f(xn)
I2 = dx/2 * f(xn) + dx * sum_{i=n+1}^{n+m-1} f(xi) + dx/2 * f(x_{n+m})
->
I1 + I2 = dx/2 * f(x0) + dx * sum_{i=1}^{n+m-1} f(xi) + dx/2 * f(x_{n+m})
Thus since the endpoints in the trapezoidal rule are only counted half, all is fine.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Eigenvalue Problems 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!