473,287 Members | 1,582 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,287 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 9778
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.