A Calculus course for Informatics engineering class

29 views
Skip to first unread message

chu-ching huang

unread,
May 4, 2017, 1:46:52 AM5/4/17
to sympy
As title, sympy package had been introduced in these lectures, especially for Multiple-variable functions. If interested, welcome  to visit the site:


cch

Aaron Meurer

unread,
May 5, 2017, 2:09:42 PM5/5/17
to sy...@googlegroups.com
Thanks for sharing. One thing I would suggest, to avoid mixing SymPy and NumPy functions, is to only import sympy and numpy as

import sympy as sym
import numpy as np

and then use sym.cos or np.cos. Otherwise, one cell has SymPy cos and another has NumPy cos, and it can be very confusing, since you cannot use SymPy functions on NumPy arrays or NumPy functions on SymPy expressions.

You can also use sympy.lambdify to convert a SymPy expression into a NumPy function for use with matplotlib, like

x = sympy.Symbol('x')
expr = sympy.cos(x) + 1
f = lambdify(x, expr)

t = np.linspace(-10, 10, 100)
plt.plot(t, f(t))

That way you don't have to rewrite the expression if you already have it in SymPy.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/eb12b241-373a-4cf4-a9f1-6cedad8e1be0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages