Commit 13ecb45a authored by Aitor Perez's avatar Aitor Perez

added sympy examples

parent 6b2c43e6
......@@ -199,6 +199,45 @@ plt.show()
# %% Slide: Sympy
from sympy import *
# Import package
x = symbols('x')
y = symbols('y')
# Create symbolic variables
a = x + y # x + y
b = a - x # y
c = expand(a**2) # x**2 + 2*x*y + y**2
d = factor(c) # (x + y)**2
init_printing(use_unicode = True)
# Generates a nice human-readable output
F = exp(x)*sin(x)
f = diff(F, x) # exp(x)*sin(x) + exp(x)*cos(x)
integrate(f, x) # exp(x)*sin(x)
integrate(exp(-x), (x, -oo, oo)) # oo
limit(sin(x)/x, x, 0) # 1
solve(x**2 + 2, x) # [-sqrt(2)i, sqrt(2)i]
u = Function('u')
t = symbols('t')
lhs = diff(u(t), t, t) - u(t)
rhs = exp(t)
dsolve(Eq(lhs, rhs), u(t)) # u(t) = C2*exp(-t) + (C1 + t/2)*exp(t)
latex(Integral(cos(x)**2, (x, 0, pi))) # LaTeX code!
# %% Old Slide : Function definition
def funcA(a, b = 1):
......
......@@ -22,7 +22,7 @@ Contains *.tex*, *.pdf*, etc ... files for the presentation of the PhD seminar.
- [x] Using Numpy to manipulate arrays (AP)
- [x] Overview of Scipy functionalities (AP)
- [x] Data visualization with Matplotlib (AP)
- [ ] Symbolic computation with Sympy (AP)
- [x] Symbolic computation with Sympy (AP)
[MarkDown documentation](https://docs.gitlab.com/ee/user/markdown.html) - General synthax for *.md* files
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment