0% found this document useful (0 votes)
9 views13 pages

SymPy Library Notes

SymPy is a Python library designed for symbolic mathematics, enabling operations in algebra, calculus, and discrete math. It automates algebraic tasks, supports code generation, and is beneficial for teaching and research. Key features include symbolic computation, equation solving, differentiation, integration, and matrix operations.

Uploaded by

chandras13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views13 pages

SymPy Library Notes

SymPy is a Python library designed for symbolic mathematics, enabling operations in algebra, calculus, and discrete math. It automates algebraic tasks, supports code generation, and is beneficial for teaching and research. Key features include symbolic computation, equation solving, differentiation, integration, and matrix operations.

Uploaded by

chandras13
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Introduction to SymPy Library

What is SymPy?
• - A Python library for symbolic mathematics
• - Written entirely in Python
• - Capable of performing algebra, calculus,
discrete math, etc.
Why Use SymPy?
• - Automates algebraic operations
• - Supports code generation (e.g., in C, Fortran)
• - Useful for teaching, research, and computer
algebra systems
Core Features
• - Symbolic computation
• - Simplification
• - Solving equations
• - Calculus (differentiation/integration)
• - Series, matrices, logic
Getting Started with SymPy
• ```python
• from sympy import *
• x, y = symbols('x y')
• ```
• - `symbols()` creates symbolic variables
• - Use Python shell or Jupyter notebook
Basic Operations
• ```python
• expr = x**2 + 2*x + 1
• expand(expr)
• factor(expr)
• ```
• - `expand()` multiplies out
• - `factor()` simplifies into factors
Solving Equations
• ```python
• solve(x**2 - 4, x)
• ```
• - Returns: `[-2, 2]`
• - Can solve systems of equations too
Differentiation & Integration
• ```python
• diff(sin(x), x)
• integrate(exp(x), x)
• ```
• - `diff()` for differentiation
• - `integrate()` for definite/indefinite integrals
Matrix Operations
• ```python
• M = Matrix([[1, 2], [3, 4]])
• M.inv()
• ```
• - Matrix creation, inversion, determinant
Plotting (Optional)
• ```python
• plot(sin(x), (x, -10, 10))
• ```
• - For simple 2D plots using SymPy's plot
module
Code Generation & Applications
• - Generate C/Fortran code using
`sympy.utilities.codegen`
• - Use in math-based simulations, teaching,
symbolic logic
Summary
• - Easy to use symbolic math library
• - Great for math automation and learning
• - Scales from simple to complex applications
References
• - https://docs.sympy.org
• - SymPy GitHub Repository
• - Python official documentation

You might also like