Mathematica: Printing Numeric Result

Click For Summary
SUMMARY

The discussion focuses on evaluating complex integrals in Mathematica, specifically how to force numeric evaluation for integrals involving square roots. The user encountered performance issues, with calculations taking several minutes. A solution was provided using the NIntegrate function, which significantly reduces computation time when a numeric value for the variable 'r' is specified. The example demonstrates that setting r to 1 allows for rapid evaluation of the integral.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of numerical integration techniques, specifically NIntegrate
  • Basic knowledge of calculus, particularly integrals and derivatives
  • Experience with variable manipulation in mathematical expressions
NEXT STEPS
  • Explore the Mathematica documentation on NIntegrate for advanced usage
  • Learn about performance optimization techniques in Mathematica
  • Investigate the use of symbolic versus numeric evaluation in Mathematica
  • Study examples of complex integral calculations in Mathematica
USEFUL FOR

Mathematica users, physicists, and mathematicians dealing with complex integrals and seeking to improve computation efficiency.

Joel_662
Messages
1
Reaction score
0
Hey,

So I am fairly new to Mathematica (and the physics forums too). I am having a problem with mathematica not calculating the numeric result to an very complex integral. My question is, how do I force it to evaluate the integral as a number? I'm assuming that the integral of a square root is possible in mathematica as i checked the help files and it seems to suggest it is. I have tried the evaluation both with and without using n[A] which seems to be the suggested method of forcing a numeric evaluation.

K=1
R=1
VM=1
L=1
radius=1
z=-0.000000*x^6 - 0.000000*x^5 + 0.000049*x^4 + 0.000115*x^3 - 0.018528*x^2 - 0.033042*x + 2.964166
dzdx=D[z,x]
absdzdx=Abs[dzdx]
sqrtfactor=Sqrt[1+dzdx^2]
A=2*Pi*K*R*VM*L*(Integrate[(6.5+4.56*(absdzdx)+0.654*(absdzdx)^2)*x*sqrtfactor,{x,0,r}])*((2*Pi*\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(r\)]\(\((x*sqrtfactor)\) \[DifferentialD]x\)\))/10000)


I have tried to break up the calculations so that mathematica doesn't take to long to calculate it but it still seems to take at least 3 or 4 mins of running before it displays an answer. The variables do unfortunately need to stay separate as they will be changed. I apologise in advance if it is just some stupid error of mine.
 
Physics news on Phys.org
If you can supply a numeric value for r, perhaps like this

r = 1;

then this

In[1]:= A=2*Pi*K*R*VM*L* NIntegrate[((6.5+4.56*absdzdx+0.654*absdzdx^2)* x*sqrtfactor),{x,0,r}]*
2*Pi/10000*NIntegrate[x*sqrtfactor,{x,0,r}]]

Out[1]= 0.00669876

evaluates in a fraction of a second.

If you cannot provide a numeric value for r then I doubt you will get a satisfactory answer.
 
Last edited:

Similar threads

  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K