SymPy Tutorial
Aaron Meurer, Ondˇrej Cert´ık,Amitˇ Kumar, Jason Moore, Sartaj Singh, Harsh Gupta
July 11, 2016
All materials for today’s tutorial are at
1 / 21 http://www.sympy.org/scipy-2016-tutorial/ Outline
SymPy Introduction
Goal
Features
History
Present
Future
Tutorial
Intro to SymPy and Basic features
Solving real life problems
2 / 21 “SymPy is an open source Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.”
SymPy Goal
Goal Provide a symbolic manipulation library in Python.
3 / 21 SymPy Goal
Goal Provide a symbolic manipulation library in Python.
“SymPy is an open source Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.”
3 / 21 Why SymPy?
Standalone
Full featured
BSD licensed
Embraces Python
Usable as a library
4 / 21 Features
Core Capabilities Calculus Basic arithmetic: Support for operators such as Limits: limx→0 x log(x) = 0 +, -, *, /, ** (power) Differentiation Simplification Integration: It uses extended Risch-Norman Expansion heuristic Functions: trigonometric, hyperbolic, Taylor (Laurent) series exponential, roots, logarithms, absolute value, spherical harmonics, factorials and gamma Solving equations functions, zeta functions, polynomials, special Polynomial equations functions, . . . Algebraic equations Substitution Differential equations Numbers: arbitrary precision integers, rationals, and floats Difference equations Systems of equations Noncommutative symbols Pattern matching Combinatorics Polynomials Permutations Basic arithmetic: division, gcd, . . . Combinations Factorization Partitions Square-free decomposition Subsets Gr¨obnerbases Permutation Groups: Polyhedral, Rubik, Partial fraction decomposition Symmetric, . . . Resultants Prufer and Gray Codes
5 / 21 Features
Discrete math Plotting Binomial coefficients Coordinate modes Summations Plotting Geometric Entities Products 2D and 3D Number theory: generating prime numbers, Interactive interface primality testing, integer factorization, . . . Colors Logic expressions Physics Matrices Units Basic arithmetic Mechanics Eigenvalues/eigenvectors Quantum Determinants Gaussian Optics Inversion Pauli Algebra Solving Abstract expressions Statistics Geometric Algebra Normal distributions Uniform distributions Geometry Probability points, lines, rays, segments, ellipses, circles, Printing polygons, . . . Intersection Pretty printing: ASCII/Unicode pretty printing, Tangency LaTeX Similarity Code generation: C, Fortran, Python
6 / 21 History
History
Ondˇrej Cert´ıkstartedˇ the project in 2006.
Development took off in 2007 when SymPy first participated in Google Summer of Code. We have participated in every Google Summer of Code since.
In 2011, Aaron Meurer (who also joined from Google Summer of Code) took over as lead developer.
7 / 21 Present
Current Status
Over 450 contributors.
Current code base has over 400,000 lines of code and documentation.
We have crossed the point of “sympy a toy” to “sympy a tool”
8 / 21 Future
GSoC (1/2) These are our current GSoC projects. Expect to see these features by the end of the summer.
Group Theory, Gaurav Dhingra
Extending solveset, Kshitij Saraogi
Completing Solveset, Shekhar Prasad Rajak
Implementation of Holonomic Functions, Shubham Tibra
Implementation of Singularity Functions to solve Beam Bending problems, Sampad Kumar Saha
9 / 21 Future
GSoC (2/2) These are our current GSoC projects. Expect to see these features by the end of the summer.
Adding to SymEngine’s Polynomial functionality and interfacing it with FLINT & Piranha Srajan Garg
Implementing Finite Fields and Set module in SymEngine Nishant Nikhil
10 / 21 Future
Other Plans
New assumptions
Make things faster
SymEngine (https://github.com/symengine)
Implement more algorithms, so we can compute more things (and also make them faster)
Replacing solve with solveset
Encourage people to use SymPy for many applications
https://github.com/sympy/sympy/wiki/gsoc-2016-ideas for full list of things we want done
11 / 21 Projects Using SymPy
Sage: A CAS, visioned to be a viable free open source alternative to Magma, Maple, Mathematica and MATLAB. Sage includes many open source mathematical libraries, including SymPy.
SageMathCloud: SageMathCloud is a web-based cloud computing and course management platform for computational mathematics.
Mathpix: An iOS App, that detects handwritten math as input, and uses SymPy Gamma to evaluate the math input and generate the relevant steps to solve the problem.
PyDy: Multibody Dynamics with Python.
IKFast: IKFast is a robot kinematics compiler provided by OpenRAVE. It analytically solves robot inverse kinematics equations and generates optimized C++ files. It uses SymPy for its internal symbolic mathematics. 12 / 21 Projects Using SymPy
Octave Symbolic: The Octave-Forge Symbolic package adds symbolic calculation features to GNU Octave. These include common CAS tools such as algebraic operations, calculus, equation solving, Fourier and Laplace transforms, variable precision arithmetic, and other features.
galgebra: Geometric algebra (previously sympy.galgebra).
SymPy.jl: Provides a Julia interface to SymPy using PyCall.
Mathics: Mathics is a free, general-purpose online CAS featuring Mathematica compatible syntax and functions. It is backed by highly extensible Python code, relying on SymPy for most mathematical tasks.
SfePy: Simple finite elements in Python.
13 / 21 Projects Using SymPy
Quameon: Quantum Monte Carlo in Python.
Lcapy: Experimental Python package for teaching linear circuit analysis.
Quantum Programming in Python: Quantum 1D Simple Harmonic Oscillator and Quantum Mapping Gate. A LaTeX Expression project: Easy LTEX typesetting of algebraic expressions in symbolic form with automatic substitution and result computation.
Symbolic statistical modeling: Adding statistical operations to complex physical models.
14 / 21 Authors
Ondˇrej Cert´ıkˇ James Aspnes Boris Timokhin Florian Mickler James Pearson Fabian Pedregosa Nimish Telang Robert Nicolas Pourcelot Matthew Brett Jurjen N.E. Bos Abderrahim Kitouni Andy R. Terrel Ben Goodrich Addison Cugini Mateusz Paprocki Pan Peng Hubert Tsang Toon Verstraelen Nicholas J.S. Kinar Marc-Etienne Friedrich Hagedorn Konrad Meyer Ronan Lamy Harold Erbin M.Leveille Elrond der Henrik Johansson James Abbatiello Thomas Dixon Brian Jorgensen Elbenfuerst Priit Laes Ryan Krauss Crist´ov˜aoSousa Jason Gedge Rizgar Mella Freddie Witherden Bill Flynn Andre de Fortier Robert Schwarz Felix Kaiser Brian E. Granger Kevin Goodsell Smit Pearu Peterson Roberto Nobrega Andrew Straw Jorn Baayen Mark Dewing Fredrik Johansson David Roberts Kaifeng Zhu Eh Tan Alexey U. Chris Wu Sebastian Kr¨amer Ted Horst Renato Coutinho Gudchenko Ulrich Hecht Vinzent Steinberg Andrew Docherty Oscar Benjamin Gary Kerr Goutham Riccardo Gori Akshay Srinivasan Øyvind Jensen Sherjil Ozair Lakshminarayan Case Van Horsen Aaron Meurer Julio Idichekop Filho Oleksandr Gituliar David Lawrence Stepan Roucka Barry Wardell Lukasz Pankowski Sean Vig Jaroslaw Tworek Ali Raza Syed Tomasz Buchert Chu-Ching Huang Prafullkumar P. Tale David Marek Stefano Maggiolo Vinay Kumar Fernando Perez Vladimir Peri´c Bernhard R. Link Robert Cimrman Johann Raffaele De Feo Tom Bachmann Andrej Tokarˇc´ık Bastian Weber Cohen-Tanugi Christian Muise Yuri Karadzhov Or Dvory Sebastian Krause Jochen Voss Matt Curry Saroj Adhikari Sebastian Kreft Luke Peterson Kazuo Thow Pauli Virtanen Dan Chris Smith Christian Schubert Robert Kern Alan Bromborsky Thomas Sidoti Jezreel Ng
15 / 21 Authors (continued)
Vladimir Lagunov Min Ragan-Kelley Imran Ahmed Swapnil Agarwal Prateek Papriwal Matthew Rocklin Emma Hogan Manzoor Kendhia Arpit Goyal Saptarshi Mandal Nikhil Sarda LjubiˇsaMo´ci´c jerryma1121 Angadh Nanjangud Gilbert Gede Julien Rioux Piotr Korgul Joachim Durchholz Comer Duncan Anatolii Koval Roberto Colistete, Jim Zhang Martin Poviˇser Jens H. Nielsen Tomo Lazovich Jr. Sam Sleight Siddhant Jain Joseph Dougherty Pavel Fedotov Raoul Bourquin tsmars15 Kevin Hunter marshall2389 Jack McCaffery Gert-Ludwig Ingold Chancellor Arkantos Michael Mayorov Guru Devanla Jeremias Yehdegho Srinivas Vasudevan Stepan Simsa Nathan Alison George Waksman Kibeom Kim Jason Moore Tobias Lenz Christian B¨uhler Alexandr Popov Gregory Ksionda Miha Marolt Siddhanathan Carsten Knoll Tarun Gaba Tom´aˇsBambas Tim Lahey Shanmugam Bharath M R Takafumi Arakaki Raymond Wong Luis Garcia Tiffany Zhu Matthias Toews Saurabh Jha Luca Weihs Matt Rajca Tristan Hume Sergiu Ivanov Rom le Clair Shai ’Deshe’ David Li Alexey Subach Jorge E. Cardona Angus Griffith Wyborski Alexandr Gudulin Joan Creus Sanket Agarwal Timothy Reluga Thomas Wiecki Bilal Akhtar Geoffry Song Manoj Babu K. Brian Stephanik Oscar´ N´ajera Grzegorz Swirski´ Puneeth Chaganti Sai Nikhil Alexander Mario Pernici Matt Habel Marcin Kostrzewa Aleksandar Makelov Ebersp¨acher Benjamin McDonald David Ju Natalia Nawara Sachin Irukula Sachin Joglekar Sam Magura Nichita Utiu vishal Raphael Michel Tyler Pirtle Stefan Krastanov Nikolay Lazarov Shruti Mangipudi Ashwini Oruganti Vasily Povalyaev Bradley Froehle Steve Anton Davy Mao Andreas Kloeckner Colleen Lee
16 / 21 Authors (continued)
Matthew Hoff Bj¨ornDahlgren Chris Conley James Goppert Ben Lucato Niklas Th¨orne Christophe Tim Swast rathmann Kunal Arora Huijun Mai Saint-Jean Dmitry Batkovich Avichal Dayal Henry Gebhardt Marek Suppaˇ Demian Wassermann Francesco Bonazzi Paul Scott Dammina Ramana Venkata Khagesh Patel Yuriy Demidov Shipra Banga Sahabandu Prasoon Shukla Stephen Loo Rick Muller Pramod Ch Shukla Stefen Yin hm Manish Gill Akshay Ralph Bean Thomas Hisch Patrick Poitras Markus M¨uller Buck Shlegeris richierichrawr Madeleine Ball Katja Sophie Hotz Amit Saha Jonathan Miller John Connor Case Van Horsen Varun Joshi Jeremy Edward Schembor Juan Luis Cano Mary Clark Chetna Gupta QuaBoo Rajath Shashidhara Rodr´ıguez Rishabh Dixit Thilina Rathnayake Stefan van der Walt Zamrath Nizam Sahil Shekhawat Manoj Kumar Max Hutchinson David Joyner Aditya Shah Kundan Kumar Akshit Agarwal Shravas K Rao Lars Buitinck Rajat Aggarwal Stas Kelvich CJ Carey Matthew Tadd Alkiviadis G. Akritas Sambuddha Basu sevaader Patrick Lacasse Alexander Hirzel Vinit Ravishankar Zeel Shah Dhruvesh Vijay Ananya H Randy Heydon Mike Boyle Abhinav Chanda Parikh Tarang Patel Oliver Lee Heiner Kirchhoffer Jim Crist Venkatesh Halli Christopher Dembia Seshagiri Prabhu Pablo Puente Sudhanshu Mishra Lennart Fricke Benjamin Fishbein Pradyumna James Fiedler Anurag Sharma Vlad Seghete Sean Ge Erik Welch Harsh Gupta Soumya Dipta Shashank Agarwal Amit Jamadagni Eric Nelson Tuomas Airaksinen Biswas carstimon Ankit Agrawal Roland Puntaier Paul Strickland Sushant Hiray Pierre Haessig
17 / 21 Authors (continued)
Maciej Baranski Leonid Blouvshtein Guillaume Gay Lucas Jones Michael Zingale Benjamin Gudehus Peleg Michaeli Ray Cathcart Gregory Ashton Chak-Pong Chung Faisal Anees ck Lux Mihir Wadwekar Jennifer White David T Mark Shoulson zsc347 Tuan Manh Lai Renato Orsino Phil Ruffwind Robert Johansson Hamish Dickson Asish Panda Michael Boyle Sebastian Koslowski Kalevi Suominen Michael Gallaspy Darshan Chaudhary Alistair Lynn Kumar Krishna Kaushik Varanasi Roman Inflianskas Alec Kalinin Govind Sahai Agrawal Fawaz Alazemi Duane Nykamp Ralf Stephan Adam Bloomston Dustin Gadal Ambar Mehrotra Ted Dokos Aaditya Nair Kyle McDaniel operte David P. Sanders Sunny Aggarwal Jayesh Lahori Nguyen Truong Duy Yu Kobayashi Peter Brady Victor Brebenar Harshil Goel Alex Lindsay Shashank Kumar John V. Siratt Akshat Jain Luv Agarwal Mathew Chong Timothy Cyrus Sarwar Chahal Shivam Vats Jason Ly Jason Siefken Devyani Kota Nathan Woods Longqi Wang Lokesh Sharma Gaurav Dhingra Keval Shah Colin B. Macdonald Juan Felipe Osorio Sartaj Singh Gao, Xiang Dzhelil Rufat Marcus N¨aslund GitRay Chris Swierczewski Kevin Ventullo Pastafarianist Clemens Novak Lukas Zorich Konstantin Togoi mao8 Sourav Singh Mridul Seth Eric Miller Param Singh Isuru Fernando Jacob Garber Craig A. Stoudt Venkata Ramana Sumith Shivam Tyagi Vinay Raj Cody Herbst Juha Remes Richard Otis Mihai A. Ionescu Nishith Shah Philippe Bouafia Rich LaSota immerrr AMiT Kumar Peter Schmidt dustyrockpyle Chai Wah Wu Yury G. Kudryashov Jiaxing Liang Anton Akhmerov
18 / 21 Authors (continued)
GolimarOurHero Madhyastha Guillaume Jacquenot Sanya Khurana Nathan Musoke Prashant Tyagi Tanu Hari Dixit Bhautik Mavani Aman Deep Abhishek Garg Matthew Davis Shekhar Prasad Michal Radwa´nski Aravind Reddy Dana Jacobsen Tschijnmo TSCHAU Rajak Jerry Li Abhishek Verma Vasiliy Dommes Alexander Bentkamp Aqnouch Pablo Zubieta Matthew Parnell Phillip Berndt Moo VI Mohammed Curious72 Thomas Hickman Haimo Zhang Jack Kemp Arafat Dad Khan Chaitanya Sai Akshay Siramdas Subham Tibra Kshitij Saraogi Boris Atamanovskiy Alaparthi YiDing Jiang Anthony Scopatz Thomas Baruchel Sam Tygier arihant parsoya Jatin Yadav bluebrook Nicol´as Jai Luthra Ruslan Pisarev Matthew Thomas Normal Human Guar´ın-Zapata Guo Xingjian Akash Trehan Rehas Sachdeva Josh Burkart Jens Jørgen Sandeep Veethu Nishant Nikhil Michael Mueller Dimitra Konomi Mortensen Archit Verma Vladimir Poluhsin Srajan Garg ChristinaZografou Sampad Kumar Saha Shubham Tibra Akshay Nagar Prabhjot Singh FiachAntaw Eva Charlotte Mayer Ashutosh Saboo James Brandon Haruki Moriguchi Langston Barrett Laura Domine Michael S. Hansen Milam Tom Gijselinck Krit Karan Justin Blythe Anish Shah Abhinav Agarwal Nitin Chaudhary G. D. McBain Meghana Harshil Goel Rishabh Daal Alex Argunov Prempal Singh
19 / 21 Here at SciPy
Talks
Jason Moore, Simulating Robot, Vehicle, Spacecraft, and Animal Motion with Python (Advanced) (Tutorial). Monday 1:30 PM - 5:30 PM - Room 103
Aaron Meurer, Anthony Scopatz SymPy Code Generation. Thursday 11:30 PM - 12:00 PM - Room 204
Ondˇrej Cert´ık,Isuruˇ Fernando, Thilina Rathnayake, Abhinav Agarwal SymEngine: A Fast Symbolic Manipulation Library. Friday 3:30 - 4:00 - Room 204
20 / 21 Let’s begin!
21 / 21