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)
Top Articles
25 Weight Watchers Instant Pot Recipes
Weight Watchers Zero Point Soup Recipes {+More Low-Point Soups} · The Inspiration Edit
Dainty Rascal Io
Will Byers X Male Reader
Fort Morgan Hometown Takeover Map
Bleak Faith: Forsaken – im Test (PS5)
Tmf Saul's Investing Discussions
Combat level
Team 1 Elite Club Invite
Mylife Cvs Login
Waive Upgrade Fee
Mercy MyPay (Online Pay Stubs) / mercy-mypay-online-pay-stubs.pdf / PDF4PRO
Regular Clear vs Low Iron Glass for Shower Doors
Dumb Money
Wisconsin Women's Volleyball Team Leaked Pictures
About Us | TQL Careers
Cvs Appointment For Booster Shot
Jesus Calling Oct 27
Suffix With Pent Crossword Clue
Puretalkusa.com/Amac
Illinois VIN Check and Lookup
Is The Yankees Game Postponed Tonight
Loft Stores Near Me
Lola Bunny R34 Gif
Apple Original Films and Skydance Animation’s highly anticipated “Luck” to premiere globally on Apple TV+ on Friday, August 5
Cbssports Rankings
Marine Forecast Sandy Hook To Manasquan Inlet
Anotherdeadfairy
Ecampus Scps Login
Del Amo Fashion Center Map
CVS Health’s MinuteClinic Introduces New Virtual Care Offering
Democrat And Chronicle Obituaries For This Week
Everything You Need to Know About Ñ in Spanish | FluentU Spanish Blog
Franklin Villafuerte Osorio
Opsahl Kostel Funeral Home & Crematory Yankton
Urban Blight Crossword Clue
UPS Drop Off Location Finder
Edward Walk In Clinic Plainfield Il
Craigslist Mount Pocono
Go Smiles Herndon Reviews
Restored Republic December 9 2022
Craigslist Putnam Valley Ny
Join MileSplit to get access to the latest news, films, and events!
Thor Majestic 23A Floor Plan
Craigslist Minneapolis Com
Sechrest Davis Funeral Home High Point Nc
The Average Amount of Calories in a Poke Bowl | Grubby's Poke
Kaamel Hasaun Wikipedia
Ouhsc Qualtrics
Dayton Overdrive
Otter Bustr
Factorio Green Circuit Setup
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated:

Views: 5653

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.