O'Reilly logo

Sage Beginner's Guide by Craig Finch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - putting it all together

Let's produce a simple document with LaTeX that incorporates typeset equations and graphics. This is a suitable starting point for a report, journal article, or homework assignment. First, let's make a plot of the Bessel function of the first kind for three values of n.

 from matplotlib import pyplot as plt import numpy def J_n_numerical(n, x): integrand(n1, x1, t) = cos(n1 * t - x1 * sin(t)) J_n = numpy.zeros(len(x)) for j in range(len(x)): J_n[j] = 1 / pi.n() * integrand(n1=n, x1=x[j]).nintegrate(t, 0, pi)[0] return J_n n_values = [0, 1, 2] x = numpy.arange(0.0, 10.0, 0.1) plt.figure() for n in n_values: plt.plot(x, J_n_numerical(n, x), label='n=' + str(n)) plt.xlabel('x') plt.ylabel('J(x)') plt.legend(loc='upper ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required