help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] unexpected behaviour for x^x


From: fbarbuto
Subject: Re: [newbie] unexpected behaviour for x^x
Date: Fri, 12 Dec 2014 05:14:55 -0800 (PST)

Your question, and some answers you've got, baffled me in many ways.

Mathematically speaking, -0.001^-0.001 (or -0.001^(-0.001) thereof)  should
not be compared to 0.001^0.001, because while the latter is a real number,
the former operation yields a /complex/ number.  That is easy to see if you
apply logs to both expressions, because since y = x^c (suppose "x" and "c"
as real numbers), log10(y) = c*log10(x) and hence "y" can also be computer
as y = 10**(c*log10(x)).  Thus,

log10(0.001^0.001) = 0.001*log10(0.001) = 0.001*(-3) = -0.003  ===> Real
number

whereas

log10(-0.001^(-0.001)) = -0.001*log(-0.001) ===> Complex number, as the log
of a negative number does not exist in the realm of the Reals.

Therefore your comparison makes no much sense at all.

>From Octave's standpoint I got some surprising results.  Whereas
-0.001^(-0.001) does indeed yield -1.0069, the same does not happen when you
create a variable x = -0.001 and perform x^x, as someone cleverly suggested:

>> -0.001^-0.001
ans = -1.00693166885180

>> x = -0.001
x = -0.00100000000000000
>> x^x
ans =  1.00692669984727590 - 0.00316336393000065i

That is the result I would have expected to see (a complex number), which is
consistent with:

>> y = -0.001*log10(-0.001)
y =  0.00300000000000000 - 0.00136437635384184i
>> 10**y
ans =  1.00692669984727590 - 0.00316336393000065i

As a cherry on the top of the cake, I have just "discovered" that the old
and much-loved (by me) Fortran/Python exponentiation syntax, "**", is also
valid in Octave:

>> 0.001**0.001
ans =  0.993116048420934

(I never fully liked the caret as an exponentiation symbol).

Regards,

Fausto




--
View this message in context: 
http://octave.1599824.n4.nabble.com/newbie-unexpected-behaviour-for-x-x-tp4667762p4667772.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]