473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

negative base raised to fractional exponent

Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.

Oct 16 '07 #1
10 9794
sc*********@gmail.com wrote:
Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.
A couple of questions.

1. How do you approximate a complex number in the reals? That doesn't
make sense.

2. x ^ -4.1111 = 1 / (x ^ 4.1111), so where do complex numbers enter
into this anyway?

3. I think you will find the complex numbers start to emerge as you
explore fractional exponents.

This being Python, and an interactive interpreter being available, you
can always just try it:
>>-3 ** -4.1111
-0.010927147607830808
>>-1 ** -2
-1.0
>>(-1+0j) ** (-2)
(1+0j)
>>(-1+0j) ** (0.5)
(6.123233995736766e-17+1j)
>>(-3 + 0j) ** (-4.1111 + 0j)
(0.010268290423601775-0.0037369461622949107j)
>>>
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

Oct 16 '07 #2
Steve Holden wrote:
sc*********@gmail.com wrote:
>Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.
A couple of questions.

1. How do you approximate a complex number in the reals? That doesn't
make sense.

2. x ^ -4.1111 = 1 / (x ^ 4.1111), so where do complex numbers enter
into this anyway?
When *x* is negative and the exponent is fractional.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Oct 16 '07 #3
On Oct 17, 8:03 am, Steve Holden <st...@holdenweb.comwrote:
schaefer...@gmail.com wrote:
Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.

A couple of questions.

1. How do you approximate a complex number in the reals? That doesn't
make sense.

2. x ^ -4.1111 = 1 / (x ^ 4.1111), so where do complex numbers enter
into this anyway?

3. I think you will find the complex numbers start to emerge as you
explore fractional exponents.
This is part of the story -- the other part is that the story differs
depending on whether x is positive or negative.
>
This being Python, and an interactive interpreter being available, you
can always just try it:
>>-3 ** -4.1111
-0.010927147607830808
Steve, Trying to memorise the operator precedence table for each of
several languages was never a good idea. I admit advanced age :-) and
give up and use parentheses, just like the OP did:
>>(-3)**-4.11111
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: negative number cannot be raised to a fractional power

Best regards,
John

Oct 16 '07 #4
On Oct 16, 2:48 pm, schaefer...@gmail.com wrote:
Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.
Use complex numbers. They are part of python (no special modules
needed).
Just write your real number r, as r+0j

e.g. square-root of -4 is 2j
>>(-4+0j)**(0.5)
(1.2246063538223773e-16+2j) # real part is almost zero
>>>
(-4.234324+0j)**(0.5)
(1.2599652164116278e-16+2.0577473119894969j)
>>2.0577473119894969j ** 2
(-4.234324+0j)
>>>

Karthik

Oct 16 '07 #5
sc*********@gmail.com wrote:
Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.
As others have said, you can use Python's complex numbers (just write -3
as -3+0j). If for some reason you don't want to, you can do it all with
reals using Euler's formula,

(-3)^-4.11111 = (-1)^-4.11111 * 3^-4.11111
=
e^(j*pi*-4.11111) * 3^-4.11111
=
(cos(pi*-4.11111) + j*sin(pi*-4.11111)) * 3^-4.11111

in Python:
>>import math
real_part = (3**-4.11111) * math.cos(-4.11111 * math.pi)
imaj_part = (3**-4.11111) * math.sin(-4.11111 * math.pi)
(real_part,imaj_part)
(0.01026806021211755, -0.0037372276904401318)
Ken
Oct 17 '07 #6
John Machin wrote:
On Oct 17, 8:03 am, Steve Holden <st...@holdenweb.comwrote:
>schaefer...@gmail.com wrote:
>>Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.
A couple of questions.

1. How do you approximate a complex number in the reals? That doesn't
make sense.

2. x ^ -4.1111 = 1 / (x ^ 4.1111), so where do complex numbers enter
into this anyway?

3. I think you will find the complex numbers start to emerge as you
explore fractional exponents.

This is part of the story -- the other part is that the story differs
depending on whether x is positive or negative.
>This being Python, and an interactive interpreter being available, you
can always just try it:
> >>-3 ** -4.1111
-0.010927147607830808

Steve, Trying to memorise the operator precedence table for each of
several languages was never a good idea. I admit advanced age :-) and
give up and use parentheses, just like the OP did:
>>>(-3)**-4.11111
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: negative number cannot be raised to a fractional power

Best regards,
John
Well I guess I'd better admit to advances age too. Particularly since
there was a python-dev thread about precedence, unaries and
exponentiation not too long ago.

regards
Steve

--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

Oct 17 '07 #7
On Oct 17, 4:05 am, Ken Schutte <kschu...@csail.mit.eduwrote:
schaefer...@gmail.com wrote:
Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.

As others have said, you can use Python's complex numbers (just write -3
as -3+0j). If for some reason you don't want to, you can do it all with
reals using Euler's formula,

