[Tutor] Solving physics problems with python

Oscar Benjamin oscar.j.benjamin at gmail.com
Sun Apr 12 15:36:05 EDT 2020


On Sun, 12 Apr 2020 at 14:04, mixipilixi . <mixipilixi at gmail.com> wrote:
>
> I am a physicist and am learning python. I wonder if you could recommend a
> beginners reference for me to learn python with focus on physics
> applications. I would like to learn to do calculations and plot curves
> effectively on basic physics. Eventually I would like to move to more
> complex physics subjects.  One of my interests is quantum computing, among
> others.

Another library you might find interesting is sympy for doing symbolic
calculations:
https://www.sympy.org/en/index.html

If you have sympy installed then you can do things like:

>>> from sympy import *
>>> x = Symbol('x')
>>> equation = 2*x**2 - 1
>>> equation
2*x**2 - 1
>>> equation.diff(x)
4*x
>>> solve(equation, x)
[-sqrt(2)/2, sqrt(2)/2]

Sympy also has a subsection for various topics in physics including
some quantum computing:
https://docs.sympy.org/latest/modules/physics/index.html

--
Oscar


More information about the Tutor mailing list