Professional Documents
Culture Documents
html
q2 =
-1.000000000000010
Copy Command
Integrate in the complex plane over the triangular path from 0 to 1+1i to 1-1i to 0 by specifying waypoints.
q = integral(fun,0,0,'Waypoints',[1+1i,1-1i])
q = 0.0000 - 3.1416i
Vector-Valued Function
Create the vector-valued function f (x) = [sinx, sin2x, sin3x, sin4x, sin5x] and integrate from x=0 to x=1. Specify
'ArrayValued',true to evaluate the integral of an array-valued or vector-valued function. Try This Example
Copy Command
fun = @(x)sin((1:5)*x);
q = integral(fun,0,1,'ArrayValued',true)
q = 1×5
Copy Command
fun = @(x)x.^5.*exp(-x).*sin(x);
Evaluate the integral from x=0 to x=Inf , adjusting the absolute and relative tolerances.
format long
q = integral(fun,0,Inf,'RelTol',1e-8,'AbsTol',1e-13)
q =
-14.999999999998360
fun — Integrand
function handle
Integrand, speci�ed as a function handle, which de�nes the function to be integrated from xmin to xmax.
For scalar-valued problems, the function y = fun(x) must accept a vector argument, x, and return a vector result, y. This generally means that fun must use array
operators instead of matrix operators. For example, use .* (times) rather than * (mtimes). If you set the 'ArrayValued' option to true, then fun must accept a
scalar and return an array of �xed size.
Lower limit of x, speci�ed as a real (�nite or in�nite) scalar value or a complex (�nite) scalar value. If either xmin or xmax are complex, then integral approximates
the path integral from xmin to xmax over a straight line path.
2 of 4 12-Aug-22, 12:35 AM