Are there any Haskell libraries for integrating complex functions?

<ol> <li>How to numerically integrate complex, complex-valued functions in Haskell?</li> <li>Are there any existing libraries for it? numeric-tools operates only on reals.</li> </ol>

I am aware that on complex plane there's only line integrals, so the interface I am interested in is something like this:

i = integrate f x a b precision

to calculate integral along straight line from a to b of function f on point x. i, x, a, b are all of Complex Double or better Num a => Complex a type.

Please... :)


You can make something like this yourself. Suppose you have a function realIntegrate of type (Double -> Double) -> (Double,Double) -> Double, taking a function and a tuple containing the lower and upper bounds, returning the result to some fixed precision. You could define realIntegrate f (lo,hi) = quadRomberg defQuad (lo,hi) f using numeric-tools, for example.

Then we can make your desired function as follows - I'm ignoring the precision for now (and I don't understand what your x parameter is for!):

integrate :: (Complex Double -> Complex Double) -> Complex Double -> Complex Double -> Complex Double integrate f a b = r :+ i where r = realIntegrate realF (0,1) i = realIntegrate imagF (0,1) realF t = realPart (f (interpolate t)) -- or realF = realPart . f . interpolate imagF t = imagPart (f (interpolate t)) interpolate t = a + (t :+ 0) * (b - a)

So we express the path from a to b as a function on the real interval from 0 to 1 by linear interpolation, take the value of f along that path, integrate the real and imaginary parts separately (I don't know if this can give numerically badly behaving results, though) and reassemble them into the final answer.

I haven't tested this code as I don't have numeric-tools installed, but at least it typechecks :-)


  • track changes of nodes bound in JavaFX
  • UITableView numberOfRowsInSection Will Not Load More than One Row
  • How to make NSView's background image not repeat?
  • SpriteKit screenshot of view off screen
  • Disable vertical scroll in UIScrollView Swift
  • How to make text wrap in a WPF TreeViewItem?
  • C++ Incrementing a pointer into unknown memory territory
  • How to curve a Polyline in react-google-maps?
  • byte, char, int in Java - bit representation
  • Drawing a polygon over the entire map
  • JsonConvert.DeserializeObject, Index was outside the bounds of the array
  • How to get or calculate size of Azure File/Share or Service
  • Exporting SAS DataSet on to UNIX as a text file…with delimiter '~|~'
  • Drag and reorder - UICollectionview with sections
  • How to model a mixture of finite components from different parametric families with JAGS?
  • Fraction length
  • SQL Server re-calculate or not?
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • Receive mouse move even cursor is outside control
  • Why the SequenceFile is truncated?
  • Use of this Javascript
  • Atlas images wrong size on iPad iOS 9
  • Linq Objects Group By & Sum
  • Android screen density dpi vs ppi
  • Is possible to count alias result on mysql
  • How would I use PHP exceptions to define a redirect?
  • How to extract text from Word files using C#?
  • MySQL WHERE-condition in procedure ignored
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Do I've to free mysql result after storing it?
  • Calling of Constructors in a Java
  • How to format a variable of double type
  • Buffer size for converting unsigned long to string
  • need help with bizarre java.net.HttpURLConnection behavior
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?