### Python for learning Science and Maths

In the high school classes, we learn about the various branches of mathematics, like geometry, algebra, trigonometry, calculus etc. , without bothering much about their interconnections. Plotting the graphs of different algebraic and trigonometric functions helps understanding them better. Simple numerical methods can demonstrate the connection between algebra and calculus. This knowledge is useful for for exploring the problems in physics in a different manner.

This document explains the implementation of this concept using the Python programming language and the Python modules like numpy, matplotlib and scipy. It attempts to introduce Python as an an extension to your existing knowledge of algebra and logic.

On the computer front, you only need to know how to use a text editor and how to run the Python interpreter from a text terminal. We are using the editor called gedit and a command terminal under Ubuntu GNU/Linux distribution. The software requirement is Python Interpreter along with Numpy, Scipy and Matplotlib packages.

Several videos made during writing these examples also have been uploaded to the Youtube. (Keeping the RecordmyDesktop program running and mumbling while writing code can generate the drag and audio comparable to that of a 19th century steam locomotive)

plot-equation.py : Plotting Graphs using numpy and matplotlib. The example demonstrates sine(x), you may also try other functions. screenshot

sum-of-sines.py : Sum of two sine waves result in beats.  screenshot.

product-of-sines.py
: Amplitude modulation by multiplying two sine waves.  screenshot

3phase-ac.py : Amplitude modulation by multiplying two sine waves.  screenshot

mass-spring-euler.py : Solve the mass on a spring system using Euler method of integration. screenshot

mass-spring-visual.py
: Mass Spring system animation using python-visual, computation using Euler method of integration

accn-vel-from-pos.py
: Calculate acceleration and velocity from position data. screenshot

integrate-trapez.py : Calculate the area under an arc of unit radius from x=0 to 1, using trapezoid rule . Compare the result with pi/4. screenshot

integrate-scipy-quad.py : Calculate the area under an arc of unit radius from x=0 to 1, using scipy.integrate.quad() function

pos-time-plot-euler.py :  One dimensional motion. Velocity and initial position given. Use Euler integration to plot x(t) . screenshot

rdecay-euler.py
: Plot the radioactive decay curve calculated using Euler method of solving differential equation. screenshot

rdecay-scipy.py
: Radioactive decay curve. dN/dt = L * N, solved using scipy.integrate.odeint() . screenshot

rdecay2-scipy.py : Radioactive decay curve. dN/dt = L * N. Two of them solved at a time using scipy.integrate.odeint() . screenshot

second-order-de-scipy.py : Solving second order equation by splitting into two first order ones. solve d2y/dx2 = -y  gives  y=sin(x).  screenshot

projectile-2d-euler.py : Projectile motion, trajectory in x-y plane calculated using Euler's method. screenshot

projectile-2d-scipy.py : Projectile motion, trajectory in x-y plane calculated using scipy.integrate.odeint(). screenshot

mass-spring-scipy.py : Solve the mass on a spring system using scipy.integrate.odeint(). screenshot

Lorentz-force-scipy.py : Trajectory of a charged particle in electric and magnetic fields. screenshot

Lorentz-force-scipy-vector.py : Trajectory of a charged particle in electric and magnetic fields, using vector equations. screenshot

Lorentz-force-euler.py : Trajectory of a charged particle in electric and magnetic fields. screenshot , circle is becoming spiral due to computational error.

plot-data-3d.py : #Reads multi-column text data from files and plots the first 3 columns, screenshot shows the data from file.

plot-data-2d.py : #Reads multi-column text data from files and plots the first 2 columns, screenshot shows the data from file.

Python book and Code Browser

Download Python for Education is PDF format.  The Code Browser can be installed on Debian and Ubuntu (>14.04).