Message Boards Message Boards

[✓] Break a time consuming integration into pieces?


I am trying to calculate an expression which has the following form

Sum[(-1)^(n+1) Bionomial[4,n] NIntegrate[S[n,x] Q[n,x] V[n,x] F[x], {x,0,2000} , WorkingPercision -> 5 ] , {n, 4} ]

Where we have :

G[x_ ] := 2 Pi x p[x] Exp[-2 Pi Integrate[t p[t], {t, 0, x}]]

p[x_ ] := Piecewise[ {{0 , x > 140}} , Exp[ -0.0071* x] ];

S[n_ ,x_ ] := Exp[ -n x];

Q[n_ ,x_ ] := Product[ Exp[-2 Pi Integrate [1 - 1/(n x)^4 p[t] t ,  {t,x, Infinity }]] ,{n,4} ]

V[n_ ,x_ ] := Product[ Exp[-2 Pi Integrate [1 - 1/(n x / t^2 )^4 (1-p[t]) t ,  {t, x^2 , Infinity }]] ,{n,4} ]

F[x_ ] := G[x] Exp[Integrate[ -2 Pi (1- p[t]) t , {t, 0 , x }]]

Unfortunately the evaluation takes so much time. Is there any way to break this expression into pieces and perform calculation separately ? p.s. I also tried limiting WorkingPercision and MaxRecursion but it didn't work.

The acceptable WorkingPercision is 5 and the acceptable evaluation time is less than half an hour !

I appreciate your suggestions.

POSTED BY: Shahrooz Aghili
2 months ago

Are your five functions simple enough to paste (as code, not an image) into you original post?

How long would an acceptable time be to complete this calculation?

How little precision in the result would be acceptable to you?

With those someone might be able to offer some ideas to help you.

POSTED BY: Bill Simpson
2 months ago

Hi Bill , Thanks for your comment ! I have edited the the problem definition and provided the Mathematica code for it.

POSTED BY: Shahrooz Aghili
2 months ago

Thank you for your code. That is very helpful.

When I try to evaluate your code I get errors

Product::itraw: Raw object 1 cannot be used as an iterator. >>

Product::vloc: The variable 1 cannot be localized so that it can be assigned to numerical values. >>

Are there perhaps slight differences between the code in your notebook and what you wrote in the message?

I often use the mouse to highlight all the code, copy it to the clipboard and then paste the clipboard into the message. That can help me try to avoid making little mistakes that I do not notice until too late.

Then I highlight all the code in the message and use the icon in the upper left corner of the posting box to format my information as code, rather than as plain text. That will help keep the posting process from doing some of the desktop publishing which can damage and modify the code.

Do you give the variable r a particular value?

POSTED BY: Bill Simpson
2 months ago

I see a couple of problems. As Bill points out, your code is not syntactically correct. I assume, for example that r should really be "x" in p[x_].

Some general points:

  1. You should not use "If" in an expression you want to integrate -- Use Piecewise instead so Mathematica can integrate it.
  2. You recompute the same integral many times over -- set up your code to do complicated integrals once and substitute into the results.
  3. Some of your integrals go to either zero or infinity. For example your expression for V[] is not defined when x is zero. G[x] goes to zero (so is the integral zero? or does another term go to infinity?)
  4. Do not use capital letters for functions or variables because capital letters are reserved for internal usage in Mathematica.

I would fix these issues and post equations that are correct.

I hope this helps. Regards

POSTED BY: Neil Singer
2 months ago

Group Abstract Group Abstract