Exploring Computational Physics with Python

In summary: Python write a Gnuplot file then start Gnuplot to visualize data]).In summary, Python is a highly useful and powerful language for computational physics. It is built upon C, making it efficient in terms of speed and performance. It is also a more versatile and popular language compared to Mathematica. Some of its benefits over Mathematica include speed, object orientation, and its wider focus on tasks such as network-focused data handling. However, it cannot perform symbolic computation like Mathematica and its plotting capabilities may not be as advanced. It is also worth learning Fortran for specific purposes, but Python offers more practicality and ease of learning. For a physics major, it is recommended to learn both Matlab and Python, as they both have
  • #1
Winzer
598
0
Hello, I have recently become interested in computational physics. I know a good deal of Mathematica. Recently I have heard great things about Python. My questions are:
1) How useful is Python in computation?
2) Would there be a better program to learn instead of Python for computation?
Any additional comments would be appreciated.
 
Technology news on Phys.org
  • #3
If would have to pick "a couple" of languages to work with python would be one of them.
 
  • #4
PerennialII said:
If would have to pick "a couple" of languages to work with python would be one of them.
Can you name the other ones?

Also, can someone tell me:
1)Two or more benefits of Python over Mathematica
2)Two or more disadvantages of Python over Mathematica
 
  • #5
Winzer said:
Can you name the other ones?

Personally speaking, I'd concentrate on Python and C/C++.

Winzer said:
Also, can someone tell me:
1)Two or more benefits of Python over Mathematica

*: Speed. CPython, the standard distribution of Python that you can download from python.org, is built upon C. Hence modules like Numpy and Scipy have been able to produce code that is in many cases significantly faster than equivalent Mathematica code.

*: Python is an actual programming language. Mathematica, for all its wonderful uses, really isn't a serious language. Object orientation, for instance, is natural and easy to use in Python; although OOP is possible in Mathematica, it's ugly and cumbersome in an ungodly way.

*: Python is a much more powerful language.

*: It's free.

*: It's more popular than Mathematica.

*: It's got a much, much wider focus. For instance, Python will handle all of the numerical work Mathematica can do but can also do nifty, network-focused things with your data once it's been obtained. This is pretty much impossible with Mathematica.

Winzer said:
2)Two or more disadvantages of Python over Mathematica

*: Well, Mathematica's real strength is in symbolic computation. To the best of my knowledge, Python can't do symbolic computation at all.

*: Plotting in Python is poor in comparison to Mathematica, especially to version 7.0.
 
  • #6
Winzer said:
Can you name the other ones?

Also, can someone tell me:
1)Two or more benefits of Python over Mathematica
2)Two or more disadvantages of Python over Mathematica

Thinking about tools which enable to carry out "research tasks" as effectively as possible with a wide range of applicability (thinking about code performance, "usability" of the resulting code and development time) would pick a medium level language like C++, then Python which is actually kind of "in between" due to its performance imho and then Mathematica [scripting wise that is] (followed closely by Matlab, but its necessity is shadowed a bit by Python with scipy and works, although it's very easy to pick up). After those would pick good old Perl for some raw data processing, but most tasks do with Perl can be done nicely with Python.
 
  • #7
Here's a yet another reason to learn Python! Check the open source tool Sage http://www.sagemath.org/
It is a python-based tool that integrates various (powerful) open source tools for numerical computations, statistics, symbolic computations, number theory, algebra(as diverse as group theory, linear algebra, representation theory, commutative algebra, and algebraic geometry), ...

The integration of these tools under Python is exceptional in my opinion! There's a very useful "notebook" a la Mathematica! But much more powerful I'd say!

It got not only great plotting capabilities, but also interactive ones, including Java 3D, take a look at http://wiki.sagemath.org/interact
 
  • #8
Is there a reason why I would learn Python over Fortran?
 
  • #9
Winzer said:
Is there a reason why I would learn Python over Fortran?

Put it this way. In the two or three days you've spent asking other people's opinions, you could already have learned a sizeable and useful amount of Python.
 
  • #10
shoehorn said:
Put it this way. In the two or three days you've spent asking other people's opinions, you could already have learned a sizeable and useful amount of Python.

Oh good sir, who says I haven't been learning python? Not me.
 
  • #11
Winzer said:
Oh good sir, who says I haven't been learning python? Not me.

Neither did I. It was intended as a comparison with Fortran in the sense that in the few days you've been learning Python you've probably learned far more than you could have if you'd chosen Fortran.
 
  • #12
How about mathlab vs phython,which one is the best for a physics major?
 
  • #13
Winzer said:
Is there a reason why I would learn Python over Fortran?

You'll get a whole lot more done :wink: . Comparing languages and "stating" what is needed is always a bit arbitrary (at best), but in "general terms" when learning to do things and so forth Fortran isn't quite as useful as Python (unless everything in your field is written in Fortran for some reason or something similar). Fortran has its uses and Python its own, unless you have something in mind where you especially need something Fortran does very well Python is an animal would recommend. Not to downplay good old Fortran, I still need it :biggrin: .
 
  • #14
Qquantum1 said:
How about mathlab vs phython,which one is the best for a physics major?

Both.
 
  • #15
Qquantum1 said:
How about mathlab vs phython,which one is the best for a physics major?

matlab, maple, mathematica, etc... are all very good for symbolic and numerical calculations and for visualization (thanks to a dazzling array of specialized functions).

Python is more of a general purpose language... with a lot of useful functions imported through libraries and modules... and it's free and open source. For physics, there is this useful library http://vpython.org/

Note that Python (via the optimized numerical linear algebra library NumPy) has many Matlab-like functions and syntax.

If I were you, I'd learn both.

(One thing Python can do (that many other languages can't do as easily) is
interact with other programs... I've written Python (and Perl) programs that write Maple code... then a script can start Maple and execute it. If needed, Python can parse the output of the Maple program and do something else with it... e.g. send post-processed data to another program [like gnuplot].)
 

Related to Exploring Computational Physics with Python

1. What is "Exploring Computational Physics with Python"?

"Exploring Computational Physics with Python" is a book that teaches readers how to use the Python programming language to solve problems in the field of physics. It covers topics such as numerical methods, data analysis, and visualization, with a focus on applying these techniques to solve real-world physics problems.

2. Do I need to have prior programming experience to understand this book?

While some basic knowledge of programming concepts may be helpful, this book is designed for readers with little to no prior programming experience. It provides an introduction to Python and walks readers through the necessary steps to apply computational methods to solve physics problems.

3. What are some specific topics covered in this book?

Some of the specific topics covered in "Exploring Computational Physics with Python" include one-dimensional and multi-dimensional motion, oscillations and waves, electricity and magnetism, and computational techniques for solving differential equations and systems of equations.

4. Are there any prerequisites for reading this book?

The only prerequisite for reading this book is a basic understanding of high school level physics and mathematics. Some familiarity with the Python programming language is also helpful, but not required.

5. What makes "Exploring Computational Physics with Python" a valuable resource for scientists?

This book offers a unique approach to learning computational physics by using the popular and versatile Python programming language. It provides hands-on experience with solving real-world physics problems, making it a valuable resource for scientists who want to enhance their computational skills and apply them to their research or work.

Similar threads

  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
7
Views
660
Replies
6
Views
746
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
1
Views
800
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
Back
Top