 Student[NumericalAnalysis] - Maple Programming Help

Home : Support : Online Help : Education : Student Packages : Numerical Analysis : Computation : Student/NumericalAnalysis/NumberOfSignificantDigits

Student[NumericalAnalysis]

 NumberOfSignificantDigits
 compute the number of significant digits of an approximation

 Calling Sequence NumberOfSignificantDigits(xe, xa, opts)

Parameters

 xe - realcons; the exact value xa - realcons; the approximate value opts - (optional) equation(s) of the form keyword = value, where keyword is: digits; the options for computing the number of significant digits

Options

 • digits = posint
 A positive integer; the environment variable Digits will be set to this integer during the execution of this procedure. By default this is set to 10.

Description

 • The NumberOfSignificantDigits command computes the number of significant digits of an approximation using the exact value and approximate value.
 • The number, SD, of significant digits is computed by the formula

$\mathrm{SD}\left(\mathrm{xe},\mathrm{xa}\right)=\mathrm{max}\left(0,\mathrm{max}\left(\mathrm{ilog10}\left(\mathrm{xe}\right),\mathrm{ilog10}\left(\mathrm{xa}\right)\right)-\mathrm{ilog10}\left(2\mathrm{xe}-2\mathrm{xa}\right)\right)$

 This formula returns the largest integer $n$ such that $\mathrm{xe}$ and $\mathrm{xa}$ differ by less than $0.5$ units in the $n$th place.  For example, for $\mathrm{xe}=19.123456$ and $\mathrm{xa}=19.123955$ we have $n=5$, because the difference between $\mathrm{xe}$ and $\mathrm{xa}$ is $0.499$ units in the 5th place (digit), while for $\mathrm{xa}=19.123956$ we have $n=4$ because the difference is now $0.500$ units in the 5th place (so too large to set $n=5$).

Examples

 > $\mathrm{with}\left(\mathrm{Student}\left[\mathrm{NumericalAnalysis}\right]\right):$
 > $\mathrm{xe}≔1.81$
 ${\mathrm{xe}}{≔}{1.81}$ (1)
 > $\mathrm{xa}≔1.63$
 ${\mathrm{xa}}{≔}{1.63}$ (2)
 > $\mathrm{NumberOfSignificantDigits}\left(\mathrm{xe},\mathrm{xa}\right)$
 ${1}$ (3)
 > $\mathrm{xe}≔9.81$
 ${\mathrm{xe}}{≔}{9.81}$ (4)
 > $\mathrm{xa}≔9.63$
 ${\mathrm{xa}}{≔}{9.63}$ (5)
 > $\mathrm{NumberOfSignificantDigits}\left(\mathrm{xe},\mathrm{xa}\right)$
 ${1}$ (6)