MATLAB improves accuracy VPA

Source: Internet
Author: User

MATLAB provides a wide range of data types (you can find detailed descriptions of MATLAB data types). The default data type is double.

However, sometimes there may be situations where the data type is not accurate enough. For example, when calculating the slope and counting down, there may often be a phenomenon where the difference is a thousand miles.

Therefore, the precision of existing data types needs to be improved. MATLAB provides a function VPA that allows you to customize data precision. For details, see product help or help.

YesDescriptionYes: When high precision is no longer required, double (data)-> double type, or other types you need.

> Help VPA
VPA variable precision arithmetic.
R = VPA (s) numerically evaluates each element of the double Matrix
S Using Variable Precision Floating Point Arithmetic with D decimal
Digit accuracy, where D is the current setting of digits.
The resulting R is a sym.

VPA (S, d) uses D digits, instead of the current setting of digits.
D is an integer or the sym representation of a number.
 
It is important to avoid the evaluation of an expression using double
Precision Floating Point Arithmetic before it is passed to VPA.
For example,
Phi = VPA (1 + SQRT (5)/2)
First computes a 16-digit approximation to the golden ratio, then
Converts that approximation to one with D digits, where D is the current
Setting of digits. To get full precision, use unevaluated string or
Symbolic arguments,
Phi = VPA ('(1 + SQRT (5)/2 ')
Or
S = Sym ('sqrt (5 )')
Phi = VPA (1 + S)/2 );
 
Additional examples:
VPA (PI, 780) shows six consecutive 9's near digit 770 in
Decimal expansion of pi.
 
VPA (hilb (2), 5) returns
 
[1.,. 50000]
[. 50000,. 33333]
 
See also double, digits.

Overloaded methods:
Sym/VPA

Reference page in help Browser
Doc VPA

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.