Added more calculations to profit.py

parent 4852a1d1
......@@ -12,6 +12,7 @@ def x_i(i, x):
x0 = 6
max_j = max_i = 10
lookup = []
print r'\hline'
print ' &', ' & '.join(map(lambda x: "$x_%d$" % x, range(0, max_i))), r'\\'
......@@ -21,9 +22,37 @@ for i in range(0,max_i):
r = []
for j in range(0,max_j):
r.append("%.2f" % round(phi(i, x_i(j, x0)), 4))
r.append("%.2f" % phi(i, x_i(j, x0)))
print '$\phi_%d(x)$ & ' % i, ' & '.join(r), r'\\'
print r'\hline'
lookup.append(r)
r = []
n = 10
x_step = float(x0) / n
s = []
for i in range(0, n):
s.append(phi(i, x_step))
print s, len(s), sum(s)
print "x_n = x0 / n = %.3f =>" % x_step, sum([phi(i, x_step) for i in range(0, n)])
for f in range(2, 10):
x = float(x0)
for d in range(0, n):
x /= f
s = []
for i in range(0, n-1):
x *= f
s.append(phi(i, x))
s.append(phi(n, x))
print s, len(s)
print "x_n = x * %d =>" % f, sum(s)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment