Why do they act differently with respect to complex numbers?
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information. pow(2, 0+1j)
(0.76923890136397211+0.63896127631363475j) import math math.pow(2, 0+1j)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: can't convert complex to float; use e.g. abs(z)
Apart from handling complex numbers, the built-in pow also has a
modulo efficiency hack.
When would I want to use math.pow? 5 2693
Clueless Moron <Bi********@Microsoft.com> writes: Why do they act differently with respect to complex numbers?
[...] Apart from handling complex numbers, the built-in pow also has a modulo efficiency hack.
When would I want to use math.pow?
For some applications, getting a complex result means you've made a
mistake. And some people don't know what a complex number is, and
would rather have their teeth drilled than find out.
John
You wouldn't know a subtle plan if it painted itself purple and danced
naked on top of a harpsichord singing 'Subtle Plans Are Here Again'
Blackadder
John J. Lee wrote: For some applications, getting a complex result means you've made a mistake. And some people don't know what a complex number is, and would rather have their teeth drilled than find out.
Perhaps, but why should pow() be different from math.pow() in python?
"John J. Lee" <jj*@pobox.com> wrote in message news:87************@pobox.com...
| For some applications, getting a complex result means you've made a
| mistake. And some people don't know what a complex number is, and
| would rather have their teeth drilled than find out.
Can you provide an example when pow with real arguments gives a complex result,
please?
Georgy
|
|
| John
|
| You wouldn't know a subtle plan if it painted itself purple and danced
| naked on top of a harpsichord singing 'Subtle Plans Are Here Again'
|
| Blackadder
Georgy Pruss wrote: "John J. Lee" <jj*@pobox.com> wrote in message news:87************@pobox.com... | For some applications, getting a complex result means you've made a | mistake. And some people don't know what a complex number is, and | would rather have their teeth drilled than find out.
Can you provide an example when pow with real arguments gives a complex result, please?
He could, if Python were not so reluctant: pow(-5,.5)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: negative number cannot be raised to a fractional power
Sad day for the dentist:-)
But:
pow(complex(-5), .5)
(1.3691515264124976e-16+2.2360679774997898j)
pow(-5, complex(.5))
(1.3691515264124976e-16+2.2360679774997898j)
as you might expect.
Peter
"Georgy Pruss" <se*************@hotmail.com> writes: "John J. Lee" <jj*@pobox.com> wrote in message news:87************@pobox.com... | For some applications, getting a complex result means you've made a | mistake. And some people don't know what a complex number is, and | would rather have their teeth drilled than find out.
Can you provide an example when pow with real arguments gives a complex result, please?
[...]
I was thinking about results of earlier calculations providing the
argument for pow.
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frank Millman |
last post by:
Hi all
I was helping my niece with her trigonometry homework last night. Her
calculator's batteries were flat, so I thought I would use Python's
math module to calculate sin, cos, and tan.
I...
|
by: Jussi Mononen |
last post by:
Hi,
I'm having problems to successfully execute the test scripts on a
Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up
with the following error message
"PARI: *** ...
|
by: limelight |
last post by:
I have discovered a math error in the .NET framework's Log function. It
returns incorrect results for varying powers of 2 that depend on whether the
program is run from within the IDE or from the...
|
by: cwdjrxyz |
last post by:
Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels...
|
by: bravesplace |
last post by:
Hello,
I am using the folling funtion to round a number to a single digit on
my form:
function round1(num)
{
return Math.round(num*1)/1
}
|
by: Gregory Pietsch |
last post by:
I'm writing a portable implementation of the C standard library for
http://www.clc-wiki.net and I was wondering if someone could check the
functions in math.h for sanity/portability/whatever. I'm...
|
by: Sambo |
last post by:
I have the following module:
-------------------------------
import math
def ac_add_a_ph( amp1, ph1, amp2, ph2 ):
amp3 = 0.0
ph3 = 0.0
ac1 = ( 0, 0j )
ac2 = ( 0, 0j )
|
by: kirby.urner |
last post by:
Cyber-curricula have a leveling aspect, as kids
nearer Katrina's epicenter tune in and bliss out
on 'Warriors of the Net' (why wait for stupid big
dummy textbooks to catch up?). They feel more...
|
by: =?Utf-8?B?UmVuZQ==?= |
last post by:
Hello everyone
I have a problem with Math.Round, it´s ocurring some strange:
Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99
Why?? What is the problem?
Help ME !!!!
|
by: bH |
last post by:
Hi All,
I have been looking at javascript drawing from this website :
http://www.cwdjr.net/geometricDraw/pentagon_draw.html"
and I am wondering why the author made it
into two images : upper...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |