Skip to content
chrismedrela edited this page Jul 7, 2014 · 2 revisions

This feature is not implemented yet!

Integration

Breeze comes with builtin integration facilities, located in breeze.integration module. At this moment, there is only 1d trapezoid and Simpson interpolation available, but you are encouraged to contribute to Breeze and write other intergrators.

All examples in this document assumes that you've imported necessary modules:

scala> import breeze.integration._

1D integrals

breeze.integration comes with one function for each integration method. Now, there are trapezoid_integral and simpson_integral functions, both sharing the same interface:

scala> val f = x => 2*x
scala> trapezoid_integral(f, 0, 1, 2)
?

scala> simpson_integral(f, 0, 1, 2000)
?

The arguments are:

  • the function whose integral we want to compute; should be Double => Double
  • the beginning of the integration range
  • the end of the integration range
  • accuracy -- the number of nodes; higher the number, more accurate the integral is, but also it takes more time; for trapezoid_integral, there must be at least two nodes while simpson_integral requires three or more nodes.

Trapezoid and Simpson integral don't support infinite integration ranges. Both ends of the range must be finite.

Clone this wiki locally