Double integrals with variable upper limit

Click For Summary

Discussion Overview

The discussion revolves around computing double integrals with variable upper limits in the C programming language. Participants explore different methods and approaches for numerical integration, particularly in the context of performance and efficiency compared to Python's scipy.integrate.dblquad function.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant seeks to compute the integral F(k) = k∫₀^∞ dy ∫₀^y dx f(kx,y) in C, expressing concerns about the speed of Python's scipy.integrate.dblquad function.
  • Another participant proposes an alternative formulation of the integral, F(k) = k∫₀^∞ dy ∫₀^y dx f(x,y), and suggests a substitution to transform the integration limits, potentially simplifying the computation.
  • A later post clarifies that the integrand also depends on k, indicating a modification to the original problem statement.
  • One participant suggests a theoretical approach to compute the double integral by looping through one-dimensional integrals and summing them, emphasizing the importance of accuracy and optimization based on the function's properties.
  • Further optimization strategies are mentioned, including the potential use of floating point or GPU programming to enhance computational efficiency.

Areas of Agreement / Disagreement

Participants express differing views on the best approach to compute the double integral, with no consensus reached on a single method or solution. Various strategies and formulations are proposed, reflecting the complexity of the problem.

Contextual Notes

Some limitations include the dependence on specific properties of the integrand and the need for careful consideration of integration limits. The discussion does not resolve the mathematical steps involved in the proposed substitutions or methods.

niteOwl
Messages
10
Reaction score
0
How can you compute
[itex] F(k) = k\int^{\infty}_{0}dy\int^{y}_{0}dx f(kx,y)[/itex]

in C. I know about Python's scipy.integrate.dblquad function but it's just too slow. I have written some Cython code with a 2D gaussian quadrature function in C but it only takes doubles as limits. I think C doesn't have anything like Python's lambda, so how can this be done in C?
 
Last edited:
Technology news on Phys.org
niteOwl said:
How can you compute
[itex] F(k) = k\int^{\infty}_{0}dy\int^{y}_{0}dx f(x,y)[/itex]

in C. I know about Python's scipy.integrate.dblquad function but it's just too slow. I have written some Cython code with a 2D gaussian quadrature function in C but it only takes doubles as limits. I think C doesn't have anything like Python's lambda, so how can this be done in C?

This is [itex]k[/itex] times a constant, which happens to be [itex]\int_0^\infty \int_0^y f(x,y)\,dx\,dy[/itex]. You can obtain a rectangular, finite domain of integration by making the substitution [itex](x,y) = (\mathrm{arctanh}(s) \cos\theta, \mathrm{arctanh}(s) \sin \theta)[/itex] to obtain [tex] \int_0^1 \int_{\frac14\pi}^{\frac12\pi} \frac{\mathrm{arctanh}(s)}{1 - s^2} f(\mathrm{arctanh}(s) \cos\theta, \mathrm{arctanh}(s) \sin \theta)\,d\theta\,ds.[/tex] Probably best to use a scheme of integration which doesn't require values of the integrand on [itex]s = 1[/itex].
 
pasmith said:
This is [itex]k[/itex] times a constant

i forgot to say the integrand also depends on k, question is edited.
 
Hey niteOwl.

You could theoretically code a routine that loops through the one dimensional integrals and adds them up to achieve a double integral.

If you can integrate one "strip" (as it were) you just add up the strips in the double integral.

The accuracy will be determined with respect to the kind of function being integrated and if you know various derivative properties you could optimize it so that you only do so many computations per evaluation and that gets processed in some finite time interval. If you do this so many times within a couple of loops then you will be able to gauge the computational complexity of the integration routine.

If you want to optimize further then try learning floating point or GPU programming as an exercise.
 

Similar threads

  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 16 ·
Replies
16
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
7K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K