n = 30
plt.plot([x for x in range(n)],p3.pi_sequence(n, p3.fa),'g.')
plt.show()

plt.plot([x for x in range(n)],p3.pi_sequence(n, p3.fb) ** .5 ,'b.')
plt.show()

plt.plot([x for x in range(n)],p3.pi_sequence(n, p3.fc) ** .25 ,'y.')
plt.show()

plt.plot([x for x in range(n)],p3.pi_sequence(n, p3.fd),'r.')
plt.show()

plt.plot([x for x in range(n)],p3.pi_sequence(n, p3.fd),'c.')
plt.show()

n = 10
plt.plot([x + 20 for x in range(n)],p3.pi_sequence(n + 20, p3.fa)[-n:],'g.')
plt.plot([x + 20 for x in range(n)],(p3.pi_sequence(n + 20, p3.fb) ** .5)[-n:] ,'b.')
plt.plot([x + 20 for x in range(n)],(p3.pi_sequence(n + 20, p3.fc) ** .25)[-n:] ,'y.')
plt.plot([x + 20 for x in range(n)],p3.pi_sequence(n + 20, p3.fd)[-n:],'r.')
plt.plot([x + 20 for x in range(n)],p3.pi_sequence(n + 20, p3.fd)[-n:],'c.')

plt.plot((20, 30), (math.pi, math.pi), 'b')

plt.show()


"""
Explanation: Classwork 3
Michael Seaman, Chinmai Raman, Austin Ayers, Taylor Patti
Organized by Andrew Malfavon
Excercise A.2: Computing $\pi$ via sequences
Michael Seaman
The following sequences all converge to pi, although at different rates.
In order:
$$a_n = 4\sum_{k=1}^{n}\frac{(-1)^{k+1}}{2k-1}$$
$$b_n = (6\sum_{k=1}^{n}k^{-2})^{1/2} $$
$$c_n = (90\sum_{k=1}^{n}k^{-4})^{1/4} $$
$$d_n = \frac{6}{\sqrt{3}}\sum_{k=0}^{n}\frac{(-1)^{k}}{3^k(2k+1)}$$
$$e_n = 16\sum_{k=0}^{n}\frac{(-1)^{k}}{5^{2k+1}(2k+1)}  - 4\sum_{k=0}^{n}\frac{(-1)^{k}}{239^{2k+1}(2k+1)}$$
End of explanation
"""


x = np.linspace(0,1,10000)
y1 = p1.v(x, 1, np.exp)[2]
y2 = p1.v(x, 0.1, np.exp)[2]
y3 = p1.v(x, 0.01, np.exp)[2]

fig = plt.figure(1)
plt.plot(x, y1, 'b')
plt.plot(x, y2, 'r')
plt.plot(x, y3, 'g')
plt.xlabel('x')
plt.ylabel('v(x)')
plt.legend(['(1 - exp(x / mu)) / (1 - exp(1 / mu))'])
plt.axis([x[0], x[-1], min(y3), max(y3)])
plt.title('Math Function')
plt.show(fig)

"""
Explanation: Chinmai Raman
Classwork 3
5.49 Experience Overflow in a Function
Calculates an exponential function and returns the numerator, denominator and the fraction as a 3-tuple
End of explanation
"""


p2.part_a()

p2.part_b()

p2.part_c()

p2.part_d()

p2.part_e()

p2.part_f()

"""
Explanation: Austin Ayers
Classwork 3
A.1 Determine the limit of a sequence
Computes and returns the following sequence for N = 100
$$a_n = \frac{7+1/(n+1)}{3-1/(n+1)^2}, \qquad n=0,1,2,\ldots,N$$
End of explanation
"""


function_call = p4.vector_midpoint(p4.np.sin, 0, p4.np.pi, 10000)
print function_call[1][-1]

"""
Explanation: diffeq_midpoint
Taylor Patti
Uses the midpoint integration rule along with numpy vectors to produce a continuous vector which gives integral data for an array of prespecified points.
Here we use it to integrate sin from 0 to pi.
End of explanation
"""


print function_call[1][5000]

"""
Explanation: Observe the close adherance to the actual value of this cannonical value.
We can also call it at a different value of x. Let's look at the value of this integral from 0 to pi over 2. Again, the result will have strikingly close adherance to the analytical value of this integral.
End of explanation
"""


