 Elementary - Maple Help

RealBox

 Elementary
 elementary and other basic functions for RealBox objects
 abs
 compute the absolute value of a RealBox
 signum
 compute the sign of a RealBox
 log
 compute the logarithm of a RealBox
 log1p
 compute the logarithm of one plus a RealBox
 exp
 compute the exponential of a RealBox
 expm1
 compute the exponential of a RealBox and subtract one
 expinvexp
 compute the exponential and its reciprocal of a RealBox
 sqrt
 compute the square root of a RealBox
 rsqrt
 compute the reciprocal square root of a RealBox
 sqrtpos
 compute the positive square root of a RealBox
 floor
 compute the positive floor of a RealBox
 ceil
 compute the positive ceiling of a RealBox
 hypot
 compute the hypotenuse of a pair of real boxes Calling Sequence abs( b ) signum( b ) log( b ) log1p( b ) exp( b ) expm1( b ) expinvexp( b ) sqrt( b ) rsqrt( b ) sqrtpos( b ) b :- floor( b ) ceil( b ) hypot( a, b ) Parameters

 a - RealBox object b - RealBox object precopt - (optional) equation of the form precision = n, where n is a positive integer Description

 • These are the elementary and other basic mathematical functions defined for RealBox objects, such as logarithms and exponentials.

 abs( b ) the absolute value of a RealBox object b signum( b ) the signum (0, 1 or -1) of a RealBox object b log( b ) the (natural) logarithm of a RealBox object b log1p( b ) computes log( 1 + b ) accurately for b close to $0$ exp( b ) the exponential (to base $e$) of b expm1( b ) computes exp( b ) - 1 accurately for b close to $0$ expinvexp( b ) computes the expression sequence representing exp( b ), exp( -b ) b:-sqrt( b ) the square root of b sqrtpos( b ) the square root of b, ignoring any negative part of the box rsqrt( b ) the reciprocal 1/sqrt( b ) of the square root of b b:-floor( b ) the floor of b ceil( b ) the ceiling of b hypot( a, b ) computes sqrt( a^2 + b^2 )

 • Use the 'precision' = n option to control the precision used in these methods. For more details on precision, see BoxPrecision. Examples

 > $b≔\mathrm{RealBox}\left(-2.3\right)$
 ${b}{≔}{⟨}{\text{RealBox:}}{-2.3}{±}{2.32831ⅇ-10}{⟩}$ (1)
 > $\left|b\right|$
 ${⟨}{\text{RealBox:}}{2.3}{±}{2.32831ⅇ-10}{⟩}$ (2)
 > $\mathrm{signum}\left(b\right)$
 ${⟨}{\text{RealBox:}}{-1}{±}{0}{⟩}$ (3)
 > $\mathrm{log}\left(b\right)$
 ${⟨}{\text{RealBox:}}{nan}{±}{0}{⟩}$ (4)

The log1p method does not have a Maple equivalent. It computes log1p( x ) = log( 1 + x ) accurately, for $x$ close to $0$.

 > $\mathrm{log1p}\left(b\right)$
 ${⟨}{\text{RealBox:}}{nan}{±}{0}{⟩}$ (5)
 > $b≔\mathrm{RealBox}\left(2.3\right)$
 ${b}{≔}{⟨}{\text{RealBox:}}{2.3}{±}{2.32831ⅇ-10}{⟩}$ (6)
 > $\mathrm{log}\left(b\right)$
 ${⟨}{\text{RealBox:}}{0.832909}{±}{1.59445ⅇ-10}{⟩}$ (7)
 > $\mathrm{log1p}\left(b\right)$
 ${⟨}{\text{RealBox:}}{1.19392}{±}{1.87027ⅇ-10}{⟩}$ (8)

Note the difference in the following three computations. In particular, for the last of the three, the expression $1+x$ is computed in Maple's regular floating point domain, where inaccuracies due to round off are not kept track of; and consequently, the final result does not contain the correct answer.

 > $x≔1.{10}^{-30}$
 ${x}{≔}{1.}{×}{{10}}^{{-30}}$ (9)
 > $\mathrm{log1p}\left(\mathrm{RealBox}\left(x\right)\right)$
 ${⟨}{\text{RealBox:}}{1e-30}{±}{1.83815ⅇ-40}{⟩}$ (10)
 > $\mathrm{log}\left(1+\mathrm{RealBox}\left(x\right)\right)$
 ${⟨}{\text{RealBox:}}{0}{±}{1.16415ⅇ-10}{⟩}$ (11)
 > $\mathrm{log}\left(\mathrm{RealBox}\left(1+x\right)\right)$
 ${⟨}{\text{RealBox:}}{0}{±}{0}{⟩}$ (12)
 > ${ⅇ}^{b}$
 ${⟨}{\text{RealBox:}}{9.97418}{±}{3.25726ⅇ-09}{⟩}$ (13)

Again, there are different results depending upon how the following is computed.

 > $\mathrm{expm1}\left(b\right)$
 ${⟨}{\text{RealBox:}}{8.97418}{±}{3.25726ⅇ-09}{⟩}$ (14)
 > ${ⅇ}^{b}-1$
 ${⟨}{\text{RealBox:}}{8.97418}{±}{3.25726ⅇ-09}{⟩}$ (15)

The sqrt function must be invoked as a fully qualified method from its argument b by using the b:- prefix.

 > $b:-\mathrm{sqrt}\left(b\right)$
 ${⟨}{\text{RealBox:}}{1.51658}{±}{1.93178ⅇ-10}{⟩}$ (16)
 > $\sqrt{b}$

There is no Maple equivalent for the method rsqrt, which computes rsqrt( s ) = 1 / sqrt( s ).

 > $b≔\mathrm{RealBox}\left(0.1,0.2\right)$
 ${b}{≔}{⟨}{\text{RealBox:}}{0.1}{±}{0.2}{⟩}$ (17)

This is undefined because the box contains negative values.

 > $b:-\mathrm{sqrt}\left(b\right)$
 ${⟨}{\text{RealBox:}}{nan}{±}{0}{⟩}$ (18)
 > $\mathrm{HasNegative}\left(b\right)$
 ${\mathrm{true}}$ (19)

However, there is an alternative method sqrtpos that can be used in such cases.

 > $\mathrm{sqrtpos}\left(\mathrm{RealBox}\left(0.1,0.2\right)\right)$
 ${⟨}{\text{RealBox:}}{0.273861}{±}{0.273861}{⟩}$ (20)
 > $\mathrm{rsqrt}\left(b\right)$
 ${⟨}{\text{RealBox:}}{nan}{±}{0}{⟩}$ (21)

The expinvexp( b ) command returns a pair of RealBox objects, the first representing exp( b ) and the second one exp( -b ).

 > $b≔\mathrm{RealBox}\left(-2.3\right)$
 ${b}{≔}{⟨}{\text{RealBox:}}{-2.3}{±}{2.32831ⅇ-10}{⟩}$ (22)
 > $\mathrm{expinvexp}\left(b\right)$
 ${⟨}{\text{RealBox:}}{0.100259}{±}{3.06477ⅇ-11}{⟩}{,}{⟨}{\text{RealBox:}}{9.97418}{±}{3.9803ⅇ-09}{⟩}$ (23)

Note that the expression above provides for a smaller radius for the second output.

 > ${ⅇ}^{b},{ⅇ}^{-b}$
 ${⟨}{\text{RealBox:}}{0.100259}{±}{3.06477ⅇ-11}{⟩}{,}{⟨}{\text{RealBox:}}{9.97418}{±}{3.25726ⅇ-09}{⟩}$ (24)
 > ${ⅇ}^{-b}$
 ${⟨}{\text{RealBox:}}{9.97418}{±}{3.25726ⅇ-09}{⟩}$ (25)
 > $b:-\mathrm{floor}\left(b\right)$
 ${⟨}{\text{RealBox:}}{-3}{±}{0}{⟩}$ (26)
 > $\mathrm{ceil}\left(b\right)$
 ${⟨}{\text{RealBox:}}{-2}{±}{0}{⟩}$ (27)
 > $a≔\mathrm{RealBox}\left(-4.7\right)$
 ${a}{≔}{⟨}{\text{RealBox:}}{-4.7}{±}{4.65661ⅇ-10}{⟩}$ (28)
 > $\mathrm{hypot}\left(a,b\right)$
 ${⟨}{\text{RealBox:}}{5.23259}{±}{1.0113ⅇ-09}{⟩}$ (29)

Note that the hypot( a, b ) command may produce a more accurate result than computing the result synthetically.

 > $\mathrm{RealBox}:-\mathrm{sqrt}\left({a}^{2}+{b}^{2}\right)$
 ${⟨}{\text{RealBox:}}{5.23259}{±}{1.38675ⅇ-09}{⟩}$ (30)
 > $\mathrm{evalb}\left(\mathrm{Radius}\left(\mathrm{hypot}\left(a,b\right)\right)<\mathrm{Radius}\left(\mathrm{RealBox}:-\mathrm{sqrt}\left({a}^{2}+{b}^{2}\right)\right)\right)$
 ${\mathrm{true}}$ (31) Compatibility

 • The RealBox[Elementary], RealBox:-abs, RealBox:-signum, RealBox:-log, RealBox:-log1p, RealBox:-exp, RealBox:-expm1, RealBox:-expinvexp, RealBox:-sqrt, RealBox:-rsqrt, RealBox:-sqrtpos, RealBox:-floor, RealBox:-ceil and RealBox:-hypot commands were introduced in Maple 2022.