473,544 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9817
sc*********@gma il.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.0109271476078 30808
>>-1 ** -2
-1.0
>>(-1+0j) ** (-2)
(1+0j)
>>(-1+0j) ** (0.5)
(6.123233995736 766e-17+1j)
>>(-3 + 0j) ** (-4.1111 + 0j)
(0.010268290423 601775-0.0037369461622 949107j)
>>>
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*********@gma il.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...@holdenwe b.comwrote:
schaefer...@gma il.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.0109271476078 30808
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...@gma il.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.224606353822 3773e-16+2j) # real part is almost zero
>>>
(-4.234324+0j)**( 0.5)
(1.259965216411 6278e-16+2.0577473119 894969j)
>>2.05774731198 94969j ** 2
(-4.234324+0j)
>>>

Karthik

Oct 16 '07 #5
sc*********@gma il.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,im aj_part)
(0.010268060212 11755, -0.0037372276904 401318)
Ken
Oct 17 '07 #6
John Machin wrote:
On Oct 17, 8:03 am, Steve Holden <st...@holdenwe b.comwrote:
>schaefer...@gm ail.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.0109271476078 30808

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...@gma il.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,im aj_part)
(0.010268060212 11755, -0.0037372276904 401318)

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*********@gma il.com wrote:
On Oct 17, 4:05 am, Ken Schutte <kschu...@csail .mit.eduwrote:
>schaefer...@gm ail.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,im aj_part)
(0.01026806021 211755, -0.0037372276904 401318)

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*********@gma il.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.999999999999 95
John
Oct 17 '07 #10

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

Similar topics

2
2793
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 script to convert numbers to arbitrary bases. It aims to take any of whole numbers (python ints, longs, or Decimals), rational numbers (n / m n, m...
25
2950
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 the testing of it I discovered that negative numbers were being treated as if they were > 0. I compiled the following on mingw compiler/dev...
1
4324
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 inherited base member's access level in the derived class: its access level in the base class and the type of inheritance (public, protected, or...
6
1832
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 (sometimes) define an abstract base exception class, that all other exceptions in that module inherit from. class FooException(Exception):
29
16701
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
1286
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 and does MyBase.OnMouseUp(mea) does that effect any of the above answers? Thanks in advance for any insight passed along
8
12301
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
2813
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 magic, I wrote the following module. It is mainly useful as a light weight tool to help programmers catch mistakes at definition time (e.g.,...
10
6913
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 //This function raises 1+AIR to a negative n power float power (int num_of_pay, float number) { float result; int i; double AIR;
0
7431
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7370
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7617
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5305
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4924
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3415
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
674
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.