Skip to content
Jake Timothy edited this page Jan 19, 2016 · 3 revisions

This feature is not implemented yet!

Integration

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

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

scala> import breeze.integrate._

1D integrals

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

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

scala> simpson(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, there must be at least two nodes while simpson requires three or more nodes.

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