Previous Page Next Page Contents

numeric::int -- numerical integration (the float attribute of int)

Introduction

numeric::int(f(x), x = a..b, ..) computes a numerical approximation of int(f(x), x = a..b).

Call(s)


numeric::int(f(x), x = a..b <, options>)
float(hold(int)(f(x), x = a..b <, options>))
float(freeze(int)(f(x), x = a..b <, options>))

Parameters

f(x) - expression in x
x - identifier or indexed identifier.
a,b - arbitrary expressions.

Options

options - all options of numeric::quadrature can be used.

Returns

a floating point number or an unevaluated int(f(x), x = a..b <, options>), if the integral cannot be evaluated numerically.

Related Functions

int, numeric::quadrature

Details

Example 1

We demonstrate some equivalent calls for numerical integration:

>> numeric::int(exp(x^2), x = -1..1),
   float(hold(int)(exp(x^2), x = -1..1)),
   float(freeze(int)(exp(x^2), x = -1..1)),
   numeric::quadrature(exp(x^2), x = -1..1) 
            2.925303492, 2.925303492, 2.925303492, 2.925303492
>> numeric::int(max(1/10, cos(PI*x)), x = -2..0.0123),
   float(hold(int)(max(1/10, cos(PI*x)), x = -2..0.0123)),
   float(freeze(int)(max(1/10, cos(PI*x)), x = -2..0.0123)),
   numeric::quadrature(max(1/10, cos(PI*x)), x = -2..0.0123) 
          0.7521024709, 0.7521024709, 0.7521024709, 0.7521024709
>> numeric::int(exp(-x^2), x = -2..infinity),
   float(hold(int)(exp(-x^2), x = -2..infinity)),
   float(freeze(int)(exp(-x^2), x = -2..infinity)),
   numeric::quadrature(exp(-x^2), x = -2..infinity) 
            1.768308316, 1.768308316, 1.768308316, 1.768308316
>> numeric::int(sin(x)/x, x = -1..10, GaussLegendre = 5),
   float(hold(int)(sin(x)/x, x = -1..10, GaussLegendre = 5)),
   float(freeze(int)(sin(x)/x, x = -1..10, GaussLegendre = 5)),
   numeric::quadrature(sin(x)/x, x = -1..10, GaussLegendre = 5) 
            2.604430665, 2.604430665, 2.604430665, 2.604430665

The calls numeric::int(..), float(hold(int)(..)) and numeric::quadrature(..) are equivalent in multiple numerical integrations, too:

>> numeric::int(numeric::int(x*y, x = 0..y), y = 0..1),
   numeric::int(numeric::quadrature(x*y, x = 0..y), y = 0..1),
   float(freeze(int)(numeric::int(x*y, x = 0..y), y = 0..1)),
   float(hold(int)(numeric::quadrature(x*y, x = 0..y), y = 0..1)),
   numeric::quadrature(numeric::int(x*y, x = 0..y), y = 0..1),
   numeric::quadrature(numeric::quadrature(x*y, x = 0..y), y = 0..1) 
                 0.125, 0.125, 0.125, 0.125, 0.125, 0.125

Example 2

The following integral do not exist. Consequently, numerical integration runs into problems:

>> numeric::quadrature(exp(x^2), x = 0..infinity) 
      Error: Overflow/underflow in arithmetical operation;
      during evaluation of 'exp::float'

Note that numeric::int handles errors produced by numeric::quadrature and returns an unevaluated call to int:

>> numeric::int(exp(x^2), x = 0..infinity) 
                                2
                       int(exp(x ), x = 0..infinity)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000