numint
Contents: Description, Arguments, Usage, Examples, Sub-Functions, Related Functions, Source Supported Under Version: >1.00
Description Numerical integration, using midpoint approximation method
Arguments and Return Values Arguments: First input is string giving integrand function in terms of x; next two are limits of integration; fourth input specifies number of points Return Value: The approximate integral of the function over the specified range
Usage Syntax: numint("f(x)",a,b,n) "f(x)" is a string specifying the function to be integrated, in terms of x, e.g. "exp(-x^2)" or "sin(x)/x". The function MUST be in terms of x, and there cannot be any other variables, or even system constants like pi. The string can only have x, numbers (entered as numbers), and functions. See the examples below. a and b are the limits of integration. n is the number of intervals to use. Higher n (up to 5000 or so) gives a more accurate result but takes longer to evaluate. Usually the computation time difference is not noticeable. The upper useful limit to n is probably due to accumulating roundoff error. This function is only intended to provide quick approximations. If you need something really accurate, you may want to write your own function. The function's output is double format, but the computed values are NOT accurate to double precision. If no arguments are input, numint() prints its description, as shown below.
Examples dv> numint() Numerical integration (midpoint approximation) numint("f(x)",a,b,n) returns approximate integral of function f(x) with respect to x over interval [a,b] with n divisions S.Marshall 10-02-2009 0 dv> numint("sin(x)", 0, pi, 1000) 2.00000073682339 dv> numint("sin(x)", 0, pi, 2000) 2.00000026705699 dv> numint("sin(x)", 0, pi, 4000) 2.00000007551615 dv> numint("sin(x)", 0, pi, 8000) 1.99999992543316 dv> numint("pi*sin(pi*x)", 0, 1, 4000) error: Variable not found: pi Not enough arguments to function: sin() sum: No object specified 0 dv> numint("3.141593*sin(3.141593*x)", 0, 1, 4000) 2.00000007765542 |
DavinciWiki Mini-Nav Bar Contents
Contact Developers
All other topics
Related Functions
Recent Library Changes Created On: 11-18-2009 |