Using sympy for proofs in Jupyter

40 views
Skip to first unread message

CM

unread,
Nov 10, 2017, 3:20:08 AM11/10/17
to comphys
Sympy can be good for proofs, because you can avoid making transcription and algebra errors.
  There is a bit of an art to making computer algebra packages represent solutions in a usable way, so this method isn't for everyone.
  I am attaching a heavily-commented notebook for E4.7b, in part for my own reference.  If anyone knows better ways to do some of these steps, feel free to  comment.

HW4b-E4.7b-cmallary-posted.ipynb

Jay Wang

unread,
Nov 10, 2017, 6:36:31 PM11/10/17
to com...@googlegroups.com
Thanks for posting a beautifully crafted code. It shows some very useful sympy tricks.
One can use subscripts to make it look neater, e.g. to print $r_{max}$, set
rmax = symbols('r_{max}')

Added:
One can also use inequality solvers to do simple proofs, for instance, the von Neumann analysis of waves in Ch. 6, Eq. (6.78) to (6.81) (see attached code, or link http://www.faculty.umassd.edu/j.wang/p521/inequal.ipynb):
from sympy import *
from sympy.solvers.inequalities import solve_univariate_inequality
x
= symbols('x', real=True)

# x = beta^2*s^2 per Eq. (6.78)--(6.81)
print (solve_univariate_inequality(abs(1-2*x**2)>1, x))
print (solve_univariate_inequality(abs(1-2*x**2)<=1, x))


inequal.py
Reply all
Reply to author
Forward
0 new messages