fractional powers of negative numbers? [message #8837] |
Thu, 24 April 1997 00:00 |
Med Bennett
Messages: 109 Registered: April 1997
|
Senior Member |
|
|
Can someone explain this to me? Is it possible to compute the fractional
power of a negative number? IDL does it on single negative values but
not on arrays containing negative values.
IDL> print,findgen(11)-5
-5.00000 -4.00000 -3.00000 -2.00000
-1.00000 0.000000 1.00000 2.00000
3.00000 4.00000 5.00000
IDL> print,(findgen(11)-5)^1.51
-1.#IND0 -1.#IND0 -1.#IND0 -1.#IND0
-1.#IND0 0.000000 1.00000 2.84810
5.25355 8.11168 11.3617
% Program caused arithmetic error: Floating illegal operand
IDL> print,-2.^1.51
-2.84810
IDL> print,-5.^1.51
-11.3617
Med Bennett
bennettm@boulder.pti-enviro.com
|
|
|
Re: fractional powers of negative numbers? [message #8838 is a reply to message #8837] |
Thu, 24 April 1997 00:00  |
Ewan A. Macpherson
Messages: 14 Registered: December 1996
|
Junior Member |
|
|
Med Bennett wrote:
> Can someone explain this to me? Is it possible to compute the fractional
> power of a negative number? IDL does it on single negative values but
> not on arrays containing negative values.
> IDL> print,-2.^1.51
> -2.84810
> IDL> print,-5.^1.51
> -11.3617
These may not give an error, but they're wrong. The results are going to
be complex. IDL is giving you -(2^1.51), not (-2)^1.51, which gives me
an error in PV-WAVE. When you do it on the array it is not treating the
negative sign as a negation operator, but as part of the value, hence
the error. You'll need to do something like this:
print, exp(1.51 * alog(complex(-2,0)))
which gives: ( 0.0894611, -2.84669)
--
Ewan Macpherson <macpherson@earvax.waisman.wisc.edu>
Hearing Development Research Lab, Waisman Center
University of Wisconsin - Madison
http://www.waisman.wisc.edu/~macpherson/
|
|
|