Generating tables of derivatives and integrals
From SymPy
Contents |
Description
This example shows how SymPy can be used to automatically generate tables of, for instance, derivatives and integrals. We print the output in TeX (replacing the $-signs in the TeX output with <math></math>-tags for display on the wiki).
from sympy import * def derivative_table(functions, x): for f in functions: s = printing.latex(Derivative(f, x) == diff(f, x)) print ":<math>" + s[1:-1] + "</math>", "\n" def integral_table(functions, x): for f in functions: s = printing.latex(Integral(f, x) == integrate(f, x)) print ":<math>" + s[1:-1] + "</math>", "\n" var('x') print "===Derivatives===" derivative_table([cos(x)/(1 + sin(x)**i) for i in range(1, 5)], x) print "===Integrals===" integral_table([x**i * exp(i*x) for i in range(1, 5)], x)
