Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
170 views
stirling = ((x / e) ^ x) * sqrt(2 * pi * x) # defines Stirling's formula ramanujan = sqrt(pi) * ((x / e) ^ x) * ((8 * (x ^ 3) + 4 * (x ^ 2) + x + (1 / 30)) ^ (1 / 6)) # defines Ramanujan's formula truevalues = [[i, ln(factorial(i))] for i in range(10, 111)] p = list_plot(truevalues, color = 'red', frame = True, legend_label = "True values", axes_labels = ['n', 'ln(n!)']) # creates list plot of list of values of ln(i!) p += plot(ln(stirling), x, 10, 110, color = 'green', legend_label = "Stirling's approximation") # adds to plot a graph of Stirling's approximation from 10 to 110 p += plot(ln(ramanujan), x, 10, 110, color = 'blue', legend_label = "Ramanujan's approximation") # does the same with Ramanujan's formula p.show()