Matlab integration function

Integration in MATLAB

Integration is defined as the process of finding the anti derivative of a function. It is used to calculate area, volume, displacement, and many more. In this article, we will see how to perform integration on expressions in MATLAB.

There are two types of Integration:

• Indefinite integral: Let f(x) be a function. Then the family of all antiderivatives is called the indefinite integral of a function f(x) and it is denoted by ∫f(x)dx. The symbol ∫f(x)dx is read as the indefinite integral of f(x) with respect to x. Thus ∫f(x)dx= ∅(x) + C. Thus, the process of finding the indefinite integral of a function is called the integration of the function.
• Definite integrals: Definite integrals are the extension after indefinite integrals, definite integrals have limits [a, b]. It gives the area of a curve bounded between given limits. It is denoted by ∫f(x)dx under the limit of a and b, it denotes the area of curve F(x) bounded between a and b, where a is the lower limit and b is the upper limit.

Before moving to Integration, we first need to assign an expression to a variable in MATLAB which can be done by using the inline() function. It creates a function to contain the expression.

Syntax:

f = inline(expr, var)

Here f is the inline function created to contain the expression, expr can be any expression and var is the variable in that expression.

Now, after assigning the expression using the inline() function, we need to integrate the expression. This task can be performed using the int() function. The int() function is used to integrate expressions in MATLAB.

Syntax:

int(f,v)

Parameters:

Indefinite Integral

Indefinite integrals are those integrals that do not have any limit and containing an arbitrary constant.

Step-wise Approach:

Step 1: Use Inline function for the creation of the function for integration.

Matlab

Step 2: Create a symbolic function.

Step 3: Use int to find out the integration.

Complete Code:

Output

Definite Integral

Definite integrals are those integrals that have an upper limit and a lower limit. Let’s take the above example and add the limits.

Step-wise Approach:

Step 1: Use the Inline function for the creation of the function for integration.

Matlab

Step 2: Create a symbolic function.

Step 3: Use int to find out the integration and pass down the values of the lower limit, upper limit.

Complete Code:

Matlab

Output:

Sours: https://www.geeksforgeeks.org/integration-in-matlab/

An integral is a mathematical measure that combines infinitesimal data points. Integrals have a broad range of applications in all engineering disciplines.

Types of Integrals

In general, integrals can be either definite or indefinite. Definite integrals represent functions with bounded upper and lower limits, whereas indefinite Integrals represent functions without limits.

The following example shows an indefinite integral:

$$I= \int3x^2 dx=x^3+c$$

where ‘c’ is a constant.

A definite integral for the same equation must have defined limits. For example, we can integrate the above equation with limits [-2, 2] as follows:

$$I= \int_{-2}^2 3x^2 dx=(2^3+c)-(-2^3+c)=16$$

You can use MATLAB® and Symbolic Math Toolbox™ to calculate integrals numerically and symbolically.

Examples of Integral Applications

1. Area under curves:

You can calculate the area under two curves using integrals. For example, we define two curves,

$$x1=y^2-1$$

$$x2=1- y^2$$

and calculate the area under the curves as follows:

$$A=∫(x2-x1) dy=\frac{(-2y(y^2-3))}{3}$$

The area under the curve$$'A’$$ here is a function of $$'y’$$ because we did not specify limits. If we define the limits as $$[-1, 1]$$, the integral returns a value of:

$$A=8/3.$$

1. Volume of objects:

You can use integrals to calculate the volume of objects. For example, you can derive the volume of a sphere by starting with a function:

$$f(x)=√(r^2-x^2 )$$

which depicts a semi-circle with radius ‘r.’ Rotating this semi-circle around the x-axis would yield a sphere.

The area of the semi-circle would be

$$A=πf(x)^2$$

Integrating this area with limits [-r, +r] would give us the volume of the sphere:

$$V= ∫_{-r}^{+r} A dx=\frac{(4πr^3)}{3}$$

1. Velocity of a moving object:

You can find the velocity of an object by finding the definite integral of the object’s acceleration with respect to time, because acceleration is simply defined as the rate of change of velocity over time.

$$∆Vel= ∫Acc \; dt$$

Techniques to Calculate Integrals

You can calculate integrals numerically using techniques such as:

For more information on the numeric and symbolic calculations of integrals, see MATLAB® and Symbolic Math Toolbox™.

Sours: https://www.mathworks.com/discovery/integral.html

Select a Web Site

Integration

If is a symbolic expression, then

attempts to find another symbolic expression, , so that   . That is, returns the indefinite integral or antiderivative of (provided one exists in closed form). Similar to differentiation,

uses the symbolic object as the variable of integration, rather than the variable determined by . See how works by looking at this table.

Mathematical Operation

MATLAB® Command

or

or

g  =  cos(at + b)

or

or

In contrast to differentiation, symbolic integration is a more complicated task. A number of difficulties can arise in computing the integral:

• The antiderivative, , may not exist in closed form.

• The antiderivative may define an unfamiliar function.

• The antiderivative may exist, but the software can't find it.

• The software could find the antiderivative on a larger computer, but runs out of time or memory on the available machine.

Nevertheless, in many cases, MATLAB can perform symbolic integration successfully. For example, create the symbolic variables

The following table illustrates integration of expressions containing those variables.

f

int(f)

ans = piecewise(n == -1, log(x), n ~= -1,... x^(n + 1)/(n + 1))
syms a b theta f = sin(a*theta+b);
ans = -cos(b + a*theta)/a
ans = (pi^(1/2)*erf(x))/2

In the last example, , there is no formula for the integral involving standard calculus expressions, such as trigonometric and exponential functions. In this case, MATLAB returns an answer in terms of the error function .

If MATLAB is unable to find an answer to the integral of a function , it just returns .

Definite integration is also possible.

Definite Integral

Command

f

a, b

int(f, a, b)

syms x f = log(x)*sqrt(x);
syms z f = besselj(1,z)^2;
ans = hypergeom([3/2, 3/2],... [2, 5/2, 3], -1)/12

For the Bessel function () example, it is possible to compute a numerical approximation to the value of the integral, using the function. The commands

syms z a = int(besselj(1,z)^2,0,1)

return

a = hypergeom([3/2, 3/2], [2, 5/2, 3], -1)/12

and the command

returns

Integration with Real Parameters

One of the subtleties involved in symbolic integration is the “value” of various parameters. For example, if a is any positive real number, the expression

is the positive, bell shaped curve that tends to 0 as x tends to ±∞. You can create an example of this curve, for a = 1/2.

syms x a = sym(1/2); f = exp(-a*x^2); fplot(f)

However, if you try to calculate the integral

without assigning a value to a, MATLAB assumes that a represents a complex number, and therefore returns a piecewise answer that depends on the argument of a. If you are only interested in the case when a is a positive real number, use to set an assumption on :

Now you can calculate the preceding integral using the commands

syms x f = exp(-a*x^2); int(f, x, -inf, inf)

This returns

Integration with Complex Parameters

To calculate the integral

for complex values of , enter

syms a x f = 1/(a^2 + x^2); F = int(f, x, -inf, inf)

Use to clear the all assumptions on variables. For more information about symbolic variables and assumptions on them, see Delete Symbolic Objects and Their Assumptions.

The preceding commands produce the complex output

The function is defined as:

To evaluate at , enter

High-Precision Numerical Integration Using Variable-Precision Arithmetic

High-precision numerical integration is implemented in the function of the Symbolic Math Toolbox™. uses variable-precision arithmetic in contrast to the MATLAB function, which uses double-precision arithmetic.

Integrate by using both and . The function returns and issues a warning while returns the correct result.

syms u f = besseli(5,25*x).*exp(-x*25); fun = @(u)besseli(5,25*u).*exp(-u*25); usingIntegral = integral(fun, 0, 30) usingVpaintegral = vpaintegral(f, 0, 30)
Warning: Infinite or Not-a-Number value encountered. usingIntegral = NaN usingVpaintegral = 0.688424

