negative decimal powers of negative numbers

i need to calcualte something like
-12.567 ^ -0.256

a normal pow(-12.567,-0.256) doesnt work obviously. I can still make it pow(-12.567,-0.256) if i use a recoprocal, bnut still the pow statement doesnt work,...

my question is that is -12.567^-0.256==(-1^-0.256)*(12.567^-0.256) ???
and is -1 raised to any negative decimal power equla to -1 ???


is this is the case then i can use the absolute value and calculate it

Comments

  • Hi,

    : i need to calcualte something like
    : -12.567 ^ -0.256
    :
    : a normal pow(-12.567,-0.256) doesnt work obviously. I can still make
    : it pow(-12.567,-0.256) if i use a recoprocal, bnut still the pow
    : statement doesnt work,...
    So, from the POW docs:

    [code]If "x" and "y" are both zero, or if "x" is non-positive and "y" is not an integer, "pow" return -HUGE_VAL and sets "errno" to EDOM.[/code]

    The second part applies there and the "and" means we only need to deal with one of the conditions, so it would appear we can solve the problem by writing:

    [code]double z = -pow(12.567, -0.256);[/code]

    Instead. Which works. Also this gives the same answer:

    [code]double z = -1.0 / pow(12.567, 0.256);[/code]

    Which uses the reciprocal property you mention.

    : my question is that is -12.567^-0.256==(-1^-0.256)*(12.567^-0.256)
    : ???
    Can't see how.

    : and is -1 raised to any negative decimal power equla to -1 ???
    No. What is -1 ^ -2? It is 1 / (-1 ^ 2) = 1 / (-1 * -1) = 1.

    Jonathan
    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • is -12.567^-0.256==-(12.567^-0.256)

    (note the brackets)

    now
    -4^-3=-1*pow(4,-3)
    because -1^-3 is an integer and is equal to -1
    but -1^0.5 is complex and i dont know how this can be defined in c
  • Grrr...I need more coffee...

    : is -12.567^-0.256==-(12.567^-0.256)
    :
    : (note the brackets)
    :
    Ah, I see what you're getting at. And no, I'm pretty sure it isn't. So I think what I just suggested was wrong. D'oh.

    : now
    : -4^-3=-1*pow(4,-3)
    : because -1^-3 is an integer and is equal to -1
    Yes, but -4^-4 != -1*pow(4,-4)

    : but -1^0.5 is complex and i dont know how this can be defined in c
    :
    Yup, 'cus that's doing the square root of -1. And roots of negative numbers are complex, so in your example it's going to be complex too. Man am I rusty. :-(

    C99 added support for complex numbers, though that makes your program only work where you have C99 support. Check out complex.h and related things, anyway.

    Jonathan
    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
  • :
    : is -12.567^-0.256==-(12.567^-0.256)
    :
    : (note the brackets)
    :
    : now
    : -4^-3=-1*pow(4,-3)
    : because -1^-3 is an integer and is equal to -1
    : but -1^0.5 is complex and i dont know how this can be defined in c
    :

    http://en.wikipedia.org/wiki/Exponentiation

    wikipedia has a good explaination. A ^ -N is equal to 1 / (A ^ N). In C/C++ terms: 1.0 / pow(a,n);


    =============================================
    never lie -- the government doesn't like the competition. (Author unknown)
  • But the entire problem is that:
    x^y is undefined when x is negative and y is a non-integer number.

    However you could make some personal rule for that and then code it...

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories