Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens notedJens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]

If you really do wish to use Simpson's rule specifically (perhaps, for a homework or to reproduce some other result), you can also do what Daniel suggested, which is to set up the vector for Simpson's rule (or the 3/8ths rule), $\{1,4,2,4,2,\ldots,4,2,1\}$ and use Dot.

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]

If you really do wish to use Simpson's rule specifically (perhaps, for a homework or to reproduce some other result), you can also do what Daniel suggested, which is to set up the vector for Simpson's rule (or the 3/8ths rule), $\{1,4,2,4,2,\ldots,4,2,1\}$ and use Dot.

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]

If you really do wish to use Simpson's rule specifically (perhaps, for a homework or to reproduce some other result), you can also do what Daniel suggested, which is to set up the vector for Simpson's rule (or the 3/8ths rule), $\{1,4,2,4,2,\ldots,4,2,1\}$ and use Dot.

added 275 characters in body
Source Link
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]

If you really do wish to use Simpson's rule specifically (perhaps, for a homework or to reproduce some other result), you can also do what Daniel suggested, which is to set up the vector for Simpson's rule (or the 3/8ths rule), $\{1,4,2,4,2,\ldots,4,2,1\}$ and use Dot.

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]

If you really do wish to use Simpson's rule specifically (perhaps, for a homework or to reproduce some other result), you can also do what Daniel suggested, which is to set up the vector for Simpson's rule (or the 3/8ths rule), $\{1,4,2,4,2,\ldots,4,2,1\}$ and use Dot.

Source Link
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it:

With[{if = Interpolation[(* list of {x, y} pairs *), InterpolationOrder -> k}, 
    Integrate[if[x], {x, Sequence @@ if["Domain"][[1]]}]
]