I have just started in python and I am reading
9.3. cmath ? Mathematical functions for complex numbers — Python v2.7 documentation
what is the difference between these and the sum([]) function
I can use sum([4.5, 5.5]) to return the sum but the other ones return an error
NameError: name 'tan' is not defined
what do i have to do to use all these math functions?
and what is the difference between math and cmath?
math and cmath
Started by xzwerm, Oct 10 2010 10:47 AM
3 replies to this topic
#1
Posted 10 October 2010 - 10:47 AM
|
|
|
#2
Posted 10 October 2010 - 11:00 PM
Complex numbers are a fairly advanced mathematical concept and chances are you won't have encountered them if you haven't done any advanced maths courses. I don't think I really got to grips with them until university but I may have studied them at school as well.
Basically a complex number is made up of two parts, the real and the imaginary. The real part is just like any 'normal' number while the complex number is expressed as a multiple of i, where i is the square root of -1.
If you are struggling to follow the documentation for cmath I would recommend one of two things
1. Read up on complex numbers. It's an incredibly rich topic but the basics should be enough for now.
2. Leave the cmath module for now. If you don't understand complex numbers chances are that you won't ever want or need to use the module.
Basically a complex number is made up of two parts, the real and the imaginary. The real part is just like any 'normal' number while the complex number is expressed as a multiple of i, where i is the square root of -1.
If you are struggling to follow the documentation for cmath I would recommend one of two things
1. Read up on complex numbers. It's an incredibly rich topic but the basics should be enough for now.
2. Leave the cmath module for now. If you don't understand complex numbers chances are that you won't ever want or need to use the module.
If there's a new way, I'll be the first in line.
But, it better work this time.
But, it better work this time.
#3
Posted 11 October 2010 - 11:14 AM
so are math and cmath only used with complex numbers? I just thought i could use the python interpreter to solve trigonometric and other math problems.
#4
Posted 11 October 2010 - 12:37 PM
Only cmath is used for complex numbers. For regular use the math module should he fine.
If there's a new way, I'll be the first in line.
But, it better work this time.
But, it better work this time.


Sign In
Create Account

Back to top









