[futurebasic] Re: cubic root

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2003 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Thu, 20 Mar 2003 07:57:21 -0500
Alain Wrobel asked:

>I have another problem : why is the cubic root of a negative
>number always equal to zero ?


Alain:

The following modification in expression may solve your problem in 
the classic schoolbook definition of "cube root", but not in the true 
mathematical sense of the word. This is because there are three (not 
necessarily distinct) cube roots for negative numbers, two of which 
result in complex results. That said, this may be all you need for 
your programming purposes.

window 1
dim as double a
a = 27
print "cubic root of "a" = "a^(1\3)
a = -a
print "cubic root of "a" = "sgn(a) * abs(a) ^ (1/3)
a = 50
print "cubic root of "a" = "a^(1\3)
a = -a
print "cubic root of "a" = "sgn(a) * abs(a) ^ (1/3)
do
until fn button


Ken