Sours: https://www.mathworks.com/help/symbolic/integration.html

int

Description

example

computes the indefinite integral of . uses the default integration variable determined by (). If is a constant, then the default integration variable is .

example

computes the indefinite integral of with respect to the symbolic scalar variable .

example

computes the definite integral of from to . uses the default integration variable determined by (). If is a constant, then the default integration variable is .

is equivalent to .

example

computes the definite integral of with respect to the symbolic scalar variable from to .

is equivalent to .

example

specifies additional options using one or more pair arguments. For example, specifies that applies additional simplifications to the integrand.

collapse all

Indefinite Integral of Univariate Expression

Define a univariate expression.

syms x expr = -2*x/(1+x^2)^2;

Find the indefinite integral of the univariate expression.

Indefinite Integrals of Multivariate Function

Define a multivariate function with variables and .

syms xz f(x,z) = x/(1+z^2);

Find the indefinite integrals of the multivariate expression with respect to the variables and .

Fx(x, z) =
Fz(x, z) =

If you do not specify the integration variable, then uses the first variable returned by as the integration variable.

Definite Integrals of Symbolic Expressions

Integrate a symbolic expression from to .

syms x expr = x*log(1+x); F = int(expr,[0 1])

Integrate another expression from to .

syms t F = int(2*x,[sin(t) 1])

When cannot compute the value of a definite integral, numerically approximate the integral by using .

syms x f = cos(x)/sqrt(1 + x^2); Fint = int(f,x,[0 10])
Fint =
Fvpa =

To approximate integrals directly, use instead of . The function is faster and provides control over integration tolerances.

Fvpaint = vpaintegral(f,x,[0 10])

Integrals of Matrix Elements

Define a symbolic matrix containing four expressions as its elements.

syms axtz M = [exp(t) exp(a*t); sin(t) cos(t)]
M =

Find indefinite integrals of the matrix element-wise.

F =

Apply IgnoreAnalyticConstraints

Define a symbolic function and compute its indefinite integral.

syms f(x) f(x) = acos(cos(x)); F = int(f,x)
F(x) =

By default, uses strict mathematical rules. These rules do not let rewrite as .

If you want a simple practical solution, set to .

F = int(f,x,'IgnoreAnalyticConstraints',true)

Ignore Special Cases

Define a symbolic expression and compute its indefinite integral with respect to the variable .

F =

By default, returns the general results for all values of the other symbolic parameter . In this example, returns two integral results for the case and .

To ignore special cases of parameter values, set to . With this option, ignores the special case and returns the solution for .

F = int(x^t,x,'IgnoreSpecialCases',true)

Find Cauchy Principal Value

Define a symbolic function that has a pole at .

Compute the definite integral of this function from to . Since the integration interval includes the pole, the result is not defined.

However, the Cauchy principal value of the integral exists. To compute the Cauchy principal value of the integral, set to .

F = int(f,[0 2],'PrincipalValue',true)

Unevaluated Integral and Integration by Parts

Find the integral of .

Define the integral without evaluating it by setting the option to .

syms xg(y) F = int(x*exp(x),'Hold',true)

You can apply integration by parts to by using the function. Use as the differential to be integrated.

G = integrateByParts(F,exp(x))

To evaluate the integral in , use the function to ignore the option.

Compare the result to the integration result returned by without setting the option.

Approximate Indefinite Integrals

If cannot compute a closed form of an integral, then it returns an unresolved integral.

syms f(x) f(x) = sin(sinh(x)); F = int(f,x)
F(x) =

You can approximate the integrand function as polynomials by using the Taylor expansion. Apply to expand the integrand function as polynomials around . Compute the integral of the approximated polynomials.

fTaylor = taylor(f,x,'ExpansionPoint',0,'Order',10)
fTaylor(x) =
Fapprox(x) =

collapse all

— Integrandsymbolic expression | symbolic function | symbolic vector | symbolic matrix | symbolic number

