Numerical integration using variable precision (2024)

Numerical integration using variable precision

collapse all in page

Syntax

vpaintegral(f,a,b)

vpaintegral(f,x,a,b)

vpaintegral(___,Name,Value)

Description

example

vpaintegral(f,a,b) numerically approximates f from a to b. The default variable x in f is found by symvar.

vpaintegral(f,[a b]) is equal to vpaintegral(f,a,b).

example

vpaintegral(f,x,a,b) performs numerical integration using the integration variable x.

example

vpaintegral(___,Name,Value) uses additional options specified by one or more Name,Value pair arguments.

Examples

Numerically Integrate Symbolic Expression

Numerically integrate the symbolic expression x^2 from 1 to 2.

syms xvpaintegral(x^2, 1, 2)
ans =2.33333

Numerically Integrate Symbolic Function

Numerically integrate the symbolic function y(x)=x2 from 1 to 2.

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

High-Precision Numerical Integration

vpaintegral uses variable-precision arithmetic while the MATLAB® integral function uses double-precision arithmetic. Using the default values of tolerance, vpaintegral can handle values that cause the MATLAB integral function to overflow or underflow.

Integrate besseli(5,25*u).*exp(-u*25) by using both integral and vpaintegral. The integral function returns NaN and issues a warning while vpaintegral returns the correct result.

syms u xf = 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 = NaNusingVpaintegral =0.688424

Increase Precision Using Tolerances

The digits function does not affect vpaintegral. Instead, increase the precision of vpainteral by decreasing the integration tolerances. Conversely, increase the speed of numerical integration by increasing the tolerances. Control the tolerance used by vpaintegral by changing the relative tolerance RelTol and absolute tolerance AbsTol, which affect the integration through the condition

|QI|max(AbsTol,|Q|·RelTol)whereQ=CalculatedIntegralI=ExactIntegral.

Numerically integrate besselj(0,x) from 0 to pi, to 32 significant figures by setting RelTol to 10^(-32). Turn off AbsTol by setting it to 0.

