Table

edit

Table generated with this Python script:

#!/usr/bin/env python
import re, math
def fmt(string): ## string.format(**vars()) ucosg tags {expression!format} by CMG Lee
 def f(tag): i_sep = tag.rfind('!'); return (re.sub('\.0+$', '', str(eval(tag[1:-1])))
  if (i_sep < 0) else ('{:%s}' % tag[i_sep + 1:-1]).format(eval(tag[1:i_sep])))
 return (re.sub(r'(?<!{){[^{}]+}', lambda m:f(m.group()), string)
         .replace('{{', '{').replace('}}', '}'))
def append(obj, string): return obj.append(fmt(string))
def format_tab(*arg): return '\t'.join([str(el) for el in (arg if len(arg) > 1 else arg[0])])
def tabbify(cellss, separator='|'):
 cellpadss = [list(rows) + [''] * (len(max(cellss, key=len)) - len(rows)) for rows in cellss]
 fmts = ['%%%ds' % (max([len(str(cell)) for cell in cols])) for cols in zip(*cellpadss)]
 return '\n'.join([separator.join(fmts) % tuple(rows) for rows in cellpadss])
import fractions
def cos(deg): return math.cos(math.radians(deg))
def bartable(value): return '{{{{bartable|%s||200}}}}' % (round(value, 5))
outss    = []
outs     = []
rule_cum = actual_cum = deg_old = 0
for i_period in range(1, 6 + 1):
 rule        = 3 - int(abs(i_period - 3.5))
 rule_cum   += rule
 deg         = 180 * i_period / 6
 formula     = '(cos %d&deg; - cos %d&deg;) / 2' % (deg_old, deg)
 formula_cum = '(1 - cos %d&deg;) / 2' % (deg)
 actual      = eval(re.sub(r'(\d+)&deg;', r'(\1)', formula))
 actual_cum += actual
 outss.append([i_period, rule, rule / 12.0, rule_cum, rule_cum / 12.0, formula, actual, actual_cum])
 append(outs, '''\
|--
! rowspan="2"|{i_period}
| Rule || {rule} / 12 || {bartable(rule / 12.0)} || {rule_cum} / 12 || {bartable(rule_cum / 12.0)}
|-
| Actual || {formula} || {bartable(actual)} || {formula_cum} || {bartable(actual_cum)}''')
 deg_old = deg
out = '''\
{| class="wikitable"
! rowspan="2"|Period !! rowspan="2"|Rule or<br />actual<br />values
! colspan="3"|Increment !! colspan="3"|Cumulative
|-
! Exact value !! Decimal !! Relative size !! Exact value !! Decimal !! Relative size
%s
|}''' % ('\n'.join(outs))
print(out)
print(tabbify(outss))