Board index » delphi » Cubed root

Cubed root

Quote
Jason Wallace wrote:

> Attention Math Majors...

>   A friend of mine was asking if anyone knew how to code a way to
> determine a cubed root...

. . . . . (snip)

case X of
 0.0 : Y :=  0.0;

Quote
>0.0 : Y :=  Exp ( Ln( X) / 3.0 );

<0.0 : Y := -Exp ( Ln(-X) / 3.0 );
end

should do the trick

regards Sven

 

Re:Cubed root


Attention Math Majors...

  A friend of mine was asking if anyone knew how to code a way to
determine a cubed root...
  We looked in the Math.PAS, but there's nothing there on it...  Any
help would be GREATLY appreciated...  Thanks...

Jason

Re:Cubed root


In article <3212DBAC.2...@alcatel.no>, Sven Pran  <Sven.P...@alcatel.no> wrote:

Quote
>Jason Wallace wrote:

>> Attention Math Majors...

>>   A friend of mine was asking if anyone knew how to code a way to
>> determine a cubed root...
>. . . . . (snip)

>case X of
> 0.0 : Y :=  0.0;
>>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
>end

>should do the trick

>regards Sven

Does this technique extend to n'th roots?  Or is it just some
funky property of a cube root?

Glenn McAllister

Re:Cubed root


Glen McAllister wrote in a message appearing on comp.lang.pascal.delphi.components.misc:

Quote
>In article <3212DBAC.2...@alcatel.no>, Sven Pran  <Sven.P...@alcatel.no>
>wrote:
>>Jason Wallace wrote:

>>> Attention Math Majors...

>>>   A friend of mine was asking if anyone knew how to code a way to
>>> determine a cubed root...
>>. . . . . (snip)

>>case X of
>> 0.0 : Y :=  0.0;
>>>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
>><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
>>end

>>should do the trick

>>regards Sven
>Does this technique extend to n'th roots?  Or is it just some
>funky property of a cube root?

It's a funky property of Logarithms.

It will work in general, except for even numbered roots of negative
numbers.

--
Kevin (kwdav...@mercury.interpath.com) | http://www.interpath.com/~kwdavids/

Re:Cubed root


Quote
Jason Wallace wrote:
>>>   A friend of mine was asking if anyone knew how to code a way to
>>> determine a cubed root...

Sven Pran replied:

Quote
>>case X of
>> 0.0 : Y :=  0.0;
>>>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
>><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
>>end

While Glen McAllister asked:

Quote
>Does this technique extend to n'th roots?  Or is it just some
>funky property of a cube root?

Basically, the Nth root of a number is the Logarithm of that number,
divided by N. You can have positive and negative values for the root (but I
forget if that is only for the odd-values like 3,5,7, etc.) Basically,

     N-root of X equals    Ln(X)/N

Hope that helps.

Mark Edwards
------------
Any email, judged by me, to be of a commercial nature,
will be reviewed and billed at a rate of $500 per item.

Re:Cubed root


Quote
Jason Wallace wrote:

> Attention Math Majors...

>   A friend of mine was asking if anyone knew how to code a way to
> determine a cubed root...
>   We looked in the Math.PAS, but there's nothing there on it...  Any
> help would be GREATLY appreciated...  Thanks...

Heh, heh, heh...

        You didn't look hard enough.

        Since (x ** a) ** b = x ** (a * b), it follows that

              (x ** 1/3) ** 3 = x ** 1 = x

        So cube-root of x is Power (x, 1/3)

                Ain't that so?

                J.

Re:Cubed root


In article <3212DE1F.3...@DarkElf.reno.nv.us>, E...@DarkElf.reno.nv.us says...

Quote

>Attention Math Majors...

>  A friend of mine was asking if anyone knew how to code a way to
>determine a cubed root...
>  We looked in the Math.PAS, but there's nothing there on it...  Any
>help would be GREATLY appreciated...  Thanks...

>Jason

If it's D2, just use power(x,1/3)

=steve

Re:Cubed root


Quote
In article <3214C0CC.2...@math.okstate.edu> David Ullrich <ullr...@math.okstate.edu> writes:
>Mark Edwards wrote:

>> Jason Wallace wrote:
>> >>>   A friend of mine was asking if anyone knew how to code a way to
>> >>> determine a cubed root...

>> Sven Pran replied:
>> >>case X of
>> >> 0.0 : Y :=  0.0;
>> >>>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
>> >><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
>> >>end

>> While Glen McAllister asked:
>> >Does this technique extend to n'th roots?  Or is it just some
>> >funky property of a cube root?

>> Basically, the Nth root of a number is the Logarithm of that number,
>> divided by N. You can have positive and negative values for the root (but I
>> forget if that is only for the odd-values like 3,5,7, etc.) Basically,

>>      N-root of X equals    Ln(X)/N
>        What? This is like saying that basically the sine of an angle
>is the aquare of the hypotenuse.

:-)  I believe you meant to say:        Exp(Ln(x) / n)

The logarithm of X^2 is exactly twice the logarithm of X.  

Seriously folks, one of the nicest books on my shelves, besides the large
number of data-structure books, is a reference work on algorithms.  Also, many
college libraries and some more-enlightened community libraries have books
such as ACM Collected Algorithms, which can be worth their weight.

I don't know if anyone has done a web-site on algorithms yet, but I'd sure
like to know if someone did .. someone should.

/mr/

Re:Cubed root


Quote
Mark Edwards wrote:

> Jason Wallace wrote:
> >>>   A friend of mine was asking if anyone knew how to code a way to
> >>> determine a cubed root...

> Sven Pran replied:
> >>case X of
> >> 0.0 : Y :=  0.0;
> >>>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
> >><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
> >>end

