Documentation

# `numeric`::`int`

Numerical integration (the Float attribute of Int )

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```numeric::int(f(`x`), `x = a .. b`, `options`)
float(holdint(f(`x`), `x = a .. b`, `options`))
float(freezeint(f(`x`), `x = a .. b`, `options`))
```

## Description

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

The calls `numeric::int(...)`, ```float ( freeze(int)(...))```, and `float ( hold(int)(...))` are equivalent.

The calls `numeric::int(...)` and `numeric::quadrature(...)` are almost equivalent: `numeric::int` calls `numeric::quadrature`. A numerical result produced by `numeric::quadrature` is returned as is. Otherwise, `hold(numeric::int)(...)` is returned.

See the help page of `numeric::quadrature` for details.

## Environment Interactions

The function is sensitive to the environment variable `DIGITS`, which determines the numerical working precision.

## Examples

### 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)```

```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)```

```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)```

```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)```

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)```

### Example 2

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

`numeric::quadrature(1/x, x = 0..infinity)`
```Warning: Precision goal not achieved after 10000 function calls. Increase 'MaxCalls' and try again for a more accurate result. [numeric::quadrature] ```

Note that `numeric::int` handles errors produced by `numeric::quadrature` and returns a symbolic call to `numeric::int`:

`numeric::int(1/x, x = 0..infinity)`

## Parameters

 `f(x)` `x` An identifier or an indexed identifier `a`, `b` arithmetical expressions

## Options

All options of `numeric::quadrature` can be used.

## Return Values

Floating point number or a symbolic call ```numeric::int(f(x), x = a..b)``` if the integral cannot be evaluated numerically.