How to calculate an integral from 0 to infinite
Lucas
I wanna to calculate an integral from 0 to infinite , so i use this command
integrate1D( userFunc, 0, inf, 2, 0).
but the result was NaN, when i use a number 2 or any other limited variable to replace "inf", the result was right, so, i think maybe i have use "inf" in a wrong way. Does anyone know how to figure out this problem?
Thanks!
userFunc
?May 5, 2015 at 03:45 am - Permalink
variable xx
variable yy
yy = sin(xx)
return yy
end
function aa()
variable temp = 0
//print integrate1D( xx, 0, 1/temp, 2, 0 )
print integrate1D(userFunc, 0, inf, 2, 0 )
end
I tried to use 1/0 to replace
inf
, but it doesn't work.May 5, 2015 at 04:11 am - Permalink
inf
. SoNaN
would be the correct answer.Could you check whether your original function is defined at
inf
or maybe post it?HJ
May 5, 2015 at 07:40 am - Permalink
I think you need to recalibrate your notion of numerical integration. You NEVER use INF in numerical integration.
If you have infinite limit(s) in an integration problem start by quitting IGOR and take a piece of paper. Write out your integral and scale it. Simplify the integrand to the extent possible and inspect the behavior in the range of integration. If your integral converges then you should be able to replace the infinite limit with some finite (possibly large) number. Another approach that is frequently employed is a change of variable that transforms an infinite limit to a finite number.
A.G.
WaveMetrics, Inc.
May 5, 2015 at 12:19 pm - Permalink
Thanks, A. G. . You really inspire me. I will try that right now. >_<
May 5, 2015 at 08:30 pm - Permalink
Alternatively, open a symbolic math application (e.g. Maple or Mathematica or equivalent). Type in your integral. Use the functional methods in the math application to determine whether the integral of the function over the range needed has a closed-form, analytical expression or a limiting approximation.
:-)
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
May 6, 2015 at 09:52 am - Permalink