Previous Page Next Page Contents

sqrt -- the square root function

Introduction

sqrt(z) represents the square root of z.

Call(s)

sqrt(z)

Parameters

z - an arithmetical expression

Returns

an arithmetical expression.

Overloadable:

z

Side Effects

When called with a floating point argument, the function is sensitive to the environment variable DIGITS which determines the numerical working precision.

Related Functions

_power, isqrt, numlib::issqr

Details

Example 1

We demonstrate some calls with exact and symbolic input data:

>> sqrt(2), sqrt(4), sqrt(36*7), sqrt(127)
                           1/2        1/2     1/2
                          2   , 2, 6 7   , 127
>> sqrt(1/4), sqrt(1/2), sqrt(3/4), sqrt(25/36/7), sqrt(4/127)
                           1/2   1/2     1/2       1/2
                          2     3     5 7     2 127
                     1/2, ----, ----, ------, --------
                           2     2      42      127
>> sqrt(-4), sqrt(-1/2), sqrt(1 + I)
                                    1/2         1/2
                        2 I, 1/2 I 2   , (1 + I)
>> sqrt(x), sqrt(4*x^(4/7)), sqrt(4*x/3), sqrt(4*(x + I))
                  1/2     2/7  / 4 x \1/2             1/2
                 x   , 2 x   , | --- |   , (4 x + 4 I)
                               \  3  /

Example 2

Floating point values are computed for floating point arguments:

>> sqrt(1234.5), sqrt(-1234.5), sqrt(-2.0 + 3.0*I)
         35.13545218, 35.13545218 I, 0.8959774761 + 1.674149228 I

A jump occurs when crossing the negative real semi axis:

>> sqrt(-4.0), sqrt(-4.0 + I/10^100), sqrt(-4.0 - I/10^100)
                 2.0 I, 2.5e-101 + 2.0 I, 2.5e-101 - 2.0 I

Example 3

The square root of symbolic products involving positive integer factors is simplified:

>> sqrt(20*x*y*z)
                                      1/2  1/2
                             2 (x y z)    5

Example 4

Square roots of squares are not simplified, unless the argument is real and its sign is known:

>> sqrt(x^2*y^4)
                                  2  4 1/2
                                (x  y )
>> assume(x > 0): sqrt(x^2*y^4)
                                     4 1/2
                                 x (y )
>> assume(x < 0): sqrt(x^2*y^4)
                                      4 1/2
                                - x (y )

Example 5

sqrt provides more simplifications than the _power function:

>> sqrt(4*x), (4*x)^(1/2) = _power(4*x, 1/2) 
                           1/2       1/2        1/2
                        2 x   , (4 x)    = (4 x)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000