Board index » delphi » What is Square Root command?

What is Square Root command?

sqrt()

Quote
{*word*104}t0aD wrote:

> Can someone post the command to do a square root.  I'm a newbie and can't find
>  it anywhere.  I don't have the help files at my computer.  Please post it as
>  an RE or email me

> {*word*104}t...@aol.com
> Please note the ZERO in my name
> {*word*104}t0  <---Zero

> Thanx!

 

Re:What is Square Root command?


Can someone post the command to do a square root.  I'm a newbie and can't find
 it anywhere.  I don't have the help files at my computer.  Please post it as
 an RE or email me

{*word*104}t...@aol.com
Please note the ZERO in my name
{*word*104}t0  <---Zero    

Thanx!

Re:What is Square Root command?


On 4 Nov 1997 01:10:51 GMT, {*word*104}t...@aol.com ({*word*104}t0aD) wrote:

Quote
>Can someone post the command to do a square root.  I'm a newbie and can't find
> it anywhere.  I don't have the help files at my computer.  Please post it as
> an RE or email me

Maybe you should get a legal version of your compiler ?

Regards
Horst

Re:What is Square Root command?


{*word*104}t0aD <{*word*104}t...@aol.com> wrote in article
<19971104011001.UAA07...@ladder01.news.aol.com>...

Quote
> Can someone post the command to do a square root.  I'm a newbie and can't
find
>  it anywhere.  I don't have the help files at my computer.  Please post
it as
>  an RE or email me

This is actually a math question!  Pascal as we know it, does not give a
function to do this, but the mathematical fuctions used for the calculation
in question, are available.

a^n = e^(n log a)   where the base is e. (log base e  is the same as  ln)

which translates to the following in your square root question

x^(1/2) = e^((1/2) ln x)

Here is your function

Function SqrRoot(x : Real) : Real;

Begin
        If x = 0 Then
                SqrRoot := 0
        Else
                If x < 0 Then
                        Halt (Square root is a complex number)
                Else
                        SqrRoot := Exp(0.5 * Ln(x));
End;

Also keep in mind that the answer you get will also work if negative.
e.g. (-2)*(-2) = 4 thus 2 and -2 are both roots of 4.

Re:What is Square Root command?


Quote
>Subject: Re: What is Square Root command?
>From: "BASTARD" <lexli...@iafrica.com>
>Date: Fri, Nov 7, 1997 01:32 EST
>Message-id: <01bceb47$05cc1f00$LocalH...@lexlines.iafrica.com>

>{*word*104}t0aD <{*word*104}t...@aol.com> wrote in article
><19971104011001.UAA07...@ladder01.news.aol.com>...
>> Can someone post the command to do a square root.  I'm a newbie and can't
>find
>>  it anywhere.  I don't have the help files at my computer.  Please post
>it as
>>  an RE or email me

>This is actually a math question!  Pascal as we know it, does not give a
>function to do this, but the mathematical fuctions used for the calculation
>in question, are available.

>a^n = e^(n log a)   where the base is e. (log base e  is the same as  ln)

>which translates to the following in your square root question

>x^(1/2) = e^((1/2) ln x)

>Here is your function

>Function SqrRoot(x : Real) : Real;

>Begin
>    If x = 0 Then
>            SqrRoot := 0
>    Else
>            If x < 0 Then
>                    Halt (Square root is a complex number)
>            Else
>                    SqrRoot := Exp(0.5 * Ln(x));
>End;

>Also keep in mind that the answer you get will also work if negative.
>e.g. (-2)*(-2) = 4 thus 2 and -2 are both roots of 4.

Apparently you have never seen the build-in function Sqrt (n).

Re:What is Square Root command?


Quote
BASTARD wrote:

> {*word*104}t0aD <{*word*104}t...@aol.com> wrote in article
> <19971104011001.UAA07...@ladder01.news.aol.com>...
> > Can someone post the command to do a square root.  I'm a newbie and can't
> find

[snip]

Quote
> This is actually a math question!  Pascal as we know it, does not give a
> function to do this, but the mathematical fuctions used for the calculation
> in question, are available.

[snip]

Quote
> which translates to the following in your square root question

> x^(1/2) = e^((1/2) ln x)

[function snipped]

{*word*104}toad might of course also try and look in the manuals for math
functions. Turbo/Borland pascal does implement some of them (after all,
exp() and ln() could also be done by series development.

Your function has the nice property that it is easy to extent to
negative
x, returning complex numbers.
--

Remco Vietor                            Department of Chemistry
re...@chem.gla.ac.uk                       J. Black Building
                                        University of Glasgow
                                        Glasgow G12 8QQ
                                        U.K.

Re:What is Square Root command?


On Tue, 11 Nov 1997 10:17:36 +0000, Remco Vi?tor

Quote
<re...@chem.gla.ac.xukx> wrote:
>BASTARD wrote:

>> {*word*104}t0aD <{*word*104}t...@aol.com> wrote in article
>> <19971104011001.UAA07...@ladder01.news.aol.com>...
>> > Can someone post the command to do a square root.  I'm a newbie and can't
>> find

>[snip]

>> This is actually a math question!  Pascal as we know it, does not give a
>> function to do this ...

Not true: function sqrt(x: real): real is defined in standard Pascal
and in Turbo Pascal since version 1.

Bob Ferguson

--
J.R. Ferguson, Amsterdam, The Netherlands
e-mail: j.r.fergu...@iname.com

Re:What is Square Root command?


In article <19971104011001.UAA07...@ladder01.news.aol.com>,

Quote
{*word*104}t0aD <{*word*104}t...@aol.com> wrote:
>Can someone post the command to do a square root.  I'm a newbie and can't find
> it anywhere.  I don't have the help files at my computer.  Please post it as
> an RE or email me

>{*word*104}t...@aol.com
>Please note the ZERO in my name

What was your mother thinking about.

Quote
>{*word*104}t0  <---Zero    

>Thanx!

Osmo

Other Threads