Quad

It integrates a specified function over specified limits, based on adaptive Simpson’s rule. The adaptive rule seeks to improve accuracy by adaptively selecting the size of the subintervals (as opposed to keeping it constant) within the limits of integration while evaluating the sums that make up the integral.

Syntax

I = quad(‘fun’,a,b)

where fun is a function handle representing the function to be integrated, a is the lower bound of the interval, and b is the upper bound. The output, I, is the approximate value of the definite integral.

Uses

quad uses a numerical algorithm to approximate the definite integral. It can handle a wide range of functions, including those with singularities and discontinuities, and can provide high accuracy for well-behaved functions.

For example, to approximate the integral of the function funct(x) = x^2 from x = 0 to x = 2, we can use the following code:

Matlab




>> a = 0;
>> b = 2;
% first you have to create a function like here 'funct' is a function
%and then call that function.
%see the below output for more clarification.
>> I = quad('funct',a,b);


Output:

I = 2.6667  
%This means that the approximate 
value of the definite 
integral is 2.66667.  

 

Quad and Quadl in MATLAB

The Quad and Quadl are built-in functions in MATLAB that allow you to approximate the definite integral of a function over a given interval.

Similar Reads

Quad

It integrates a specified function over specified limits, based on adaptive Simpson’s rule. The adaptive rule seeks to improve accuracy by adaptively selecting the size of the subintervals (as opposed to keeping it constant) within the limits of integration while evaluating the sums that make up the integral....

Quadl

...

Advantages

It integrates a specified function over specified limits, based on adaptive Lobatto quadrature. This one is more accurate than quad but it also uses more function evaluations. It may, however, be more efficient if your integrand is a smooth function. This function is a replacement of quad8 that existed in MATLAB 5.x. It uses a better and more reliable algorithm....

Disadvantages

...

Conclusion

Both ‘quad’ and ‘quadl’ are easy to use and require minimal input. They can handle a wide range of functions, including those with singularities and discontinuities. They can handle infinite intervals. They can provide high accuracy for well-behaved functions....