|
Q = quadv(fun,a,b)
Q = quadv(fun,a,b,tol)
Q = quadv(fun,a,b,tol,trace)
[Q,fcnt] = quadv(...)
Q = quadv(fun,a,b) approximates the integral of the complex array-valued function fun from a to b to within an error of 1.e-6 using recursive adaptive Simpson quadrature. fun is a function handle. See Function Handles in the MATLAB® Programming documentation for more information. The function Y = fun(x) should accept a scalar argument x and return an array result Y, whose components are the integrands evaluated at x. Limits a and b must be finite.
, in the MATLAB Mathematics documentation, explains how to provide addition parameters to the function fun, if necessary.
Q = quadv(fun,a,b,tol) uses the absolute error tolerance tol for all the integrals instead of the default, which is 1.e-6.
Note The same tolerance is used for all components, so the results obtained with quadv are usually not the same as those obtained with quad on the individual components. |
Q = quadv(fun,a,b,tol,trace) with non-zero trace shows the values of [fcnt a b-a Q(1)] during the recursion.
[Q,fcnt] = quadv(...) returns the number of function evaluations.
The list below contains information to help you determine which quadrature function in MATLAB to use:
The quad function may be most efficient for low accuracies with nonsmooth integrands.
The quadl function may be more efficient than quad at higher accuracies with smooth integrands.
The quadgk function may be most efficient for high accuracies and oscillatory integrands. It supports infinite intervals and can handle moderate singularities at the endpoints. It also supports contour integration along piecewise linear paths.
The quadv function vectorizes quad for an array-valued fun.
If the interval is infinite, [a,Inf), then for the integral of fun(x) to exist, fun(x) must decay as x approaches infinity, and quadgk requires it to decay rapidly. Special methods should be used for oscillatory functions on infinite intervals, but quadgk can be used if fun(x) decays fast enough.
The quadgk function will integrate functions that are singular at finite endpoints if the singularities are not too strong. For example, it will integrate functions that behave at an endpoint c like log|x-c| or |x-c|p for p >= -1/2. If the function is singular at points inside (a,b), write the integral as a sum of integrals over subintervals with the singular points as endpoints, compute them with quadgk, and add the results.
For the parameterized array-valued function myarrayfun, defined by
function Y = myarrayfun(x,n)
Y = 1./((1:n)+x);
the following command integrates myarrayfun, for the parameter value n = 10 between a = 0 and b = 1:
Qv = quadv(@(x)myarrayfun(x,10),0,1);
The resulting array Qv has 10 elements estimating Q(k) = log((k+1)./(k)), for k = 1:10.
The entries in Qv are slightly different than if you compute the integrals using quad in a loop:
for k = 1:10
Qs(k) = quadv(@(x)myscalarfun(x,k),0,1);
end
where myscalarfun is:
function y = myscalarfun(x,k)
y = 1./(k+x);
|手机版|搜索|焦点光学|光电工程师社区
( 鄂ICP备17021725号-1 鄂网安备42011102000821号 )
Copyright 2015 光电工程师社区 版权所有 All Rights Reserved.
申明:本站为非盈利性公益个人网站,已关闭注册功能,本站所有内容均为网络收集整理,不代表本站立场。如您对某些内容有质疑或不快,请及时联系我们处理!
© 2001-2022 光电工程师社区 网站备案号:鄂ICP备17021725号 网站公安备案号:鄂42011102000821号 Powered by Discuz! X3.2
GMT+8, 2025-8-2 13:45