> While Glen McAllister asked:
> >Does this technique extend to n'th roots?  Or is it just some
> >funky property of a cube root?

> Basically, the Nth root of a number is the Logarithm of that number,
> divided by N. You can have positive and negative values for the root (but I
> forget if that is only for the odd-values like 3,5,7, etc.) Basically,

>      N-root of X equals    Ln(X)/N

        What? This is like saying that basically the sine of an angle
is the aquare of the hypotenuse.

        (Would include comments of a more constructive nature but the
question's been answered, more or less.)

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Re:Cubed root


Not quite, in case of a cubed root, this routine rightly gives you an
answer on a negative value - but if the 3 would be replaced by n, you
would have to check whether n mod 2 = 0,  because x **(1/4) or x**(1/8)
clearly does not exist if x < 0.
--
John Bester
Strategic Software Ltd.
j...@sslbr.demon.co.uk
CompuServe: 100042,3171

Quote
> snowl...@igs.net (Glen McAllister) wrote in article

<4uvkcv$...@host.igs.net>...
Quote
> In article <3212DBAC.2...@alcatel.no>, Sven Pran  <Sven.P...@alcatel.no>
wrote:
> >Jason Wallace wrote:

> >> Attention Math Majors...

> >>   A friend of mine was asking if anyone knew how to code a way to
> >> determine a cubed root...
> >. . . . . (snip)

> >case X of
> > 0.0 : Y :=  0.0;
> >>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
> ><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
> >end

> >should do the trick

> >regards Sven

> Does this technique extend to n'th roots?  Or is it just some
> funky property of a cube root?

> Glenn McAllister

Re:Cubed root


Not quite, if you stick n in the place of 3, you should check if (x < 0)
and (n mod 2 = 0) in which case there you have to return an imaginary
number. (Something that exists in the mind of a mathematician) In such
cases I would just raise an exception for all normal purposes.
--
John Bester
Strategic Software Ltd.
j...@sslbr.demon.co.uk
CompuServe: 100042,3171

Quote
> snowl...@igs.net (Glen McAllister) wrote in article

<4uvkcv$...@host.igs.net>...
Quote
> In article <3212DBAC.2...@alcatel.no>, Sven Pran  <Sven.P...@alcatel.no>
wrote:
> >Jason Wallace wrote:

> >> Attention Math Majors...

> >>   A friend of mine was asking if anyone knew how to code a way to
> >> determine a cubed root...
> >. . . . . (snip)

> >case X of
> > 0.0 : Y :=  0.0;
> >>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
> ><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
> >end

> >should do the trick

> >regards Sven

> Does this technique extend to n'th roots?  Or is it just some
> funky property of a cube root?

> Glenn McAllister

Re:Cubed root


Quote
sund...@primenet.com (Sundial Services) wrote:

[material on logs snipped]

Quote

>Seriously folks, one of the nicest books on my shelves, besides the large
>number of data-structure books, is a reference work on algorithms.  Also, many
>college libraries and some more-enlightened community libraries have books
>such as ACM Collected Algorithms, which can be worth their weight.

>I don't know if anyone has done a web-site on algorithms yet, but I'd sure
>like to know if someone did .. someone should.

>/mr/

For pointers to the original journal addresses of 3000+ algorithms,
take a look at :

      http://paris.lcs.mit.edu/~bvelez/std-colls/cacm/index.html

The page is an algorithm bibliography in the form of a one page 300K
text file AKA the SMART Collection. Most of the references are to the
original 1960s ACM articles. Some papers have brief summaries
included.
It's a decent reference resource when used with a search engine, as
long as you have handy access to the original CACM/JACM journals.

------------------------------------------------------------
Dallas Jones        Vero Beach, FL       sundo...@gate.net
------------------------------------------------------------
                  "Knowledge is Good."
------------------------------------------------------------

Re:Cubed root


Jason Wallace <E...@DarkElf.reno.nv.us> wrote in article
<3212DE1F.3...@DarkElf.reno.nv.us>...

Quote
> Attention Math Majors...

>   A friend of mine was asking if anyone knew how to code a way to
> determine a cubed root...
>   We looked in the Math.PAS, but there's nothing there on it...  Any
> help would be GREATLY appreciated...  Thanks...

> Jason

function Sqrt3 (X : Real) : Real;
begin
  Sqrt3 := Exp(Ln(X)/3); {Both functions defined in System}
end;

Re:Cubed root


Quote
In article <4uvkcv$...@host.igs.net>, snowl...@igs.net (Glen McAllister) wrote:
>In article <3212DBAC.2...@alcatel.no>, Sven Pran  <Sven.P...@alcatel.no> wrote:
>>Jason Wallace wrote:

>>> Attention Math Majors...

>>>   A friend of mine was asking if anyone knew how to code a way to
>>> determine a cubed root...
>>. . . . . (snip)

>>case X of
>> 0.0 : Y :=  0.0;
>>>0.0 : Y :=  Exp ( Ln( X) / 3.0 );
>><0.0 : Y := -Exp ( Ln(-X) / 3.0 );
>>end

>>should do the trick

>>regards Sven

>Does this technique extend to n'th roots?  Or is it just some
>funky property of a cube root?

>Glenn McAllister

For a generic N'th root try:

        if (( N mod 2 ) = 1) and ( X < 0.0 ) then
                Sign:= -1
        Else if ( X = 0.0 ) then
                Sign:= 0
        Else
                Sign:= 1;
        Y:= Sign * Exp ( Ln ( X) / N );

Also Note, Ln(-X) will produce an error result.

--
Robert Howard                                    "Something Presented Well
Programming Manager                               Is Received Well."
Tasmanian Geological Drafting Services Pty Ltd.
---

Other Threads