Integrand, specified as a symbolic expression, function, vector, matrix, or number.

— Integration variablesymbolic variable

Integration variable, specified as a symbolic variable. If you do not specify this variable, uses the default variable determined by . If is a constant, then the default variable is .

— Lower boundnumber | symbolic number | symbolic variable | symbolic expression | symbolic function

Lower bound, specified as a number, symbolic number, variable, expression, or function (including expressions and functions with infinities).

— Upper boundnumber | symbolic number | symbolic variable | symbolic expression | symbolic function

Upper bound, specified as a number, symbolic number, variable, expression, or function (including expressions and functions with infinities).

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example: specifies that applies purely algebraic simplifications to the integrand.

— Indicator for applying purely algebraic simplifications to integrand (default) |

Indicator for applying purely algebraic simplifications to the integrand, specified as or . If the value is , apply purely algebraic simplifications to the integrand. This option can provide simpler results for expressions, for which the direct use of the integrator returns complicated results. In some cases, it also enables to compute integrals that cannot be computed otherwise.

Using this option can lead to results not generally valid. This option applies mathematical identities that are convenient, but the results do not always hold for all values of variables.

— Indicator for ignoring special cases (default) |

Indicator for ignoring special cases, specified as or . This ignores cases that require one or more parameters to be elements of a comparatively small set, such as a fixed finite set or a set of integers.

— Indicator for returning principal value (default) |

Indicator for returning the principal value, specified as or . If the value is , compute the Cauchy principal value of the integral. In live script, the Cauchy principal value of unevaluated integral shows as the symbol.

— Indicator for unevaluated integration (default) |

Indicator for unevaluated integration, specified as or . If the value is , returns integrals without evaluating them.

Tips

• In contrast to differentiation, symbolic integration is a more complicated task. If cannot compute an integral of an expression, check for these reasons:

• The antiderivative does not exist in a closed form.

• The antiderivative exists, but cannot find it.

If cannot compute a closed form of an integral, it returns an unresolved integral.

Try approximating such integrals by using one of these methods:

• For indefinite integrals, use series expansions. Use this method to approximate an integral around a particular value of the variable.

• For definite integrals, use numeric approximations.

• For indefinite integrals, does not return a constant of integration in the result. The results of integrating mathematically equivalent expressions may be different. For example, returns , while returns , which differs from the first result by .

• For indefinite integrals, implicitly assumes that the integration variable is real. For definite integrals, restricts the integration variable to the specified integration interval. If one or both integration bounds and are not numeric, assumes that unless you explicitly specify otherwise.

Algorithms

When you use , applies these rules:

• log(a) + log(b) = log(a·b) for all values of a and b. In particular, the following equality is valid for all values of a, b, and c:

(a·b)c = ac·bc.

• log(ab) = b·log(a) for all values of a and b. In particular, the following equality is valid for all values of a, b, and c:

(ab)c = ab·c.

• If f and g are standard mathematical functions and f(g(x)) = x for all small positive numbers, then f(g(x)) = x is assumed to be valid for all complex values x. In particular:

• log(ex) = x

• asin(sin(x)) = x, acos(cos(x)) = x, atan(tan(x)) = x

• asinh(sinh(x)) = x, acosh(cosh(x)) = x, atanh(tanh(x)) = x

• Wk(x·ex) = x for all branch indices k of the Lambert W function.

Introduced before R2006a

You have a modified version of this example. Do you want to open this example with your edits?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Sours: https://www.mathworks.com/help/symbolic/int.html

MATLAB - Integration

Integration deals with two essentially different types of problems.

• In the first type, derivative of a function is given and we want to find the function. Therefore, we basically reverse the process of differentiation. This reverse process is known as anti-differentiation, or finding the primitive function, or finding an indefinite integral.

• The second type of problems involve adding up a very large number of very small quantities and then taking a limit as the size of the quantities approaches zero, while the number of terms tend to infinity. This process leads to the definition of the definite integral.

