Solving Mathematica Error: NIntegrate::ncvb

Click For Summary
SUMMARY

The forum discussion centers on resolving the Mathematica error NIntegrate::ncvb, which indicates failure to converge to the desired accuracy during numerical integration. The user is attempting to evaluate an integral involving exponential functions and the ExpIntegralE function, but encounters issues primarily due to the choice of limits and precision settings. Key recommendations include adjusting the precision goal and allowing for more recursion in the NIntegrate function. The discussion also highlights the importance of verifying the mathematical formulation of the integral being evaluated.

PREREQUISITES
  • Familiarity with Mathematica 12.0 syntax and functions
  • Understanding of numerical integration techniques, specifically NIntegrate
  • Knowledge of exponential functions and the ExpIntegralE function
  • Basic understanding of precision and recursion settings in numerical computations
NEXT STEPS
  • Explore advanced options in NIntegrate for improved convergence
  • Learn about the implications of precision settings in Mathematica
  • Investigate the behavior of ExpIntegralE in various contexts
  • Review best practices for defining limits in numerical integrals
USEFUL FOR

Mathematica users, computational mathematicians, and researchers involved in numerical analysis and integration tasks.

  • #31
OK, thanks. I'm trying to do the mathematical derivations all over again. But I suspect it's just a technical issue with Mathematica.
 
Physics news on Phys.org
  • #32
Code:
For[yQdB = -10, yQdB <= 15, yQdB++;
 yQ = 10^(yQdB/10);
 INTEGRAND = 
  Simplify[1/x^2*Exp[(GSS*(x + GSS*yQ))/(x*yp) - x]*
    Exp[-(GSS*(x + GSS*yQ))/(x*yp) T]/T];
 A1 = 0.5*((GSS^2)*yQ)/yp*
   NIntegrate[INTEGRAND, {T, 1, \[Infinity]}, {x, Cons, Infinity}, 
    PrecisionGoal -> 5, MaxRecursion -> 12, WorkingPrecision -> 20];
 Print["A1 = ", 0.5*((GSS^2)*yQ)/yp, 
  "\[Times] NIntegrate[  1/x^2\[Times]Exp[ ( ", GSS, "\[Times](x +", 
  GSS*yQ, "))/(x\[Times]", yp, ") - x]\[Times] ExpIntegralE[1, (", 
  GSS, "\[Times](x + ", GSS*yQ, "))/(x\[Times]", yp, ")]"]]

Try that.
Basically its evaluating E1 and the Exponential separately, and one is hitting $MaxNumber and the other $MinNumber.

To fix this I just took the definition of the E1 function (its in its help file under "more information") and then let it combine the two exponentials before integration.

Now of course you have a 2-dimensional numerical integration, which takes a bit longer, but it seems to get the results. It complains about precision, but the results seem ok. You can increase working precision to try to get that error to go away, but it makes it slower and slower.

Does that help?
 
  • #33
Thanks. But I get results in term of x. How to get numerical values? (I'm no expert in Mathematica)
 
  • #34
Code:
yp = 10^(5/10);
GSS = 100;
Cons = 10^-7;
results = {};
For[yQdB = -10, yQdB <= 15, yQdB++;
 yQ = 10^(yQdB/10);
 INTEGRAND = 
  Simplify[1/x^2*Exp[(GSS*(x + GSS*yQ))/(x*yp) - x]*
    Exp[-(GSS*(x + GSS*yQ))/(x*yp) T]/T];
 A1 = 0.5*((GSS^2)*yQ)/yp*
   NIntegrate[INTEGRAND, {T, 1, \[Infinity]}, {x, Cons, Infinity}, 
    PrecisionGoal -> 5, MaxRecursion -> 12, WorkingPrecision -> 20];
 results = Join[results, {yQdB, A1}];
 Print[{yQdB, A1}];]

Sorry, I left in your old code showing the equation.

This should print you real results, and at the end of the run you can just look at "results".

Though I'm not certain if this is giving the correct result to be honest, as once yQdB passes 5 it changes to something low. Maybe that's how it should be? I don't know.
 
  • Like
Likes   Reactions: EngWiPy
  • #35
It's difficult to know if it's correct or not, as A1 is just one value from the final result. The final result is in the form of A1+A2-A3, where all values have similar integrad form approximately. I increased the working precision to 40 but I still get the "error" message! When I combined all the results, I got some negative values. This shouldn't happen, as the final value must be between 0 and 0.5.
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 13 ·
Replies
13
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 5 ·
Replies
5
Views
4K