(35S) Quick integration
|
11-12-2022, 05:13 PM
(This post was last modified: 11-14-2022 10:25 AM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: (35S) Quick integration
With only 3 sample points, I would use Gaussian quadrature.
It is more accurate (exact for quintic polynomial or less), and does not touch end-points. Code is slightly more complicated, but I think it is worth it. Code: def gauss3(f,a,b, w=0.6**0.5): Your example, ∫(√(1+4*x^2), x = 0..1) ≈ 1.47894285754 Simpson 3-pts: 1.48215537045, relative error ≈ -0.217% Gaussian 3-pts: 1.47910755366, relative error ≈ -0.011% Update: integral formula corrected. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)