Definite integrals are used for finding area, volume, center of gravity, moment of inertia, work done by a force, and in numerous other applications.

Finding Indefinite Integral Using MATLAB

By definition, if the derivative of a function f(x) is f'(x), then we say that an indefinite integral of f'(x) with respect to x is f(x). For example, since the derivative (with respect to x) of x2 is 2x, we can say that an indefinite integral of 2x is x2.

In symbols −

f'(x2) = 2x, therefore,

∫ 2xdx = x2.

Indefinite integral is not unique, because derivative of x2 + c, for any value of a constant c, will also be 2x.

This is expressed in symbols as −

∫ 2xdx = x2 + c.

Where, c is called an 'arbitrary constant'.

MATLAB provides an int command for calculating integral of an expression. To derive an expression for the indefinite integral of a function, we write −

int(f);

For example, from our previous example −

syms x int(2*x)

MATLAB executes the above statement and returns the following result −

ans = x^2

Example 1

In this example, let us find the integral of some commonly used expressions. Create a script file and type the following code in it −

syms x n int(sym(x^n)) f = 'sin(n*t)' int(sym(f)) syms a t int(a*cos(pi*t)) int(a^x)

When you run the file, it displays the following result −

ans = piecewise([n == -1, log(x)], [n ~= -1, x^(n + 1)/(n + 1)]) f = sin(n*t) ans = -cos(n*t)/n ans = (a*sin(pi*t))/pi ans = a^x/log(a)

Example 2

Create a script file and type the following code in it −

syms x n int(cos(x)) int(exp(x)) int(log(x)) int(x^-1) int(x^5*cos(5*x)) pretty(int(x^5*cos(5*x))) int(x^-5) int(sec(x)^2) pretty(int(1 - 10*x + 9 * x^2)) int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2) pretty(int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2))

Note that the pretty function returns an expression in a more readable format.

When you run the file, it displays the following result −

ans = sin(x) ans = exp(x) ans = x*(log(x) - 1) ans = log(x) ans = (24*cos(5*x))/3125 + (24*x*sin(5*x))/625 - (12*x^2*cos(5*x))/125 + (x^4*cos(5*x))/5 - (4*x^3*sin(5*x))/25 + (x^5*sin(5*x))/5 2 4 24 cos(5 x) 24 x sin(5 x) 12 x cos(5 x) x cos(5 x) ----------- + ------------- - -------------- + ------------ 3125 625 125 5 3 5 4 x sin(5 x) x sin(5 x) ------------- + ----------- 25 5 ans = -1/(4*x^4) ans = tan(x) 2 x (3 x - 5 x + 1) ans = - (7*x^6)/12 - (3*x^5)/5 + (5*x^4)/8 + x^3/2 6 5 4 3 7 x 3 x 5 x x - ---- - ---- + ---- + -- 12 5 8 2

Finding Definite Integral Using MATLAB

By definition, definite integral is basically the limit of a sum. We use definite integrals to find areas such as the area between a curve and the x-axis and the area between two curves. Definite integrals can also be used in other situations, where the quantity required can be expressed as the limit of a sum.

The int function can be used for definite integration by passing the limits over which you want to calculate the integral.

To calculate

we write,

int(x, a, b)

For example, to calculate the value of we write −

int(x, 4, 9)

MATLAB executes the above statement and returns the following result −

ans = 65/2

Following is Octave equivalent of the above calculation −

pkg load symbolic symbols x = sym("x"); f = x; c = [1, 0]; integral = polyint(c); a = polyval(integral, 9) - polyval(integral, 4); display('Area: '), disp(double(a));

Octave executes the code and returns the following result −

Area: 32.500

An alternative solution can be given using quad() function provided by Octave as follows −

pkg load symbolic symbols f = inline("x"); [a, ierror, nfneval] = quad(f, 4, 9); display('Area: '), disp(double(a));

Octave executes the code and returns the following result −

Area: 32.500

Example 1

Let us calculate the area enclosed between the x-axis, and the curve y = x3−2x+5 and the ordinates x = 1 and x = 2.

The required area is given by −

Create a script file and type the following code −

f = x^3 - 2*x +5; a = int(f, 1, 2) display('Area: '), disp(double(a));

When you run the file, it displays the following result −

a = 23/4 Area: 5.7500

Following is Octave equivalent of the above calculation −

pkg load symbolic symbols x = sym("x"); f = x^3 - 2*x +5; c = [1, 0, -2, 5]; integral = polyint(c); a = polyval(integral, 2) - polyval(integral, 1); display('Area: '), disp(double(a));

Octave executes the code and returns the following result −

Area: 5.7500

An alternative solution can be given using quad() function provided by Octave as follows −

pkg load symbolic symbols x = sym("x"); f = inline("x^3 - 2*x +5"); [a, ierror, nfneval] = quad(f, 1, 2); display('Area: '), disp(double(a));

Octave executes the code and returns the following result −

Area: 5.7500

Example 2

Find the area under the curve: f(x) = x2 cos(x) for −4 ≤ x ≤ 9.

Create a script file and write the following code −

f = x^2*cos(x); ezplot(f, [-4,9]) a = int(f, -4, 9) disp('Area: '), disp(double(a));

When you run the file, MATLAB plots the graph −

The output is given below −

a = 8*cos(4) + 18*cos(9) + 14*sin(4) + 79*sin(9) Area: 0.3326

Following is Octave equivalent of the above calculation −

pkg load symbolic symbols x = sym("x"); f = inline("x^2*cos(x)"); ezplot(f, [-4,9]) print -deps graph.eps [a, ierror, nfneval] = quad(f, -4, 9); display('Area: '), disp(double(a));
Sours: https://www.tutorialspoint.com/matlab/matlab_integration.htm
MATLAB for Engineers - Introduction to User-Defined Functions

integral

Description

example

numerically integrates function from to using global adaptive quadrature and default error tolerances.

example

specifies additional options with one or more pair arguments. For example, specify followed by a vector of real or complex numbers to indicate specific points for the integrator to use.

collapse all

Improper Integral

Create the function .

fun = @(x) exp(-x.^2).*log(x).^2;

Evaluate the integral from to .

Parameterized Function

Create the function with one parameter, .

fun = @(x,c) 1./(x.^3-2*x-c);

Evaluate the integral from to at .

q = integral(@(x) fun(x,5),0,2)

Singularity at Lower Limit

Create the function .

Evaluate the integral from to with the default error tolerances.

format long q1 = integral(fun,0,1)

Evaluate the integral again, this time with 12 decimal places of accuracy. Set to zero so that only attempts to satisfy the absolute error tolerance.

q2 = integral(fun,0,1,'RelTol',0,'AbsTol',1e-12)

Complex Contour Integration Using Waypoints

Create the function .

Integrate in the complex plane over the triangular path from to to to by specifying waypoints.

q = integral(fun,0,0,'Waypoints',[1+1i,1-1i])

Vector-Valued Function

Create the vector-valued function and integrate from to . Specify to evaluate the integral of an array-valued or vector-valued function.

fun = @(x)sin((1:5)*x); q = integral(fun,0,1,'ArrayValued',true)
q = 1×5 0.4597 0.7081 0.6633 0.4134 0.1433

Improper Integral of Oscillatory Function

Create the function .

fun = @(x)x.^5.*exp(-x).*sin(x);

Evaluate the integral from to , adjusting the absolute and relative tolerances.

format long q = integral(fun,0,Inf,'RelTol',1e-8,'AbsTol',1e-13)

collapse all

— Integrandfunction handle

Integrand, specified as a function handle, which defines the function to be integrated from to .

For scalar-valued problems, the function must accept a vector argument, , and return a vector result, . This generally means that must use array operators instead of matrix operators. For example, use () rather than (). If you set the option to , then must accept a scalar and return an array of fixed size.

— Lower limit of xreal number | complex number

