In [4]:
from sympy import *
from IPython.display import *
init_printing(use_latex=True)
# source: http://mathworld.wolfram.com/PopulationGrowth.html
# problem: for a given multi-variable equation, generate all its forms
# create symbols
vl = (N,N_0,t,r) = symbols('N N_0 t r')
# base equation
b = log(N/N_0) - r*t
def wrap_tag(t,d):
   return '<%s style="border-color:white">%s</%s>' % (t,d,t) 
desc = (
  'Population at time t','Population at time zero',
  'Time','Population growth rate'
)
s = 'Variables:'
ss = ''
for n,x in enumerate(vl):
  ss += wrap_tag('td','&nbsp;')
  ss += wrap_tag('td','$%s$' % str(x))
  ss += wrap_tag('td',': %s' % desc[n])
  ss = wrap_tag('tr',ss)
s += wrap_tag('table',ss)
s += 'Equations:'
ss = ''
for v in vl:
  soln = solve(b,v)[0]
  ss += wrap_tag('td','&nbsp;')
  ss += wrap_tag('td','$%s$' % str(v))
  ss += wrap_tag('td','$\displaystyle = %s$' % latex(soln))
  ss = wrap_tag('tr',ss)
s += wrap_tag('table',ss)
HTML(s)
Out[4]:
Variables:
 $N$: Population at time t
 $N_0$: Population at time zero
 $t$: Time
 $r$: Population growth rate
Equations:
 $N$$\displaystyle = N_{0} e^{r t}$
 $N_0$$\displaystyle = N e^{- r t}$
 $t$$\displaystyle = \frac{\log{\left (\frac{N}{N_{0}} \right )}}{r}$
 $r$$\displaystyle = \frac{\log{\left (\frac{N}{N_{0}} \right )}}{t}$