主要内容

vpaintegral

Numerical integration using variable precision

描述

example

vpaintegral(f,A,B)numerically approximatesfatob。这default variablexinf被发现symvar

vpaintegral(f,[a b])is equal tovpaintegral(f,a,b)

example

vpaintegral(f,x,A,B)使用集成变量执行数字集成x

example

vpaintegral(___,Name,Value)使用一个或多个指定的其他选项Name,Value对论点。

例子

Numerically Integrate Symbolic Expression

数值整合符号表达式x^21to2

Syms x Vpaintegral(x ^ 2,1,2)
ans = 2.33333

Numerically Integrate Symbolic Function

Numerically integrate the symbolic functiony(x) =x21to2

ysms y(x)y(x)= x ^ 2;vpaintegral(y,1,2)
ans = 2.33333

高精度数值集成

vpaintegral使用MATLAB时使用可变精度算术®㈡egralfunction uses double-precision arithmetic. Using the default values of tolerance,vpaintegralcan handle values that cause the MATLAB㈡egralfunction to overflow or underflow.

整合besseli(5,25*u).*exp(-u*25)by using both㈡egralvpaintegral。这㈡egralfunction returnsNaN并在此时发出警告vpaintegralreturns the correct result.

syms u x 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)
警告:遇到无限或不值的值。使用隔膜= NaN使用vppaintegral = 0.688424

Increase Precision Using Tolerances

digits功能不会影响vpaintegral。Instead, increase the precision ofvpainterby decreasing the integration tolerances. Conversely, increase the speed of numerical integration by increasing the tolerances. Control the tolerance used byvpaintegralby changing the relative toleranceRELTOL.和绝对的宽容AbsTol, which affect the integration through the condition

| Q I | 最大限度 ( A b s T o l , | Q | · R e l T o l ) where Q = 计算积分 I = 精确积分

Numerically integrateBesselj(0,x)0toPI.,通过设置到32个重要的数字RELTOL.to10^(-32)。Turn offAbsTolby setting it to0

Syms X vpaintegral(贝塞尔夫(0,x),[0 pi],'Reltol',1e-32,'Abstol',0)
ans = 1.3475263146739901712314731279612

Using lower tolerance values increases precision at the cost of speed.

Complex Path Integration Using Waypoints

整合1 /(2 * Z-1)over the triangular path from0to1 + 1ito1-1iback to0by specifying waypoints.

syms z vpaintegral(1 /(2 * z-1),[0 0],'waypoints',[1 + 1i 1-1i])
ANS =  -  8.67362E-19  -  3.14159i

通过更改航路点的顺序并交换限制,改变结果的顺序来逆转积分的方向。

Multiple Integrals

Perform multiple integration by nesting calls tovpaintegral。整合

1 2 1 3 x y d x d y

syms x y vpaintegral(vpaintegral(x*y, x, [1 3]), y, [-1 2])
ans = 6.0

这limits of integration can be symbolic expressions or functions. Integrate over the triangular region0 ≤x≤1.|y| < xby specifying the limits of the integration overyin terms ofx

vpaintegral(vpaintegral(sin(x-y)/(x-y), y, [-x x]), x, [0 1])
ANS = 0.89734.

Input Arguments

全部收缩

表达或功能集成, specified as a symbolic number, variable, vector, matrix, multidimensional array, function, or expression.

集成的限制,指定为两个数字,符号数字,符号变量,符号函数或符号表达式的列表。

一体化variable, specified as a symbolic variable. Ifxis not specified, the integration variable is found bysymvar

Name-Value Arguments

Specify optional comma-separated pairs ofName,Value论点。Nameis the argument name and价值是相应的价值。Name必须出现在引号内。您可以以任何顺序指定多个名称和值对参数name1,value1,...,namen,valuen

例子:'RelTol',1e-20

相对误差容差,指定为正实数。默认为1e-6。这RELTOL.argument determines the accuracy of the integration only if R e l T o l · | Q | > A b s T o l , whereQis the calculated integral. In this case,vpaintegralsatisfies the condition | Q I | R e l T o l · | Q | , whereI是确切的积分价值。只使用RELTOL.和turn offAbsTol, setAbsTolto0

例子:1e-8

Absolute error tolerance, specified as a non-negative real number. The default is1e-10AbsTol确定集成的准确性 A b s T o l > R e l T o l · | Q | , whereQis the calculated integral. In this case,vpaintegralsatisfies the condition | Q I | A b s T o l , whereI是确切的积分价值。To turn offAbsTol并仅使用RELTOL., setAbsTolto0

例子:1e-12

集成路径, specified as a vector of numbers, or as a vector of symbolic numbers, expressions, or functions.vpaintegral㈡egrates along the sequence of straight-line paths (lower limit to the first waypoint, from the first to the second waypoint, and so on) and finally from the last waypoint to the upper limit. For contour integrals, set equal lower and upper limits and define the contour using waypoints.

输入的最大评估, specified as a positive integer or a positive symbolic integer. The default value is10 ^ 5.。如果评估的数量f大于MaxFunctionCalls, thenvpaintegral抛出错误。对于无限制的评估,设置MaxFunctionCallstoinf

提示

  • 确保输入是可集成的。如果输入不可集成,则输出vpaintegralis unpredictable.

  • digits功能不会影响vpaintegral。To increase precision, use theRELTOL.AbsTol代词。

See Also

|||

Topics

Introduced in R2016b