Lower limit of x, specified as a real (finite or infinite) scalar value or a complex (finite) scalar value. If either or are complex, then approximates the path integral from to over a straight line path.

Data Types: |
Complex Number Support: Yes

— Upper limit of xreal number | complex number

Upper limit of x, specified as a real number (finite or infinite) or a complex number (finite). If either or are complex, approximates the path integral from to over a straight line path.

Data Types: |
Complex Number Support: Yes

Name-Value Arguments

Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .

Example: sets the absolute error tolerance to approximately 12 decimal places of accuracy.

— Absolute error tolerance (default) | nonnegative real number

Absolute error tolerance, specified as the comma-separated pair consisting of and a nonnegative real number. uses the absolute error tolerance to limit an estimate of the absolute error, |qQ|, where q is the computed value of the integral and Q is the (unknown) exact value. might provide more decimal places of precision if you decrease the absolute error tolerance.

Note

and work together. might satisfy the absolute error tolerance or the relative error tolerance, but not necessarily both. For more information on using these tolerances, see the Tips section.

Example: sets the absolute error tolerance to approximately 12 decimal places of accuracy.

Data Types: |

— Relative error tolerance (default) | nonnegative real number

Relative error tolerance, specified as the comma-separated pair consisting of and a nonnegative real number. uses the relative error tolerance to limit an estimate of the relative error, |qQ|/|Q|, where q is the computed value of the integral and Q is the (unknown) exact value. might provide more significant digits of precision if you decrease the relative error tolerance.

Note

and work together. might satisfy the relative error tolerance or the absolute error tolerance, but not necessarily both. For more information on using these tolerances, see the Tips section.

Example: sets the relative error tolerance to approximately 9 significant digits.

Data Types: |

— Array-valued function flag or (default) | or

Array-valued function flag, specified as the comma-separated pair consisting of and a numeric or logical () or (). Set this flag to or to indicate that is a function that accepts a scalar input and returns a vector, matrix, or N-D array output.

The default value of indicates that is a function that accepts a vector input and returns a vector output.

Example: indicates that the integrand is an array-valued function.

— Integration waypointsvector

Integration waypoints, specified as the comma-separated pair consisting of and a vector of real or complex numbers. Use waypoints to indicate points in the integration interval that you would like the integrator to use in the initial mesh:

• Add more evaluation points near interesting features of the function, such as a local extrema.

• Integrate efficiently across discontinuities of the integrand by specifying the locations of the discontinuities.

• Perform complex contour integrations by specifying complex numbers as waypoints. If , , or any entry of the waypoints vector is complex, then the integration is performed over a sequence of straight line paths in the complex plane. In this case, all of the integration limits and waypoints must be finite.

Do not use waypoints to specify singularities. Instead, split the interval and add the results of separate integrations with the singularities at the endpoints.

Example: specifies two complex waypoints along the interval of integration.

Data Types: |
Complex Number Support: Yes

Tips

• The function attempts to satisfy:

abs(q - Q) <= max(AbsTol,RelTol*abs(q))
where is the computed value of the integral and is the (unknown) exact value. The absolute and relative tolerances provide a way of trading off accuracy and computation time. Usually, the relative tolerance determines the accuracy of the integration. However if is sufficiently small, the absolute tolerance determines the accuracy of the integration. You should generally specify both absolute and relative tolerances together.
• If you are specifying single-precision limits of integration, or if returns single-precision results, you might need to specify larger absolute and relative error tolerances.

References

[1] L.F. Shampine “Vectorized Adaptive Quadrature in MATLAB®,” Journal of Computational and Applied Mathematics, 211, 2008, pp.131–140.

Thread-Based EnvironmentRun code in the background using MATLAB® or accelerate code with Parallel Computing Toolbox™ .

Introduced in R2012a

You have a modified version of this example. Do you want to open this example with your edits?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Sours: https://www.mathworks.com/help/matlab/ref/integral.html

Similar news:

Then louder baby, I told you louder. And stronger on the ass. Do you want it already. As strong as me.

905 906 907 908 909