(-3)^-4.11111 = (-1)^-4.11111 * 3^-4.11111
=
e^(j*pi*-4.11111) * 3^-4.11111
=
(cos(pi*-4.11111) + j*sin(pi*-4.11111)) * 3^-4.11111

in Python:
>>import math
>>real_part = (3**-4.11111) * math.cos(-4.11111 * math.pi)
>>imaj_part = (3**-4.11111) * math.sin(-4.11111 * math.pi)
>>(real_part,imaj_part)
(0.01026806021211755, -0.0037372276904401318)

Ken
Thank you for this. Now I need to somehow express this as a real
number. For example, I can transform the real and imaginary parts into
a polar coordinate giving me the value I want:

z = sqrt( real_part**2 + imaj_part**2 )

but this is an absolute terms. How does one determine the correct sign
for this value?
Oct 17 '07 #8
sc*********@gmail.com wrote:
On Oct 17, 4:05 am, Ken Schutte <kschu...@csail.mit.eduwrote:
>schaefer...@gmail.com wrote:
>>Does anyone know of an approximation to raising a negative base to a
fractional exponent? For example, (-3)^-4.11111 since this cannot be
computed without using imaginary numbers. Any help is appreciated.
As others have said, you can use Python's complex numbers (just write -3
as -3+0j). If for some reason you don't want to, you can do it all with
reals using Euler's formula,

(-3)^-4.11111 = (-1)^-4.11111 * 3^-4.11111
=
e^(j*pi*-4.11111) * 3^-4.11111
=
(cos(pi*-4.11111) + j*sin(pi*-4.11111)) * 3^-4.11111

in Python:
> >>import math
real_part = (3**-4.11111) * math.cos(-4.11111 * math.pi)
imaj_part = (3**-4.11111) * math.sin(-4.11111 * math.pi)
(real_part,imaj_part)
(0.01026806021211755, -0.0037372276904401318)

Ken

Thank you for this. Now I need to somehow express this as a real
number. For example, I can transform the real and imaginary parts into
a polar coordinate giving me the value I want:

z = sqrt( real_part**2 + imaj_part**2 )

but this is an absolute terms. How does one determine the correct sign
for this value?
This is a complex number with non-zero imaginary part - there is no way
to "express it as a real number". Depending what you are trying to do,
you may want the magnitude, z, which is by definition always positive.
Or, maybe you just want to take real_part (which can be positive or
negative). Taking just the real part is the "closest" real number, in
some sense.
Oct 17 '07 #9
sc*********@gmail.com writes:
[...]
Thank you for this. Now I need to somehow express this as a real
number. For example, I can transform the real and imaginary parts into
a polar coordinate giving me the value I want:

z = sqrt( real_part**2 + imaj_part**2 )

but this is an absolute terms. How does one determine the correct sign
for this value?
If you mean the angle
>>import math
x = (-3 + 0j) ** (-37/9.)
math.atan2(x.imag, x.real) * (180 / math.pi)
-19.99999999999995
John
Oct 17 '07 #10
sc*********@gmail.com wrote:
Thank you for this. Now I need to somehow express this as a real
number. For example, I can transform the real and imaginary parts
into a polar coordinate giving me the value I want:

z = sqrt( real_part**2 + imaj_part**2 )

but this is an absolute terms.
Not really. It is just the "absolute value" which is a property of
the complex number; it is (as already stated) by definition always
positive. There doesn't exist any underlying "real" value from
which a sign is stripped to yield the absolute value of z.
How does one determine the correct sign for this value?
In this case, the background (what you model using this complex
number) is of great importance.

Consider learning more about complex numbers; especially about how
they can be represented as a point on the complex plane
(<http://en.wikipedia.org/wiki/Complex_plane>), understanding this
makes understanding and dealing with complex numbers much easier.

Regards,
Björn

--
BOFH excuse #31:

cellular telephone interference

Oct 17 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian van den Broek | last post by:
Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a...
25
by: Jason | last post by:
Hi, below is example code which demonstrates a problem I have encountered. When passing a number to a function I compare it with a string's size and then take certain actions, unfortunately during...
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
6
by: Ben Finney | last post by:
Howdy all, Okay, so Guido doesn't like Abstract Base Classes, and interfaces are the way of the future. But they're not here now, and I understand ABCs better. I want my modules to...
29
by: Peter Ammon | last post by:
What's the most negative double value I can get? Is it always guaranteed to be -DBL_MAX? If so, why (or rather, where)? Thanks.
4
by: Just Me | last post by:
If a derived class handles MyBase.Mouseup does the base class have to raise the event? If both the base and derived class handle it will they both receive it? If the base overrides OnMouseup...
8
by: better_cs_now | last post by:
Hello all, I'd like to get the negative value of largest possible magnitude for a float. I've considered: -numeric_limits<float>::max() and -numeric_limits<float>::infinity()
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
10
by: thatwhiteguy | last post by:
I am trying to create a function that computes a negative exponent. This is what I have, but it is not returning the proper answer. I was wondering if anyone can see where I have gone wrong. Thanks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.