Estimating function intergral - function containing a sine or a cosine

Hi Julia users,

I am looking for a package with functionality similar to the FORTRAN package QDAWO: https://docs.roguewave.com/en/imsl/fortran/2018.0/html/fnlmath/index.html#page/FNLMath/mch4.07.08.html.

The FORTRAN function

Takes:

  • function F that evaluates X
  • a simple weight function cos(omega * x) or sin(omega * x)
  • integration limits
  • some optional accuracy args

Returns:

  • Estimate of the integral from A to B of F * weight. (Output)

Does anyone have any suggestions?
Cheers,
Tim

I think QuadGK.jl is a good option for this, if I understand the problem correctly.

2 Likes

Great, do you have an example of how to integrate the example given for the FORTRAN package with QuadGK? (see the bottom of the page in the link)
Func
where sin(10 pi x) is the weight function.

Tim

julia> using QuadGK

julia> I, err = quadgk(x -> log(x) * sin(10π * x), 0, 1)
(-0.12813684841011241, 6.022027749476766e-10)

err is an estimate of the error.

3 Likes

If you need more precision:

julia> quadgk(x -> log(x) * sinpi(10 * x), big(0), big(1))
(-0.1281368483991673319461205998814827821390661153292255454760992739874546286851618, 5.320715261059094679776530339302038795574511819139725448727858206949982301331101e-40)
1 Like

Great, that’s really simple.

Cheers,
Tim

1 Like