<jupyter_start><jupyter_text>Classwork 5 <NAME>, <NAME>, <NAME>, <NAME>, <NAME> 3/1/16The calculus module contains 3 main functions in it. The first is the discrete funk function, which takes a function f, endpoints a and b, and the number of points to be calculated n. The function returns a 2 dimensional list containing a list of inputs x equally spaced along a-b and then a list of outputs y for y = f(x).<jupyter_code>plot_points = p1.discrete_func(math.sin, -4, 4, 400)

plt.plot(plot_points[0], plot_points[1], 'g.')
plt.show()<jupyter_output><empty_output><jupyter_text>That's nice, but we also did stuff with it. For example, we wrote two functions which obtain the derrivative of a function at various points. The first was an iterative version. We display it below here, taking the derivative of sin at the x value of 2 pi. Note that it approaches the actual value of 1 with incredible accuracy and precision.<jupyter_code>print p1.diff(math.sin, 0, 2 * math.pi, 1000)[1][-1]<jupyter_output>0.999993420277<jupyter_text>We also implemented a superior version in the form of a derrivative matrix. This takes the matrix product of an n by n matrix with an n length vector utilizing numpy functions. This is far better, not only due to the speed of numpy functions, but rather, by the ability to rapidly differentiate other functions with the generated matrix should we need be so that there.<jupyter_code>print p1.diff2(math.sin, 0, 2 * math.pi, 1000)[-1]<jupyter_output>1.0009944015<jupyter_text>Finally, trapezoidal_matrix takes a function, two endpoints, and an interval number n and returns the integral of the function from the dot product of the function vector with a 1 by n matrix for integration.<jupyter_code>print p1.trapezoidal_matrix(np.sin, 0, np.pi/2.0, 100000)<jupyter_output>0.999989999979
{'fraction_non_alphanumeric': 0.07497243660418963, 'fraction_numerical': 0.04575523704520397, 'mean_word_length': 5.215753424657534, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '529638', 'license': 'MIT', 'n_tokens_mistral': 598, 'n_tokens_neox': 532, 'n_words': 250, 'path': 'cw5.ipynb', 'repo_name': 'chapman-phys227-2016s/cw-5-classwork-team', 'size': '1850'}