0

I have a following problem - I need to integrate such a function in Mathematica (I couldn't post an image, so I am writing it in latex form):


G(r)= \int_{0}^{\infty} dq f(q)*q*sin(qr)/r

To obtain function G(r) dependable on r. Nevertheless I don't know the analytical form of f(q), instead I have set of values of f(q) and for q. So I'd like to make a some kind of numerical integration, but to receive not a value afterwards, but a curve of G(r).

BenMorel
  • 34,448
  • 50
  • 182
  • 322
John Dean
  • 1
  • 2
  • http://reference.wolfram.com/mathematica/ref/FindFit.html – Mikhail May 15 '12 at 22:53
  • @JohnDean If you have more questions about `Mathematica` it will be better if you ask your questions at this site : http://mathematica.stackexchange.com because it is specifically for `Mathematica` users. – Artes May 15 '12 at 23:10

1 Answers1

1

In case you know the analytic form of the function f[q] you can do this :

Integrate[f[q] q Sin[q r]/r, {q, 0, Infinity}]

but in case of knowing only values of f[q] you can integrate numerically :

G[r_]:= NIntegrate[ f[q] q Sin[q r]/r, {q, 0, Infinity}]

Assume e.g.

f[q_] := Exp[-q]
Integrate[f[q] q Sin[q r]/r, {q, 0, Infinity}]

yields

ConditionalExpression[2/(1 + r^2)^2, Abs[Im[r]] < 1]   

You can make an assumption a priori, e.g. :

Assuming[r > 0, Integrate[f[q] q Sin[q r]/r, {q, 0, Infinity}]]

yields

2/(1 + r^2)^2

Assuming r > 0 you implicitly assume r to be real, so Im[r] == 0. Having the function G[r] we can plot the appropriate curve, defining f[q] as above :

Plot[ G[r], {r, 0, 10}]

enter image description here

Artes
  • 1,133
  • 1
  • 17
  • 24
  • Thanks for such a quick answer. Nevertheless I've some comments - I can't assume any kind of a function, because there is no analytical form of f(q). I know the shape of it as its values are data points from an experiment. – John Dean May 16 '12 at 14:34
  • But I have some other idea - I'd just make a loop for numerical integration for discrete r values and in the end getting discrete form of G(r). But there arises other problem, when I want to make just a numerical integration with my data points, as you have written in second code, I get set of values, not an area under the curve. I don't know why. – John Dean May 16 '12 at 14:42
  • `Assuming` was here only an example how one can refine `ConditionalExpression`. If you know values of `f[q]` you can use `NIntegrate`. – Artes May 16 '12 at 14:42
  • Maybe use your (q,f(q) known values to create an InterpolatingFunction for f. Then use that in the numeric integration that defines G[r] for numeric r. – Daniel Lichtblau May 17 '12 at 14:55