syms xvpaintegral(besselj(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

Integrate 1/(2*z-1) over the triangular path from 0 to 1+1i to 1-1i back to 0 by specifying waypoints.

syms zvpaintegral(1/(2*z-1), [0 0], 'Waypoints', [1+1i 1-1i])
ans =- 8.67362e-19 - 3.14159i

Reversing the direction of the integral, by changing the order of the waypoints and exchanging the limits, changes the sign of the result.

Multiple Integrals

Perform multiple integration by nesting calls to vpaintegral. Integrate

1213xydxdy.

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

The limits of integration can be symbolic expressions or functions. Integrate over the triangular region 0≤x≤1 and |y|<x by specifying the limits of the integration over y in terms of x.

vpaintegral(vpaintegral(sin(x-y)/(x-y), y, [-x x]), x, [0 1])

Input Arguments

collapse all

fExpression or function to integrate
symbolic number | symbolic variable | symbolic vector | symbolic matrix | symbolic multidimensional array | symbolic function | symbolic expression

Expression or function to integrate, specified as a symbolic number, variable, vector, matrix, multidimensional array, function, or expression.

a,bLimits of integration
list of two numbers | list of two symbolic numbers | list of two symbolic variables | list of two symbolic functions | list of two symbolic expressions

Limits of integration, specified as a list of two numbers, symbolic numbers, symbolic variables, symbolic functions, or symbolic expressions.

xIntegration variable
symbolic variable

Integration variable, specified as a symbolic variable. If x is not specified, the integration variable is found by symvar.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'RelTol',1e-20

RelTolRelative error tolerance
1e-6 (default) | positive real number

Relative error tolerance, specified as a positive real number. The default is 1e-6. The RelTol argument determines the accuracy of the integration only if RelTol·|Q|>AbsTol, where Q is the calculated integral. In this case, vpaintegral satisfies the condition |QI|RelTol·|Q|, where I is the exact integral value. To use only RelTol and turn off AbsTol, set AbsTol to 0.

Example: 1e-8

AbsTolAbsolute error tolerance
1e-10 (default) | non-negative real number

Absolute error tolerance, specified as a non-negative real number. The default is 1e-10. AbsTol determines the accuracy of the integration if AbsTol>RelTol·|Q|, where Q is the calculated integral. In this case, vpaintegral satisfies the condition |QI|AbsTol, where I is the exact integral value. To turn off AbsTol and use only RelTol, set AbsTol to 0.

Example: 1e-12

WaypointsIntegration path
vector of numbers | vector of symbolic numbers | vector of symbolic expressions | vector of symbolic functions

Integration path, specified as a vector of numbers, or as a vector of symbolic numbers, expressions, or functions. vpaintegral integrates 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.

MaxFunctionCallsMaximum evaluations of input
10^5 (default) | positive integer | positive symbolic integer

Maximum evaluations of input, specified as a positive integer or a positive symbolic integer. The default value is 10^5. If the number of evaluations of f is greater than MaxFunctionCalls, then vpaintegral throws an error. For unlimited evaluations, set MaxFunctionCalls to Inf.

Tips

  • Ensure that the input is integrable. If the input is not integrable, the output of vpaintegral is unpredictable.

  • The digits function does not affect vpaintegral. To increase precision, use the RelTol and AbsTol arguments instead.

Version History

Introduced in R2016b

See Also

diff | int | integral | vpa

Topics

  • Integration

MATLAB Command

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.

Numerical integration using variable precision (1)

Select a Web Site

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: .

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

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Numerical integration using variable precision (2024)

References

Top Articles
Real Food Eggnog Recipe {dairy-free option, Paleo, Low Carb}
27 Must-Make Recipes Inspired by Julia Child
Car Parts Open Now
Davaba19
Elektrisch koffiezetapparaat Philips CSA240/61 1450 W Zwart 1450 W | bol
Python Regex Space
Craigslist Greenville Pets Free
Tear Of The Kingdom Nsp
O'Quinn Peebles Phillips Funeral Home
Barefoot Rentals Key Largo
Schüleraustausch Neuseeland - Schulabschluss mit Study Nelson
Varsity Competition Results 2022
Bailu Game8
Gas Station Drive Thru Car Wash Near Me
Caribbean Mix Lake Ozark
Breakroom Bw
LeBron Glazing Poem / Boy Oh Boy, Where Do I Even Begin?
Google Flights Msp To Fort Myers
Hyb Urban Dictionary
Costco Gas Price City Of Industry
Starfield PC, XSX | GRYOnline.pl
Learning Channel Senior Living
Clarksville.craigslist
Used Safari Condo Alto R1723 For Sale
MySDMC SSO: Manatee County’s Digital Educational Access
Emerge Ortho Kronos
Dna Profiling Virtual Lab Answer Key
Sloansmoans Many
Gopher Hockey Forum
Logisticare Transportation Provider Login
Chris Bailey Weather Forecast
Southeast Ia Craigslist
Adams County 911 Live Incident
Best Hs Bball Players
Craigslist Pennsylvania Poconos
Hubspot Community
France 2 Journal Télévisé 20H
8 Best Bubble Braid Hairstyles For All Hair Types
Best Upscale Restaurants In Denver
Franco Loja Net Worth
Wocs Failure Rate
Avalon Hope Joi
Kagtwt
China Rose Plant Care: Water, Light, Nutrients | Greg App 🌱
C Spire Express Pay
Grayson County Craigslist
Green Press Gazette Obits
C And B Processing
Kona Airport Webcam
The most memorable songs from '90s movies
Codex Genestealer Cults 10th Edition: The Goonhammer Review
Two Soyjaks Pointing Png
Latest Posts
Article information

Author: Msgr. Benton Quitzon

Last Updated:

Views: 5914

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.