Massimo Nocentini

March and April, 2018: cleanup and sync
November 10 and 16, 2016: `inverse`, `expt` and `power` $g$ polys
November 9, 2016: splitting from "big" notebook



Abstract
Theory of matrix functions, with applications to a symbolic Riordan array $\mathcal{R}$ defined by convolutions.

In [1]:
from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, t, alpha
from sympy.functions.elementary.integers import ceiling, floor

init_printing()

In [2]:
%run ../../src/matrix_functions.py
%run ../../src/sequences.py

$\mathcal{R}$ is a symbolic Riordan array


In [3]:
m=8
recurrence = lambda n, k: {(n, k):1 if n == k else gencoeff_d[n, k]}
R = define(mathcal_R[m],
           Matrix(m, m, riordan_matrix_by_recurrence(m, recurrence)))
R # the most abstract form of a RA


Out[3]:
$$\mathcal{R}_{8} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\d_{1,0} & 1 & 0 & 0 & 0 & 0 & 0 & 0\\d_{2,0} & d_{2,1} & 1 & 0 & 0 & 0 & 0 & 0\\d_{3,0} & d_{3,1} & d_{3,2} & 1 & 0 & 0 & 0 & 0\\d_{4,0} & d_{4,1} & d_{4,2} & d_{4,3} & 1 & 0 & 0 & 0\\d_{5,0} & d_{5,1} & d_{5,2} & d_{5,3} & d_{5,4} & 1 & 0 & 0\\d_{6,0} & d_{6,1} & d_{6,2} & d_{6,3} & d_{6,4} & d_{6,5} & 1 & 0\\d_{7,0} & d_{7,1} & d_{7,2} & d_{7,3} & d_{7,4} & d_{7,5} & d_{7,6} & 1\end{matrix}\right]$$

In [4]:
eigendata = spectrum(R)
eigendata


Out[4]:
$$\sigma{\left (\mathcal{R}_{8} \right )} = \left ( \left \{ 1 : \left ( \lambda_{1}, \quad m_{1}\right )\right \}, \quad \left \{ \lambda_{1} : 1\right \}, \quad \left \{ m_{1} : 8\right \}\right )$$

In [5]:
data, eigenvals, multiplicities = eigendata.rhs # unpacking to use `eigenvals` in `subs`

In [6]:
Phi_poly = Phi_poly_ctor(deg=m-1)
Phi_poly # an abstract \Phi polynomial of degree (m-1)


Out[6]:
$$\Phi{\left (z,i,j \right )} = z^{7} \phi_{i,j,0} + z^{6} \phi_{i,j,1} + z^{5} \phi_{i,j,2} + z^{4} \phi_{i,j,3} + z^{3} \phi_{i,j,4} + z^{2} \phi_{i,j,5} + z \phi_{i,j,6} + \phi_{i,j,7}$$

In [7]:
Eq(Function(r'\Phi_{i,j}')(z), Phi_poly.rhs, evaluate=False) # the same poly, just printed using subscripts


Out[7]:
$$\Phi_{i,j}{\left (z \right )} = z^{7} \phi_{i,j,0} + z^{6} \phi_{i,j,1} + z^{5} \phi_{i,j,2} + z^{4} \phi_{i,j,3} + z^{3} \phi_{i,j,4} + z^{2} \phi_{i,j,5} + z \phi_{i,j,6} + \phi_{i,j,7}$$

In [8]:
Eq(Function(r'\Phi_{i,j}')(z), horner(Phi_poly.rhs), evaluate=False) # the same poly again, in Horner-eval form


Out[8]:
$$\Phi_{i,j}{\left (z \right )} = z \left(z \left(z \left(z \left(z \left(z \left(z \phi_{i,j,0} + \phi_{i,j,1}\right) + \phi_{i,j,2}\right) + \phi_{i,j,3}\right) + \phi_{i,j,4}\right) + \phi_{i,j,5}\right) + \phi_{i,j,6}\right) + \phi_{i,j,7}$$

In [9]:
Phi_polynomials = component_polynomials(eigendata, early_eigenvals_subs=True)
Phi_polynomials # generalized Lagrange base, expanded with respect to formal var `z`


Out[9]:
$$\left \{ \left ( 1, \quad 1\right ) : \Phi_{ 1, 1 }{\left (z \right )} = 1, \quad \left ( 1, \quad 2\right ) : \Phi_{ 1, 2 }{\left (z \right )} = z - 1, \quad \left ( 1, \quad 3\right ) : \Phi_{ 1, 3 }{\left (z \right )} = \frac{z^{2}}{2} - z + \frac{1}{2}, \quad \left ( 1, \quad 4\right ) : \Phi_{ 1, 4 }{\left (z \right )} = \frac{z^{3}}{6} - \frac{z^{2}}{2} + \frac{z}{2} - \frac{1}{6}, \quad \left ( 1, \quad 5\right ) : \Phi_{ 1, 5 }{\left (z \right )} = \frac{z^{4}}{24} - \frac{z^{3}}{6} + \frac{z^{2}}{4} - \frac{z}{6} + \frac{1}{24}, \quad \left ( 1, \quad 6\right ) : \Phi_{ 1, 6 }{\left (z \right )} = \frac{z^{5}}{120} - \frac{z^{4}}{24} + \frac{z^{3}}{12} - \frac{z^{2}}{12} + \frac{z}{24} - \frac{1}{120}, \quad \left ( 1, \quad 7\right ) : \Phi_{ 1, 7 }{\left (z \right )} = \frac{z^{6}}{720} - \frac{z^{5}}{120} + \frac{z^{4}}{48} - \frac{z^{3}}{36} + \frac{z^{2}}{48} - \frac{z}{120} + \frac{1}{720}, \quad \left ( 1, \quad 8\right ) : \Phi_{ 1, 8 }{\left (z \right )} = \frac{z^{7}}{5040} - \frac{z^{6}}{720} + \frac{z^{5}}{240} - \frac{z^{4}}{144} + \frac{z^{3}}{144} - \frac{z^{2}}{240} + \frac{z}{720} - \frac{1}{5040}\right \}$$

In [10]:
[p.factor() for p in component_polynomials(
    eigendata, early_eigenvals_subs=False).values()] # same polynomials, just factored out


Out[10]:
$$\left [ \Phi_{ 1, 1 }{\left (z \right )} = 1, \quad \Phi_{ 1, 2 }{\left (z \right )} = z - \lambda_{1}, \quad \Phi_{ 1, 3 }{\left (z \right )} = \frac{1}{2} \left(z - \lambda_{1}\right)^{2}, \quad \Phi_{ 1, 4 }{\left (z \right )} = \frac{1}{6} \left(z - \lambda_{1}\right)^{3}, \quad \Phi_{ 1, 5 }{\left (z \right )} = \frac{1}{24} \left(z - \lambda_{1}\right)^{4}, \quad \Phi_{ 1, 6 }{\left (z \right )} = \frac{1}{120} \left(z - \lambda_{1}\right)^{5}, \quad \Phi_{ 1, 7 }{\left (z \right )} = \frac{1}{720} \left(z - \lambda_{1}\right)^{6}, \quad \Phi_{ 1, 8 }{\left (z \right )} = \frac{1}{5040} \left(z - \lambda_{1}\right)^{7}\right ]$$

In [11]:
Z = IndexedBase('Z') # to be ported, discard them for now

cmatrices = component_matrices(R, Phi_polynomials)
# {Z[k]:v for k,v in cmatrices.items()} # all of them

In [12]:
cmatrices[1,2]


Out[12]:
$$Z^{\left[ \mathcal{R}[8] \right]}_{1,2} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\d_{1,0} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\d_{2,0} & d_{2,1} & 0 & 0 & 0 & 0 & 0 & 0\\d_{3,0} & d_{3,1} & d_{3,2} & 0 & 0 & 0 & 0 & 0\\d_{4,0} & d_{4,1} & d_{4,2} & d_{4,3} & 0 & 0 & 0 & 0\\d_{5,0} & d_{5,1} & d_{5,2} & d_{5,3} & d_{5,4} & 0 & 0 & 0\\d_{6,0} & d_{6,1} & d_{6,2} & d_{6,3} & d_{6,4} & d_{6,5} & 0 & 0\\d_{7,0} & d_{7,1} & d_{7,2} & d_{7,3} & d_{7,4} & d_{7,5} & d_{7,6} & 0\end{matrix}\right]$$

In [13]:
cmatrices[1,3] # a little bit more complex


Out[13]:
$$Z^{\left[ \mathcal{R}[8] \right]}_{1,3} = \left[\begin{matrix}0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{d_{1,0} d_{2,1}}{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} \left(d_{1,0} d_{3,1} + d_{2,0} d_{3,2}\right) & \frac{d_{2,1} d_{3,2}}{2} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} \left(d_{1,0} d_{4,1} + d_{2,0} d_{4,2} + d_{3,0} d_{4,3}\right) & \frac{1}{2} \left(d_{2,1} d_{4,2} + d_{3,1} d_{4,3}\right) & \frac{d_{3,2} d_{4,3}}{2} & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} \left(d_{1,0} d_{5,1} + d_{2,0} d_{5,2} + d_{3,0} d_{5,3} + d_{4,0} d_{5,4}\right) & \frac{1}{2} \left(d_{2,1} d_{5,2} + d_{3,1} d_{5,3} + d_{4,1} d_{5,4}\right) & \frac{1}{2} \left(d_{3,2} d_{5,3} + d_{4,2} d_{5,4}\right) & \frac{d_{4,3} d_{5,4}}{2} & 0 & 0 & 0 & 0\\\frac{1}{2} \left(d_{1,0} d_{6,1} + d_{2,0} d_{6,2} + d_{3,0} d_{6,3} + d_{4,0} d_{6,4} + d_{5,0} d_{6,5}\right) & \frac{1}{2} \left(d_{2,1} d_{6,2} + d_{3,1} d_{6,3} + d_{4,1} d_{6,4} + d_{5,1} d_{6,5}\right) & \frac{1}{2} \left(d_{3,2} d_{6,3} + d_{4,2} d_{6,4} + d_{5,2} d_{6,5}\right) & \frac{1}{2} \left(d_{4,3} d_{6,4} + d_{5,3} d_{6,5}\right) & \frac{d_{5,4} d_{6,5}}{2} & 0 & 0 & 0\\\frac{1}{2} \left(d_{1,0} d_{7,1} + d_{2,0} d_{7,2} + d_{3,0} d_{7,3} + d_{4,0} d_{7,4} + d_{5,0} d_{7,5} + d_{6,0} d_{7,6}\right) & \frac{1}{2} \left(d_{2,1} d_{7,2} + d_{3,1} d_{7,3} + d_{4,1} d_{7,4} + d_{5,1} d_{7,5} + d_{6,1} d_{7,6}\right) & \frac{1}{2} \left(d_{3,2} d_{7,3} + d_{4,2} d_{7,4} + d_{5,2} d_{7,5} + d_{6,2} d_{7,6}\right) & \frac{1}{2} \left(d_{4,3} d_{7,4} + d_{5,3} d_{7,5} + d_{6,3} d_{7,6}\right) & \frac{1}{2} \left(d_{5,4} d_{7,5} + d_{6,4} d_{7,6}\right) & \frac{d_{6,5} d_{7,6}}{2} & 0 & 0\end{matrix}\right]$$


In [14]:
f, g = Function('f'), Function('g') # abstract function and its Hermite interpolating polynomial

power function


In [15]:
f_power = define(f(z), z**r)
f_power


Out[15]:
$$f{\left (z \right )} = z^{r}$$

In [16]:
f_power_derivatives = [f_power.rhs.diff(z, i).factor().powsimp() for i in range(m)]
f_power_derivatives


Out[16]:
$$\left [ z^{r}, \quad r z^{r - 1}, \quad r z^{r - 2} \left(r - 1\right), \quad r z^{r - 3} \left(r - 2\right) \left(r - 1\right), \quad r z^{r - 4} \left(r - 3\right) \left(r - 2\right) \left(r - 1\right), \quad r z^{r - 5} \left(r - 4\right) \left(r - 3\right) \left(r - 2\right) \left(r - 1\right), \quad r z^{r - 6} \left(r - 5\right) \left(r - 4\right) \left(r - 3\right) \left(r - 2\right) \left(r - 1\right), \quad r z^{r - 7} \left(r - 6\right) \left(r - 5\right) \left(r - 4\right) \left(r - 3\right) \left(r - 2\right) \left(r - 1\right)\right ]$$

In [17]:
g_power = Hermite_interpolation_polynomial(f_power, eigendata, Phi_polynomials)
#g_power # too long to show

In [18]:
g_power = g_power.subs(eigenvals)
g_power


Out[18]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = - \frac{r^{7}}{5040} + \frac{r^{6}}{180} - \frac{23 r^{5}}{360} + \frac{7 r^{4}}{18} - \frac{967 r^{3}}{720} + \frac{469 r^{2}}{180} - \frac{363 r}{140} + z^{7} \left(\frac{r^{7}}{5040} - \frac{r^{6}}{240} + \frac{5 r^{5}}{144} - \frac{7 r^{4}}{48} + \frac{29 r^{3}}{90} - \frac{7 r^{2}}{20} + \frac{r}{7}\right) + z^{6} \left(- \frac{r^{7}}{720} + \frac{11 r^{6}}{360} - \frac{19 r^{5}}{72} + \frac{41 r^{4}}{36} - \frac{1849 r^{3}}{720} + \frac{1019 r^{2}}{360} - \frac{7 r}{6}\right) + z^{5} \left(\frac{r^{7}}{240} - \frac{23 r^{6}}{240} + \frac{69 r^{5}}{80} - \frac{185 r^{4}}{48} + \frac{134 r^{3}}{15} - \frac{201 r^{2}}{20} + \frac{21 r}{5}\right) + z^{4} \left(- \frac{r^{7}}{144} + \frac{r^{6}}{6} - \frac{113 r^{5}}{72} + \frac{22 r^{4}}{3} - \frac{2545 r^{3}}{144} + \frac{41 r^{2}}{2} - \frac{35 r}{4}\right) + z^{3} \left(\frac{r^{7}}{144} - \frac{25 r^{6}}{144} + \frac{247 r^{5}}{144} - \frac{1219 r^{4}}{144} + \frac{389 r^{3}}{18} - \frac{949 r^{2}}{36} + \frac{35 r}{3}\right) + z^{2} \left(- \frac{r^{7}}{240} + \frac{13 r^{6}}{120} - \frac{9 r^{5}}{8} + \frac{71 r^{4}}{12} - \frac{3929 r^{3}}{240} + \frac{879 r^{2}}{40} - \frac{21 r}{2}\right) + z \left(\frac{r^{7}}{720} - \frac{3 r^{6}}{80} + \frac{59 r^{5}}{144} - \frac{37 r^{4}}{16} + \frac{319 r^{3}}{45} - \frac{223 r^{2}}{20} + 7 r\right) + 1$$

In [19]:
g_power_implicit = define(g(z), sum(binomial(r, j)*(z-1)**j for j in range(m)).collect(z))
g_power_implicit


Out[19]:
$$g{\left (z \right )} = \left(z - 1\right)^{7} {\binom{r}{7}} + \left(z - 1\right)^{6} {\binom{r}{6}} + \left(z - 1\right)^{5} {\binom{r}{5}} + \left(z - 1\right)^{4} {\binom{r}{4}} + \left(z - 1\right)^{3} {\binom{r}{3}} + \left(z - 1\right)^{2} {\binom{r}{2}} + \left(z - 1\right) {\binom{r}{1}} + 1$$

In [20]:
g_power_theo_jk = define(g(z), sum((-1)**(j-1)*binomial(r, j-1)*binomial(j-1, k)*(-z)**k
                                    for j in range(1, m+1)
                                    for k in range(j)).collect(z))
g_power_theo_kj = define(g(z), sum((-1)**(j)*binomial(r, j)*binomial(j, k)*(-z)**k 
                                    for k in range(m) 
                                    for j in range(k, m)).collect(z))
g_power_theo_kj


Out[20]:
$$g{\left (z \right )} = z^{7} {\binom{r}{7}} + z^{6} \left({\binom{r}{6}} - 7 {\binom{r}{7}}\right) + z^{5} \left({\binom{r}{5}} - 6 {\binom{r}{6}} + 21 {\binom{r}{7}}\right) + z^{4} \left({\binom{r}{4}} - 5 {\binom{r}{5}} + 15 {\binom{r}{6}} - 35 {\binom{r}{7}}\right) + z^{3} \left({\binom{r}{3}} - 4 {\binom{r}{4}} + 10 {\binom{r}{5}} - 20 {\binom{r}{6}} + 35 {\binom{r}{7}}\right) + z^{2} \left({\binom{r}{2}} - 3 {\binom{r}{3}} + 6 {\binom{r}{4}} - 10 {\binom{r}{5}} + 15 {\binom{r}{6}} - 21 {\binom{r}{7}}\right) + z \left({\binom{r}{1}} - 2 {\binom{r}{2}} + 3 {\binom{r}{3}} - 4 {\binom{r}{4}} + 5 {\binom{r}{5}} - 6 {\binom{r}{6}} + 7 {\binom{r}{7}}\right) - {\binom{r}{1}} + {\binom{r}{2}} - {\binom{r}{3}} + {\binom{r}{4}} - {\binom{r}{5}} + {\binom{r}{6}} - {\binom{r}{7}} + 1$$

In [21]:
assert (g_power.rhs.collect(z) == 
        g_power_implicit.rhs.combsimp().collect(z) == 
        g_power_theo_jk.rhs.combsimp().collect(z) == 
        g_power_theo_kj.rhs.combsimp().collect(z))

inverse function


In [22]:
f_inverse = define(f(z), 1/z)
f_inverse


Out[22]:
$$f{\left (z \right )} = \frac{1}{z}$$

In [23]:
f_inverse_derivatives = [f_inverse.rhs.diff(z, i) for i in range(m)]
f_inverse_derivatives


Out[23]:
$$\left [ \frac{1}{z}, \quad - \frac{1}{z^{2}}, \quad \frac{2}{z^{3}}, \quad - \frac{6}{z^{4}}, \quad \frac{24}{z^{5}}, \quad - \frac{120}{z^{6}}, \quad \frac{720}{z^{7}}, \quad - \frac{5040}{z^{8}}\right ]$$

In [30]:
g_inverse = Hermite_interpolation_polynomial(f_inverse, eigendata, Phi_polynomials)
g_inverse


Out[30]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = - \frac{z^{7}}{\lambda_{1}^{8}} + z^{6} \left(\frac{1}{\lambda_{1}^{7}} + \frac{7}{\lambda_{1}^{8}}\right) + z^{5} \left(- \frac{1}{\lambda_{1}^{6}} - \frac{6}{\lambda_{1}^{7}} - \frac{21}{\lambda_{1}^{8}}\right) + z^{4} \left(\frac{1}{\lambda_{1}^{5}} + \frac{5}{\lambda_{1}^{6}} + \frac{15}{\lambda_{1}^{7}} + \frac{35}{\lambda_{1}^{8}}\right) + z^{3} \left(- \frac{1}{\lambda_{1}^{4}} - \frac{4}{\lambda_{1}^{5}} - \frac{10}{\lambda_{1}^{6}} - \frac{20}{\lambda_{1}^{7}} - \frac{35}{\lambda_{1}^{8}}\right) + z^{2} \left(\frac{1}{\lambda_{1}^{3}} + \frac{3}{\lambda_{1}^{4}} + \frac{6}{\lambda_{1}^{5}} + \frac{10}{\lambda_{1}^{6}} + \frac{15}{\lambda_{1}^{7}} + \frac{21}{\lambda_{1}^{8}}\right) + z \left(- \frac{1}{\lambda_{1}^{2}} - \frac{2}{\lambda_{1}^{3}} - \frac{3}{\lambda_{1}^{4}} - \frac{4}{\lambda_{1}^{5}} - \frac{5}{\lambda_{1}^{6}} - \frac{6}{\lambda_{1}^{7}} - \frac{7}{\lambda_{1}^{8}}\right) + \frac{1}{\lambda_{1}} + \frac{1}{\lambda_{1}^{2}} + \frac{1}{\lambda_{1}^{3}} + \frac{1}{\lambda_{1}^{4}} + \frac{1}{\lambda_{1}^{5}} + \frac{1}{\lambda_{1}^{6}} + \frac{1}{\lambda_{1}^{7}} + \frac{1}{\lambda_{1}^{8}}$$

In [32]:
define(g_inverse.lhs, g_inverse.rhs.as_poly(1/lamda_indexed[1]).as_expr()) # reversing


Out[32]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{1}{\lambda_{1}^{2}} \left(- z + 1\right) + \frac{1}{\lambda_{1}^{3}} \left(z^{2} - 2 z + 1\right) + \frac{1}{\lambda_{1}^{4}} \left(- z^{3} + 3 z^{2} - 3 z + 1\right) + \frac{1}{\lambda_{1}^{5}} \left(z^{4} - 4 z^{3} + 6 z^{2} - 4 z + 1\right) + \frac{1}{\lambda_{1}^{6}} \left(- z^{5} + 5 z^{4} - 10 z^{3} + 10 z^{2} - 5 z + 1\right) + \frac{1}{\lambda_{1}^{7}} \left(z^{6} - 6 z^{5} + 15 z^{4} - 20 z^{3} + 15 z^{2} - 6 z + 1\right) + \frac{1}{\lambda_{1}^{8}} \left(- z^{7} + 7 z^{6} - 21 z^{5} + 35 z^{4} - 35 z^{3} + 21 z^{2} - 7 z + 1\right) + \frac{1}{\lambda_{1}}$$

In [33]:
g_inverse = g_inverse.subs(eigenvals)
g_inverse


Out[33]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = - z^{7} + 8 z^{6} - 28 z^{5} + 56 z^{4} - 70 z^{3} + 56 z^{2} - 28 z + 8$$

In [34]:
g_inverse_implicit = define(g(z), sum((-1)**j*(z-1)**j for j in range(m)).collect(z))
g_inverse_implicit


Out[34]:
$$g{\left (z \right )} = - z - \left(z - 1\right)^{7} + \left(z - 1\right)^{6} - \left(z - 1\right)^{5} + \left(z - 1\right)^{4} - \left(z - 1\right)^{3} + \left(z - 1\right)^{2} + 2$$

In [35]:
g_inverse_theo_jk = define(g(z), sum(binomial(j-1, k)*(-z)**k
                                     for j in range(1, m+1)
                                     for k in range(j)))
g_inverse_theo_kj = define(g(z), sum(binomial(m, k+1)*(-z)**(k) 
                                     for k in range(m)))
g_inverse_theo_kj


Out[35]:
$$g{\left (z \right )} = - z^{7} + 8 z^{6} - 28 z^{5} + 56 z^{4} - 70 z^{3} + 56 z^{2} - 28 z + 8$$

In [36]:
assert (g_inverse.rhs.collect(z) == 
        g_inverse_implicit.rhs.expand().collect(z) == 
        g_inverse_theo_jk.rhs.collect(z) == 
        g_inverse_theo_kj.rhs.collect(z))

sqrt function


In [37]:
f = Function('f')
f_sqrt = define(let=f(z), be=sqrt(z))
f_sqrt


Out[37]:
$$f{\left (z \right )} = \sqrt{z}$$

In [38]:
order = 10

In [39]:
[f_sqrt.rhs.diff(z, j, 1).subs({z:1}) for j in range(order)]


Out[39]:
$$\left [ 1, \quad \frac{1}{2}, \quad - \frac{1}{4}, \quad \frac{3}{8}, \quad - \frac{15}{16}, \quad \frac{105}{32}, \quad - \frac{945}{64}, \quad \frac{10395}{128}, \quad - \frac{135135}{256}, \quad \frac{2027025}{512}\right ]$$

In [40]:
[f_sqrt.rhs.diff(z, j, 1).subs({z:1})/factorial(j) for j in range(order)]


Out[40]:
$$\left [ 1, \quad \frac{1}{2}, \quad - \frac{1}{8}, \quad \frac{1}{16}, \quad - \frac{5}{128}, \quad \frac{7}{256}, \quad - \frac{21}{1024}, \quad \frac{33}{2048}, \quad - \frac{429}{32768}, \quad \frac{715}{65536}\right ]$$

In [41]:
series(f_sqrt.rhs, z,1, n=15)


Out[41]:
$$\frac{1}{2} - \frac{1}{8} \left(z - 1\right)^{2} + \frac{1}{16} \left(z - 1\right)^{3} - \frac{5}{128} \left(z - 1\right)^{4} + \frac{7}{256} \left(z - 1\right)^{5} - \frac{21}{1024} \left(z - 1\right)^{6} + \frac{33}{2048} \left(z - 1\right)^{7} - \frac{429}{32768} \left(z - 1\right)^{8} + \frac{715}{65536} \left(z - 1\right)^{9} - \frac{2431}{262144} \left(z - 1\right)^{10} + \frac{4199}{524288} \left(z - 1\right)^{11} - \frac{29393}{4194304} \left(z - 1\right)^{12} + \frac{52003}{8388608} \left(z - 1\right)^{13} - \frac{185725}{33554432} \left(z - 1\right)^{14} + \frac{z}{2} + \mathcal{O}\left(\left(z - 1\right)^{15}; z\rightarrow 1\right)$$

In [42]:
[f_sqrt.rhs.diff(z, j, 1) for j in range(order)]


Out[42]:
$$\left [ \sqrt{z}, \quad \frac{1}{2 \sqrt{z}}, \quad - \frac{1}{4 z^{\frac{3}{2}}}, \quad \frac{3}{8 z^{\frac{5}{2}}}, \quad - \frac{15}{16 z^{\frac{7}{2}}}, \quad \frac{105}{32 z^{\frac{9}{2}}}, \quad - \frac{945}{64 z^{\frac{11}{2}}}, \quad \frac{10395}{128 z^{\frac{13}{2}}}, \quad - \frac{135135}{256 z^{\frac{15}{2}}}, \quad \frac{2027025}{512 z^{\frac{17}{2}}}\right ]$$

In [43]:
[(-1)**n*factorial(2*(n))/(factorial(n)*2**n)/(2**(n+1)*z**((2*n+1)/S(2))) for n in range(order-1)]


Out[43]:
$$\left [ \frac{1}{2 \sqrt{z}}, \quad - \frac{1}{4 z^{\frac{3}{2}}}, \quad \frac{3}{8 z^{\frac{5}{2}}}, \quad - \frac{15}{16 z^{\frac{7}{2}}}, \quad \frac{105}{32 z^{\frac{9}{2}}}, \quad - \frac{945}{64 z^{\frac{11}{2}}}, \quad \frac{10395}{128 z^{\frac{13}{2}}}, \quad - \frac{135135}{256 z^{\frac{15}{2}}}, \quad \frac{2027025}{512 z^{\frac{17}{2}}}\right ]$$

In [44]:
[(-1)**n*factorial(2*(n))/(factorial(n)*4**n)/(2*z**((2*n+1)/S(2))) for n in range(order-1)]


Out[44]:
$$\left [ \frac{1}{2 \sqrt{z}}, \quad - \frac{1}{4 z^{\frac{3}{2}}}, \quad \frac{3}{8 z^{\frac{5}{2}}}, \quad - \frac{15}{16 z^{\frac{7}{2}}}, \quad \frac{105}{32 z^{\frac{9}{2}}}, \quad - \frac{945}{64 z^{\frac{11}{2}}}, \quad \frac{10395}{128 z^{\frac{13}{2}}}, \quad - \frac{135135}{256 z^{\frac{15}{2}}}, \quad \frac{2027025}{512 z^{\frac{17}{2}}}\right ]$$

In [45]:
[(-1)**n*binomial(2*n, n)*factorial(n)/(2*4**n)/(z**((2*n+1)/S(2))) for n in range(order-1)]


Out[45]:
$$\left [ \frac{1}{2 \sqrt{z}}, \quad - \frac{1}{4 z^{\frac{3}{2}}}, \quad \frac{3}{8 z^{\frac{5}{2}}}, \quad - \frac{15}{16 z^{\frac{7}{2}}}, \quad \frac{105}{32 z^{\frac{9}{2}}}, \quad - \frac{945}{64 z^{\frac{11}{2}}}, \quad \frac{10395}{128 z^{\frac{13}{2}}}, \quad - \frac{135135}{256 z^{\frac{15}{2}}}, \quad \frac{2027025}{512 z^{\frac{17}{2}}}\right ]$$

In [46]:
g_sqrt = Hermite_interpolation_polynomial(f_sqrt, eigendata, Phi_polynomials)
g_sqrt


Out[46]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{33 z^{7}}{2048 \lambda_{1}^{\frac{13}{2}}} + z^{6} \left(- \frac{21}{1024 \lambda_{1}^{\frac{11}{2}}} - \frac{231}{2048 \lambda_{1}^{\frac{13}{2}}}\right) + z^{5} \left(\frac{7}{256 \lambda_{1}^{\frac{9}{2}}} + \frac{63}{512 \lambda_{1}^{\frac{11}{2}}} + \frac{693}{2048 \lambda_{1}^{\frac{13}{2}}}\right) + z^{4} \left(- \frac{5}{128 \lambda_{1}^{\frac{7}{2}}} - \frac{35}{256 \lambda_{1}^{\frac{9}{2}}} - \frac{315}{1024 \lambda_{1}^{\frac{11}{2}}} - \frac{1155}{2048 \lambda_{1}^{\frac{13}{2}}}\right) + z^{3} \left(\frac{1}{16 \lambda_{1}^{\frac{5}{2}}} + \frac{5}{32 \lambda_{1}^{\frac{7}{2}}} + \frac{35}{128 \lambda_{1}^{\frac{9}{2}}} + \frac{105}{256 \lambda_{1}^{\frac{11}{2}}} + \frac{1155}{2048 \lambda_{1}^{\frac{13}{2}}}\right) + z^{2} \left(- \frac{1}{8 \lambda_{1}^{\frac{3}{2}}} - \frac{3}{16 \lambda_{1}^{\frac{5}{2}}} - \frac{15}{64 \lambda_{1}^{\frac{7}{2}}} - \frac{35}{128 \lambda_{1}^{\frac{9}{2}}} - \frac{315}{1024 \lambda_{1}^{\frac{11}{2}}} - \frac{693}{2048 \lambda_{1}^{\frac{13}{2}}}\right) + z \left(\frac{1}{2 \sqrt{\lambda_{1}}} + \frac{1}{4 \lambda_{1}^{\frac{3}{2}}} + \frac{3}{16 \lambda_{1}^{\frac{5}{2}}} + \frac{5}{32 \lambda_{1}^{\frac{7}{2}}} + \frac{35}{256 \lambda_{1}^{\frac{9}{2}}} + \frac{63}{512 \lambda_{1}^{\frac{11}{2}}} + \frac{231}{2048 \lambda_{1}^{\frac{13}{2}}}\right) + \sqrt{\lambda_{1}} - \frac{1}{2 \sqrt{\lambda_{1}}} - \frac{1}{8 \lambda_{1}^{\frac{3}{2}}} - \frac{1}{16 \lambda_{1}^{\frac{5}{2}}} - \frac{5}{128 \lambda_{1}^{\frac{7}{2}}} - \frac{7}{256 \lambda_{1}^{\frac{9}{2}}} - \frac{21}{1024 \lambda_{1}^{\frac{11}{2}}} - \frac{33}{2048 \lambda_{1}^{\frac{13}{2}}}$$

In [50]:
g_sqrt = g_sqrt.subs(eigenvals)
g_sqrt


Out[50]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}$$

In [51]:
g_sqrt_implicit = define(g(z), sum(binomial(S(1)/2, j)*(z-1)**j for j in range(m)).collect(z))
g_sqrt_implicit


Out[51]:
$$g{\left (z \right )} = \frac{z}{2} + \frac{33}{2048} \left(z - 1\right)^{7} - \frac{21}{1024} \left(z - 1\right)^{6} + \frac{7}{256} \left(z - 1\right)^{5} - \frac{5}{128} \left(z - 1\right)^{4} + \frac{1}{16} \left(z - 1\right)^{3} - \frac{1}{8} \left(z - 1\right)^{2} + \frac{1}{2}$$

In [52]:
gg = define(Function('g')(z), 1 - sum(S(1)/(j*4**(j-1))*binomial(2*(j-1), j-1)*binomial(j, k)*(-z)**(k)
                                      for j in range(1, m) for k in range(j+1))/2) 

ggg = define(Function('g')(z), 
             1 
             -sum(S(1)/(j*4**(j-1))*binomial(2*(j-1), j-1)*binomial(j, k)*(-z)**(k) 
                  for k in range(1,m)
                  for j in range(k, m))/2 
             -sum(S(1)/(j*4**(j-1))*binomial(2*(j-1), j-1) for j in range(1,m))/2)

gggg = define(Function('g')(z), 1
       - sum(S(1)/(j*4**(j-1))*binomial(2*(j-1), j-1)*binomial(j, k)*(-z)**(k) 
           for k in range(m)
           for j in range(k+KroneckerDelta(k,0), m))/2)

ggggg = define(Function('g')(z), S(2)/(4**m*(2*m-1)*binomial(2*m, m))*
              sum(S(k-m)/(2*k-1)*binomial(m, k)*(-z)**(k) for k in range(1,m))
              + S(2)*m/(4**m*(2*m-1)*binomial(2*m, m)))

In [53]:
g_sqrt_theo_jk = define(g(z), sum((-1)**(j-1)*binomial(S(1)/2, j-1)*binomial(j-1, k)*(-z)**k
                                    for j in range(1, m+1)
                                    for k in range(j)).collect(z))
g_sqrt_theo_kj = define(g(z), sum((-1)**(j)*binomial(S(1)/2, j)*binomial(j, k)*(-z)**k 
                                    for k in range(m) 
                                    for j in range(k, m)).collect(z))
g_sqrt_theo_kj


Out[53]:
$$g{\left (z \right )} = \frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}$$

In [54]:
assert (g_sqrt.rhs == 
        g_sqrt_implicit.rhs.expand() == 
        gg.rhs == 
        ggg.rhs == 
        gggg.rhs == 
        g_sqrt_theo_jk.rhs == 
        g_sqrt_theo_kj.rhs)

In [55]:
with lift_to_Lambda(g_sqrt) as Lg_sqrt:
    gg = Eq(g_sqrt.lhs, (Lg_sqrt(z)*Lg_sqrt(z)).as_poly().as_expr(), evaluate=False)
    with lift_to_matrix_function(gg) as GG:
        P = Eq(symbols(r'\mathcal{P}'), Matrix(m, m, binomial), evaluate=False)
        PI = GG(P)
PI, gg


Out[55]:
$$\left ( \operatorname{f_{ 8 }}{\left (\mathcal{P} \right )} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 2 & 1 & 0 & 0 & 0 & 0 & 0\\1 & 3 & 3 & 1 & 0 & 0 & 0 & 0\\1 & 4 & 6 & 4 & 1 & 0 & 0 & 0\\1 & 5 & 10 & 10 & 5 & 1 & 0 & 0\\1 & 6 & 15 & 20 & 15 & 6 & 1 & 0\\1 & 7 & 21 & 35 & 35 & 21 & 7 & 1\end{matrix}\right], \quad \operatorname{f_{ 8 }}{\left (z \right )} = \frac{1089 z^{14}}{4194304} - \frac{9009 z^{13}}{2097152} + \frac{140595 z^{12}}{4194304} - \frac{172029 z^{11}}{1048576} + \frac{2371369 z^{10}}{4194304} - \frac{3066063 z^{9}}{2097152} + \frac{12450867 z^{8}}{4194304} - \frac{2563275 z^{7}}{524288} + \frac{27678651 z^{6}}{4194304} - \frac{15030015 z^{5}}{2097152} + \frac{25213617 z^{4}}{4194304} - \frac{3864861 z^{3}}{1048576} + \frac{6441435 z^{2}}{4194304} + \frac{1288287 z}{2097152} + \frac{184041}{4194304}\right )$$

In [56]:
with lift_to_Lambda(g_sqrt) as Lg_sqrt:
    gg = Eq(g_sqrt.lhs, (Lg_sqrt(Lg_sqrt(z))), evaluate=False)
    with lift_to_matrix_function(gg) as GG:
        P = Eq(symbols(r'\mathcal{P}'), Matrix(m, m, binomial), evaluate=False)
        PI = GG(P)
PI, gg


Out[56]:
$$\left ( \operatorname{f_{ 8 }}{\left (\mathcal{P} \right )} = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{4} & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{16} & \frac{1}{2} & 1 & 0 & 0 & 0 & 0 & 0\\\frac{1}{64} & \frac{3}{16} & \frac{3}{4} & 1 & 0 & 0 & 0 & 0\\\frac{1}{256} & \frac{1}{16} & \frac{3}{8} & 1 & 1 & 0 & 0 & 0\\\frac{1}{1024} & \frac{5}{256} & \frac{5}{32} & \frac{5}{8} & \frac{5}{4} & 1 & 0 & 0\\\frac{1}{4096} & \frac{3}{512} & \frac{15}{256} & \frac{5}{16} & \frac{15}{16} & \frac{3}{2} & 1 & 0\\\frac{1}{16384} & \frac{7}{4096} & \frac{21}{1024} & \frac{35}{256} & \frac{35}{64} & \frac{21}{16} & \frac{7}{4} & 1\end{matrix}\right], \quad \operatorname{f_{ 8 }}{\left (z \right )} = \frac{99099 z^{7}}{4194304} - \frac{819819 z^{6}}{4194304} + \frac{3006003 z^{5}}{4194304} - \frac{6441435 z^{4}}{4194304} + \frac{9018009 z^{3}}{4194304} - \frac{9018009 z^{2}}{4194304} + \frac{9018009 z}{4194304} + \frac{33}{2048} \left(\frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}\right)^{7} - \frac{273}{2048} \left(\frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}\right)^{6} + \frac{1001}{2048} \left(\frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}\right)^{5} - \frac{2145}{2048} \left(\frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}\right)^{4} + \frac{3003}{2048} \left(\frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}\right)^{3} - \frac{3003}{2048} \left(\frac{33 z^{7}}{2048} - \frac{273 z^{6}}{2048} + \frac{1001 z^{5}}{2048} - \frac{2145 z^{4}}{2048} + \frac{3003 z^{3}}{2048} - \frac{3003 z^{2}}{2048} + \frac{3003 z}{2048} + \frac{429}{2048}\right)^{2} + \frac{2166879}{4194304}\right )$$

catalan function


In [57]:
f = Function('f')
f_catalan = define(let=f(z), be=(1-sqrt(1-4*z))/(2*z))
f_catalan


Out[57]:
$$f{\left (z \right )} = \frac{1}{2 z} \left(- \sqrt{- 4 z + 1} + 1\right)$$

In [58]:
order = 10

In [59]:
[f_catalan.rhs.diff(z, j, 1) for j in range(order)]


Out[59]:
$$\left [ \frac{1}{2 z} \left(- \sqrt{- 4 z + 1} + 1\right), \quad \frac{1}{z \sqrt{- 4 z + 1}} - \frac{1}{2 z^{2}} \left(- \sqrt{- 4 z + 1} + 1\right), \quad \frac{1}{z} \left(\frac{2}{\left(- 4 z + 1\right)^{\frac{3}{2}}} - \frac{2}{z \sqrt{- 4 z + 1}} - \frac{1}{z^{2}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{3}{z} \left(\frac{4}{\left(- 4 z + 1\right)^{\frac{5}{2}}} - \frac{2}{z \left(- 4 z + 1\right)^{\frac{3}{2}}} + \frac{2}{z^{2} \sqrt{- 4 z + 1}} + \frac{1}{z^{3}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{12}{z} \left(\frac{10}{\left(- 4 z + 1\right)^{\frac{7}{2}}} - \frac{4}{z \left(- 4 z + 1\right)^{\frac{5}{2}}} + \frac{2}{z^{2} \left(- 4 z + 1\right)^{\frac{3}{2}}} - \frac{2}{z^{3} \sqrt{- 4 z + 1}} - \frac{1}{z^{4}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{60}{z} \left(\frac{28}{\left(- 4 z + 1\right)^{\frac{9}{2}}} - \frac{10}{z \left(- 4 z + 1\right)^{\frac{7}{2}}} + \frac{4}{z^{2} \left(- 4 z + 1\right)^{\frac{5}{2}}} - \frac{2}{z^{3} \left(- 4 z + 1\right)^{\frac{3}{2}}} + \frac{2}{z^{4} \sqrt{- 4 z + 1}} + \frac{1}{z^{5}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{360}{z} \left(\frac{84}{\left(- 4 z + 1\right)^{\frac{11}{2}}} - \frac{28}{z \left(- 4 z + 1\right)^{\frac{9}{2}}} + \frac{10}{z^{2} \left(- 4 z + 1\right)^{\frac{7}{2}}} - \frac{4}{z^{3} \left(- 4 z + 1\right)^{\frac{5}{2}}} + \frac{2}{z^{4} \left(- 4 z + 1\right)^{\frac{3}{2}}} - \frac{2}{z^{5} \sqrt{- 4 z + 1}} - \frac{1}{z^{6}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{2520}{z} \left(\frac{264}{\left(- 4 z + 1\right)^{\frac{13}{2}}} - \frac{84}{z \left(- 4 z + 1\right)^{\frac{11}{2}}} + \frac{28}{z^{2} \left(- 4 z + 1\right)^{\frac{9}{2}}} - \frac{10}{z^{3} \left(- 4 z + 1\right)^{\frac{7}{2}}} + \frac{4}{z^{4} \left(- 4 z + 1\right)^{\frac{5}{2}}} - \frac{2}{z^{5} \left(- 4 z + 1\right)^{\frac{3}{2}}} + \frac{2}{z^{6} \sqrt{- 4 z + 1}} + \frac{1}{z^{7}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{20160}{z} \left(\frac{858}{\left(- 4 z + 1\right)^{\frac{15}{2}}} - \frac{264}{z \left(- 4 z + 1\right)^{\frac{13}{2}}} + \frac{84}{z^{2} \left(- 4 z + 1\right)^{\frac{11}{2}}} - \frac{28}{z^{3} \left(- 4 z + 1\right)^{\frac{9}{2}}} + \frac{10}{z^{4} \left(- 4 z + 1\right)^{\frac{7}{2}}} - \frac{4}{z^{5} \left(- 4 z + 1\right)^{\frac{5}{2}}} + \frac{2}{z^{6} \left(- 4 z + 1\right)^{\frac{3}{2}}} - \frac{2}{z^{7} \sqrt{- 4 z + 1}} - \frac{1}{z^{8}} \left(\sqrt{- 4 z + 1} - 1\right)\right), \quad \frac{181440}{z} \left(\frac{2860}{\left(- 4 z + 1\right)^{\frac{17}{2}}} - \frac{858}{z \left(- 4 z + 1\right)^{\frac{15}{2}}} + \frac{264}{z^{2} \left(- 4 z + 1\right)^{\frac{13}{2}}} - \frac{84}{z^{3} \left(- 4 z + 1\right)^{\frac{11}{2}}} + \frac{28}{z^{4} \left(- 4 z + 1\right)^{\frac{9}{2}}} - \frac{10}{z^{5} \left(- 4 z + 1\right)^{\frac{7}{2}}} + \frac{4}{z^{6} \left(- 4 z + 1\right)^{\frac{5}{2}}} - \frac{2}{z^{7} \left(- 4 z + 1\right)^{\frac{3}{2}}} + \frac{2}{z^{8} \sqrt{- 4 z + 1}} + \frac{1}{z^{9}} \left(\sqrt{- 4 z + 1} - 1\right)\right)\right ]$$

In [60]:
g_catalan = Hermite_interpolation_polynomial(f_catalan, eigendata, Phi_polynomials)
#g_catalan

In [61]:
g_catalan = g_catalan.subs(eigenvals)
g_catalan


Out[61]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = z^{7} \left(- \frac{1}{2} - \frac{373 i}{1458} \sqrt{3}\right) + z^{6} \left(4 + \frac{1448 i}{729} \sqrt{3}\right) + z^{5} \left(-14 - \frac{1624 i}{243} \sqrt{3}\right) + z^{4} \left(28 + \frac{9226 i}{729} \sqrt{3}\right) + z^{3} \left(-35 - \frac{10630 i}{729} \sqrt{3}\right) + z^{2} \left(28 + \frac{2470 i}{243} \sqrt{3}\right) + z \left(-14 - \frac{2735 i}{729} \sqrt{3}\right) + 4 - \frac{25 i}{729} \sqrt{3}$$

In [62]:
with lift_to_matrix_function(g_catalan) as G_catalan:
    P = Eq(symbols(r'\mathcal{P}'), Matrix(m, m, binomial), evaluate=False)
    P_catalan = G_catalan(P)
P_catalan


Out[62]:
$$\operatorname{f_{ 8 }}{\left (\mathcal{P} \right )} = \left[\begin{matrix}\frac{1}{2} - \frac{\sqrt{3} i}{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\- \frac{1}{2} + \frac{\sqrt{3} i}{6} & \frac{1}{2} - \frac{\sqrt{3} i}{2} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} + \frac{\sqrt{3} i}{18} & -1 + \frac{\sqrt{3} i}{3} & \frac{1}{2} - \frac{\sqrt{3} i}{2} & 0 & 0 & 0 & 0 & 0\\- \frac{1}{2} - \frac{5 i}{18} \sqrt{3} & \frac{3}{2} + \frac{\sqrt{3} i}{6} & - \frac{3}{2} + \frac{\sqrt{3} i}{2} & \frac{1}{2} - \frac{\sqrt{3} i}{2} & 0 & 0 & 0 & 0\\\frac{1}{2} + \frac{35 i}{54} \sqrt{3} & -2 - \frac{10 i}{9} \sqrt{3} & 3 + \frac{\sqrt{3} i}{3} & -2 + \frac{2 i}{3} \sqrt{3} & \frac{1}{2} - \frac{\sqrt{3} i}{2} & 0 & 0 & 0\\- \frac{1}{2} - \frac{253 i}{162} \sqrt{3} & \frac{5}{2} + \frac{175 i}{54} \sqrt{3} & -5 - \frac{25 i}{9} \sqrt{3} & 5 + \frac{5 i}{9} \sqrt{3} & - \frac{5}{2} + \frac{5 i}{6} \sqrt{3} & \frac{1}{2} - \frac{\sqrt{3} i}{2} & 0 & 0\\\frac{1}{2} + \frac{9 i}{2} \sqrt{3} & -3 - \frac{253 i}{27} \sqrt{3} & \frac{15}{2} + \frac{175 i}{18} \sqrt{3} & -10 - \frac{50 i}{9} \sqrt{3} & \frac{15}{2} + \frac{5 i}{6} \sqrt{3} & -3 + \sqrt{3} i & \frac{1}{2} - \frac{\sqrt{3} i}{2} & 0\\- \frac{1}{2} - \frac{2605 i}{162} \sqrt{3} & \frac{7}{2} + \frac{63 i}{2} \sqrt{3} & - \frac{21}{2} - \frac{1771 i}{54} \sqrt{3} & \frac{35}{2} + \frac{1225 i}{54} \sqrt{3} & - \frac{35}{2} - \frac{175 i}{18} \sqrt{3} & \frac{21}{2} + \frac{7 i}{6} \sqrt{3} & - \frac{7}{2} + \frac{7 i}{6} \sqrt{3} & \frac{1}{2} - \frac{\sqrt{3} i}{2}\end{matrix}\right]$$

expt function


In [63]:
f = Function('f')
f_expt = define(let=f(z), be=exp(alpha*z))
f_expt


Out[63]:
$$f{\left (z \right )} = e^{\alpha z}$$

In [64]:
[f_expt.rhs.diff(z, i) for i in range(11)]


Out[64]:
$$\left [ e^{\alpha z}, \quad \alpha e^{\alpha z}, \quad \alpha^{2} e^{\alpha z}, \quad \alpha^{3} e^{\alpha z}, \quad \alpha^{4} e^{\alpha z}, \quad \alpha^{5} e^{\alpha z}, \quad \alpha^{6} e^{\alpha z}, \quad \alpha^{7} e^{\alpha z}, \quad \alpha^{8} e^{\alpha z}, \quad \alpha^{9} e^{\alpha z}, \quad \alpha^{10} e^{\alpha z}\right ]$$

In [65]:
powdenest((-1)**(j-1)*alpha**(j-1), force=True)


Out[65]:
$$\left(- \alpha\right)^{j - 1}$$

In [66]:
ss = Sum((-alpha)**j*binomial(j, k)/factorial(j), (j, k, z-1))
ss


Out[66]:
$$\sum_{j=k}^{z - 1} \frac{\left(- \alpha\right)^{j}}{j!} {\binom{j}{k}}$$

In [67]:
ss.doit().simplify().subs({alpha:1})


Out[67]:
$$\frac{\left(-1\right)^{k}}{e k!} + \frac{\left(-1\right)^{z} {\binom{z}{k}}}{e z!} \left(k - z\right) e^{i \pi \left(k - z\right)} \gamma\left(- k + z, e^{i \pi}\right)$$

checking Equation 11:


In [68]:
ss.subs({z-1:oo}).doit()


Out[68]:
$$\frac{\left(- \alpha\right)^{k}}{k!} e^{- \alpha}$$

which is the expansion of $e^{\alpha}$ as required.


In [70]:
g_expt = Hermite_interpolation_polynomial(f_expt, eigendata, Phi_polynomials)
g_expt


Out[70]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{\alpha^{7} z^{7}}{5040} e^{\alpha \lambda_{1}} - \frac{\alpha^{7}}{5040} e^{\alpha \lambda_{1}} + \frac{\alpha^{6}}{720} e^{\alpha \lambda_{1}} - \frac{\alpha^{5}}{120} e^{\alpha \lambda_{1}} + \frac{\alpha^{4}}{24} e^{\alpha \lambda_{1}} - \frac{\alpha^{3}}{6} e^{\alpha \lambda_{1}} + \frac{\alpha^{2}}{2} e^{\alpha \lambda_{1}} - \alpha e^{\alpha \lambda_{1}} + z^{6} \left(- \frac{\alpha^{7}}{720} e^{\alpha \lambda_{1}} + \frac{\alpha^{6}}{720} e^{\alpha \lambda_{1}}\right) + z^{5} \left(\frac{\alpha^{7}}{240} e^{\alpha \lambda_{1}} - \frac{\alpha^{6}}{120} e^{\alpha \lambda_{1}} + \frac{\alpha^{5}}{120} e^{\alpha \lambda_{1}}\right) + z^{4} \left(- \frac{\alpha^{7}}{144} e^{\alpha \lambda_{1}} + \frac{\alpha^{6}}{48} e^{\alpha \lambda_{1}} - \frac{\alpha^{5}}{24} e^{\alpha \lambda_{1}} + \frac{\alpha^{4}}{24} e^{\alpha \lambda_{1}}\right) + z^{3} \left(\frac{\alpha^{7}}{144} e^{\alpha \lambda_{1}} - \frac{\alpha^{6}}{36} e^{\alpha \lambda_{1}} + \frac{\alpha^{5}}{12} e^{\alpha \lambda_{1}} - \frac{\alpha^{4}}{6} e^{\alpha \lambda_{1}} + \frac{\alpha^{3}}{6} e^{\alpha \lambda_{1}}\right) + z^{2} \left(- \frac{\alpha^{7}}{240} e^{\alpha \lambda_{1}} + \frac{\alpha^{6}}{48} e^{\alpha \lambda_{1}} - \frac{\alpha^{5}}{12} e^{\alpha \lambda_{1}} + \frac{\alpha^{4}}{4} e^{\alpha \lambda_{1}} - \frac{\alpha^{3}}{2} e^{\alpha \lambda_{1}} + \frac{\alpha^{2}}{2} e^{\alpha \lambda_{1}}\right) + z \left(\frac{\alpha^{7}}{720} e^{\alpha \lambda_{1}} - \frac{\alpha^{6}}{120} e^{\alpha \lambda_{1}} + \frac{\alpha^{5}}{24} e^{\alpha \lambda_{1}} - \frac{\alpha^{4}}{6} e^{\alpha \lambda_{1}} + \frac{\alpha^{3}}{2} e^{\alpha \lambda_{1}} - \alpha^{2} e^{\alpha \lambda_{1}} + \alpha e^{\alpha \lambda_{1}}\right) + e^{\alpha \lambda_{1}}$$

In [71]:
g_expt = g_expt.subs(eigenvals)
simp_g_expt = Eq(g_expt.lhs, exp(alpha)*(g_expt.rhs/exp(alpha)).simplify().collect(z))
simp_g_expt


Out[71]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \left(\frac{\alpha^{7} z^{7}}{5040} - \frac{\alpha^{7}}{5040} + \frac{\alpha^{6} z^{6}}{720} \left(- \alpha + 1\right) + \frac{\alpha^{6}}{720} + \frac{\alpha^{5} z^{5}}{240} \left(\alpha^{2} - 2 \alpha + 2\right) - \frac{\alpha^{5}}{120} + \frac{\alpha^{4} z^{4}}{144} \left(- \alpha^{3} + 3 \alpha^{2} - 6 \alpha + 6\right) + \frac{\alpha^{4}}{24} + \frac{\alpha^{3} z^{3}}{144} \left(\alpha^{4} - 4 \alpha^{3} + 12 \alpha^{2} - 24 \alpha + 24\right) - \frac{\alpha^{3}}{6} + \frac{\alpha^{2} z^{2}}{240} \left(- \alpha^{5} + 5 \alpha^{4} - 20 \alpha^{3} + 60 \alpha^{2} - 120 \alpha + 120\right) + \frac{\alpha^{2}}{2} + \frac{\alpha z}{720} \left(\alpha^{6} - 6 \alpha^{5} + 30 \alpha^{4} - 120 \alpha^{3} + 360 \alpha^{2} - 720 \alpha + 720\right) - \alpha + 1\right) e^{\alpha}$$

In [72]:
simp_g_expt.subs({alpha:1})


Out[72]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = e \left(\frac{z^{7}}{5040} + \frac{z^{5}}{240} + \frac{z^{4}}{72} + \frac{z^{3}}{16} + \frac{11 z^{2}}{60} + \frac{53 z}{144} + \frac{103}{280}\right)$$

In [73]:
simp_g_expt.subs({alpha:-1})


Out[73]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{1}{e} \left(- \frac{z^{7}}{5040} + \frac{z^{6}}{360} - \frac{z^{5}}{48} + \frac{z^{4}}{9} - \frac{65 z^{3}}{144} + \frac{163 z^{2}}{120} - \frac{1957 z}{720} + \frac{685}{252}\right)$$

log function


In [74]:
f = Function('f')
f_log = define(let=f(z), be=ln(z))
f_log


Out[74]:
$$f{\left (z \right )} = \log{\left (z \right )}$$

In [75]:
[f_log.rhs.diff(z, i) for i in range(11)]


Out[75]:
$$\left [ \log{\left (z \right )}, \quad \frac{1}{z}, \quad - \frac{1}{z^{2}}, \quad \frac{2}{z^{3}}, \quad - \frac{6}{z^{4}}, \quad \frac{24}{z^{5}}, \quad - \frac{120}{z^{6}}, \quad \frac{720}{z^{7}}, \quad - \frac{5040}{z^{8}}, \quad \frac{40320}{z^{9}}, \quad - \frac{362880}{z^{10}}\right ]$$

In [76]:
[(-1)**i*factorial(i)/z**(i+1) for i in range(10)]


Out[76]:
$$\left [ \frac{1}{z}, \quad - \frac{1}{z^{2}}, \quad \frac{2}{z^{3}}, \quad - \frac{6}{z^{4}}, \quad \frac{24}{z^{5}}, \quad - \frac{120}{z^{6}}, \quad \frac{720}{z^{7}}, \quad - \frac{5040}{z^{8}}, \quad \frac{40320}{z^{9}}, \quad - \frac{362880}{z^{10}}\right ]$$

In [77]:
ss = Sum(binomial(j, k)/j, (j, k, z-1))
ss


Out[77]:
$$\sum_{j=k}^{z - 1} \frac{{\binom{j}{k}}}{j}$$

In [78]:
ss.doit()


Out[78]:
$$\frac{1}{k} {\binom{z - 1}{k}}$$

In [79]:
ss = Sum(1/j, (j, 1, z-1))
ss


Out[79]:
$$\sum_{j=1}^{z - 1} \frac{1}{j}$$

In [80]:
ss.doit()


Out[80]:
$$\operatorname{harmonic}{\left (z - 1 \right )}$$

checking Equation 11:


In [81]:
g_log = Hermite_interpolation_polynomial(f_log, eigendata, Phi_polynomials)
g_log


Out[81]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{z^{7}}{7 \lambda_{1}^{7}} + z^{6} \left(- \frac{1}{6 \lambda_{1}^{6}} - \frac{1}{\lambda_{1}^{7}}\right) + z^{5} \left(\frac{1}{5 \lambda_{1}^{5}} + \frac{1}{\lambda_{1}^{6}} + \frac{3}{\lambda_{1}^{7}}\right) + z^{4} \left(- \frac{1}{4 \lambda_{1}^{4}} - \frac{1}{\lambda_{1}^{5}} - \frac{5}{2 \lambda_{1}^{6}} - \frac{5}{\lambda_{1}^{7}}\right) + z^{3} \left(\frac{1}{3 \lambda_{1}^{3}} + \frac{1}{\lambda_{1}^{4}} + \frac{2}{\lambda_{1}^{5}} + \frac{10}{3 \lambda_{1}^{6}} + \frac{5}{\lambda_{1}^{7}}\right) + z^{2} \left(- \frac{1}{2 \lambda_{1}^{2}} - \frac{1}{\lambda_{1}^{3}} - \frac{3}{2 \lambda_{1}^{4}} - \frac{2}{\lambda_{1}^{5}} - \frac{5}{2 \lambda_{1}^{6}} - \frac{3}{\lambda_{1}^{7}}\right) + z \left(\frac{1}{\lambda_{1}} + \frac{1}{\lambda_{1}^{2}} + \frac{1}{\lambda_{1}^{3}} + \frac{1}{\lambda_{1}^{4}} + \frac{1}{\lambda_{1}^{5}} + \frac{1}{\lambda_{1}^{6}} + \frac{1}{\lambda_{1}^{7}}\right) + \log{\left (\lambda_{1} \right )} - \frac{1}{\lambda_{1}} - \frac{1}{2 \lambda_{1}^{2}} - \frac{1}{3 \lambda_{1}^{3}} - \frac{1}{4 \lambda_{1}^{4}} - \frac{1}{5 \lambda_{1}^{5}} - \frac{1}{6 \lambda_{1}^{6}} - \frac{1}{7 \lambda_{1}^{7}}$$

In [82]:
g_log = g_log.subs(eigenvals)
g_log


Out[82]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{z^{7}}{7} - \frac{7 z^{6}}{6} + \frac{21 z^{5}}{5} - \frac{35 z^{4}}{4} + \frac{35 z^{3}}{3} - \frac{21 z^{2}}{2} + 7 z - \frac{363}{140}$$

In [83]:
harmonic(7)


Out[83]:
$$\frac{363}{140}$$

Checking Equation 14


In [84]:
g = define(Function('g')(z),  - (sum(S(1)/k*binomial(m-1, k)*(-z)**(k) for k in range(1, m)) + harmonic(m-1)))
g


Out[84]:
$$g{\left (z \right )} = \frac{z^{7}}{7} - \frac{7 z^{6}}{6} + \frac{21 z^{5}}{5} - \frac{35 z^{4}}{4} + \frac{35 z^{3}}{3} - \frac{21 z^{2}}{2} + 7 z - \frac{363}{140}$$

In [85]:
Eq(g_log.rhs, g.rhs)


Out[85]:
$$\mathrm{True}$$

sin function


In [86]:
f = Function('f')
f_sin = Eq(f(z), sin(z))
f_sin


Out[86]:
$$f{\left (z \right )} = \sin{\left (z \right )}$$

In [87]:
[f_sin.rhs.diff(z, i) for i in range(m)]


Out[87]:
$$\left [ \sin{\left (z \right )}, \quad \cos{\left (z \right )}, \quad - \sin{\left (z \right )}, \quad - \cos{\left (z \right )}, \quad \sin{\left (z \right )}, \quad \cos{\left (z \right )}, \quad - \sin{\left (z \right )}, \quad - \cos{\left (z \right )}\right ]$$

In [88]:
(1/(1+t**2)).series(t, n=2*m)


Out[88]:
$$1 - t^{2} + t^{4} - t^{6} + t^{8} - t^{10} + t^{12} - t^{14} + \mathcal{O}\left(t^{16}\right)$$

In [89]:
g_sin = Hermite_interpolation_polynomial(f_sin, eigendata, Phi_polynomials)
g_sin


Out[89]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = - \frac{z^{7}}{5040} \cos{\left (\lambda_{1} \right )} + z^{6} \left(- \frac{1}{720} \sin{\left (\lambda_{1} \right )} + \frac{1}{720} \cos{\left (\lambda_{1} \right )}\right) + z^{5} \left(\frac{1}{120} \sin{\left (\lambda_{1} \right )} + \frac{1}{240} \cos{\left (\lambda_{1} \right )}\right) + z^{4} \left(\frac{1}{48} \sin{\left (\lambda_{1} \right )} - \frac{5}{144} \cos{\left (\lambda_{1} \right )}\right) + z^{3} \left(- \frac{5}{36} \sin{\left (\lambda_{1} \right )} - \frac{13}{144} \cos{\left (\lambda_{1} \right )}\right) + z^{2} \left(- \frac{13}{48} \sin{\left (\lambda_{1} \right )} + \frac{101}{240} \cos{\left (\lambda_{1} \right )}\right) + z \left(\frac{101}{120} \sin{\left (\lambda_{1} \right )} + \frac{389}{720} \cos{\left (\lambda_{1} \right )}\right) + \frac{389}{720} \sin{\left (\lambda_{1} \right )} - \frac{4241}{5040} \cos{\left (\lambda_{1} \right )}$$

In [90]:
m_sym = symbols('m')
g_poly_theo = Eq(Function('g')(z),
                 sin(1)*(Sum(Sum((-1)**(3*j)/factorial(2*j)*binomial(2*j, k),
                              (j, ceiling(k/2), ceiling(m_sym/2)-1))*(-z)**(k),
                          (k,0,2*ceiling(m_sym/2)-2))) + 
                 cos(1)*(Sum(Sum((-1)**(3*j+1)/factorial(2*j+1)*binomial(2*j+1, k),
                              (j, floor(k/2), floor(m_sym/2)-1))*(-z)**(k),
                          (k,0,2*floor(m_sym/2)-1))))
g_poly_theo


Out[90]:
$$g{\left (z \right )} = \sin{\left (1 \right )} \sum_{k=0}^{2 \lceil{\frac{m}{2}}\rceil - 2} \left(- z\right)^{k} \sum_{j=\lceil{\frac{k}{2}}\rceil}^{\lceil{\frac{m}{2}}\rceil - 1} \frac{\left(-1\right)^{3 j} {\binom{2 j}{k}}}{\left(2 j\right)!} + \cos{\left (1 \right )} \sum_{k=0}^{2 \lfloor{\frac{m}{2}}\rfloor - 1} \left(- z\right)^{k} \sum_{j=\lfloor{\frac{k}{2}}\rfloor}^{\lfloor{\frac{m}{2}}\rfloor - 1} \frac{\left(-1\right)^{3 j + 1} {\binom{2 j + 1}{k}}}{\left(2 j + 1\right)!}$$

In [91]:
g_poly_theo_m = g_poly_theo.subs({m_sym:m}).doit().simplify()
g_poly_theo_m


Out[91]:
$$g{\left (z \right )} = \frac{1}{720} \left(- z^{6} + 6 z^{5} + 15 z^{4} - 100 z^{3} - 195 z^{2} + 606 z + 389\right) \sin{\left (1 \right )} + \frac{1}{5040} \left(- z^{7} + 7 z^{6} + 21 z^{5} - 175 z^{4} - 455 z^{3} + 2121 z^{2} + 2723 z - 4241\right) \cos{\left (1 \right )}$$

In [92]:
assert g_sin.rhs.subs(eigenvals).expand() == g_poly_theo_m.rhs.expand()

In [93]:
sin_generic_term = Sum((((-1)**(j)/(factorial(2*j))*binomial(2*j,k))), (j, ceiling(k/2), ceiling(m_sym/2)-1))
sin_generic_term


Out[93]:
$$\sum_{j=\lceil{\frac{k}{2}}\rceil}^{\lceil{\frac{m}{2}}\rceil - 1} \frac{\left(-1\right)^{j} {\binom{2 j}{k}}}{\left(2 j\right)!}$$

In [94]:
sin_generic_term.doit().simplify()


Out[94]:
$$\frac{1}{k!} \left(\frac{\left(-1\right)^{\lceil{\frac{k}{2}}\rceil}}{\left(- k + 2 \lceil{\frac{k}{2}}\rceil\right)!} {{}_{1}F_{2}\left(\begin{matrix} 1 \\ - \frac{k}{2} + \lceil{\frac{k}{2}}\rceil + \frac{1}{2}, - \frac{k}{2} + \lceil{\frac{k}{2}}\rceil + 1 \end{matrix}\middle| {- \frac{1}{4}} \right)} - \frac{\left(-1\right)^{\lceil{\frac{m}{2}}\rceil}}{\left(- k + 2 \lceil{\frac{m}{2}}\rceil\right)!} {{}_{1}F_{2}\left(\begin{matrix} 1 \\ - \frac{k}{2} + \lceil{\frac{m}{2}}\rceil + \frac{1}{2}, - \frac{k}{2} + \lceil{\frac{m}{2}}\rceil + 1 \end{matrix}\middle| {- \frac{1}{4}} \right)}\right)$$

cos function


In [95]:
f = Function('f')
f_cos = Eq(f(z), cos(z))
f_cos


Out[95]:
$$f{\left (z \right )} = \cos{\left (z \right )}$$

In [96]:
[f_cos.rhs.diff(z, i) for i in range(m)]


Out[96]:
$$\left [ \cos{\left (z \right )}, \quad - \sin{\left (z \right )}, \quad - \cos{\left (z \right )}, \quad \sin{\left (z \right )}, \quad \cos{\left (z \right )}, \quad - \sin{\left (z \right )}, \quad - \cos{\left (z \right )}, \quad \sin{\left (z \right )}\right ]$$

In [97]:
(1/(1+t**2)).series(t, n=2*m)


Out[97]:
$$1 - t^{2} + t^{4} - t^{6} + t^{8} - t^{10} + t^{12} - t^{14} + \mathcal{O}\left(t^{16}\right)$$

In [98]:
g_cos = Hermite_interpolation_polynomial(f_cos, eigendata, Phi_polynomials)
g_cos


Out[98]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{z^{7}}{5040} \sin{\left (\lambda_{1} \right )} + z^{6} \left(- \frac{1}{720} \sin{\left (\lambda_{1} \right )} - \frac{1}{720} \cos{\left (\lambda_{1} \right )}\right) + z^{5} \left(- \frac{1}{240} \sin{\left (\lambda_{1} \right )} + \frac{1}{120} \cos{\left (\lambda_{1} \right )}\right) + z^{4} \left(\frac{5}{144} \sin{\left (\lambda_{1} \right )} + \frac{1}{48} \cos{\left (\lambda_{1} \right )}\right) + z^{3} \left(\frac{13}{144} \sin{\left (\lambda_{1} \right )} - \frac{5}{36} \cos{\left (\lambda_{1} \right )}\right) + z^{2} \left(- \frac{101}{240} \sin{\left (\lambda_{1} \right )} - \frac{13}{48} \cos{\left (\lambda_{1} \right )}\right) + z \left(- \frac{389}{720} \sin{\left (\lambda_{1} \right )} + \frac{101}{120} \cos{\left (\lambda_{1} \right )}\right) + \frac{4241}{5040} \sin{\left (\lambda_{1} \right )} + \frac{389}{720} \cos{\left (\lambda_{1} \right )}$$

In [99]:
m_sym = symbols('m')
g_poly_theo = Eq(Function('g')(z),
                 cos(1)*(Sum(Sum((-1)**(3*j)/factorial(2*j)*binomial(2*j, k),
                              (j, ceiling(k/2), ceiling(m_sym/2)-1))*(-z)**(k),
                          (k,0,2*ceiling(m_sym/2)-2))) + 
                 sin(1)*(Sum(Sum((-1)**(3*j+2)/factorial(2*j+1)*binomial(2*j+1, k),
                              (j, floor(k/2), floor(m_sym/2)-1))*(-z)**(k),
                          (k,0,2*floor(m_sym/2)-1))))
g_poly_theo


Out[99]:
$$g{\left (z \right )} = \cos{\left (1 \right )} \sum_{k=0}^{2 \lceil{\frac{m}{2}}\rceil - 2} \left(- z\right)^{k} \sum_{j=\lceil{\frac{k}{2}}\rceil}^{\lceil{\frac{m}{2}}\rceil - 1} \frac{\left(-1\right)^{3 j} {\binom{2 j}{k}}}{\left(2 j\right)!} + \sin{\left (1 \right )} \sum_{k=0}^{2 \lfloor{\frac{m}{2}}\rfloor - 1} \left(- z\right)^{k} \sum_{j=\lfloor{\frac{k}{2}}\rfloor}^{\lfloor{\frac{m}{2}}\rfloor - 1} \frac{\left(-1\right)^{3 j + 2} {\binom{2 j + 1}{k}}}{\left(2 j + 1\right)!}$$

In [100]:
g_poly_theo_m = g_poly_theo.subs({m_sym:m}).doit().simplify()
g_poly_theo_m


Out[100]:
$$g{\left (z \right )} = \frac{1}{720} \left(- z^{6} + 6 z^{5} + 15 z^{4} - 100 z^{3} - 195 z^{2} + 606 z + 389\right) \cos{\left (1 \right )} + \frac{1}{5040} \left(z^{7} - 7 z^{6} - 21 z^{5} + 175 z^{4} + 455 z^{3} - 2121 z^{2} - 2723 z + 4241\right) \sin{\left (1 \right )}$$

In [101]:
assert g_cos.rhs.subs(eigenvals).expand() == g_poly_theo_m.rhs.expand()

M function


In [105]:
f = Function('f')
a, b, c, d = symbols("a b c d", int=True)
f_mobius = Eq(f(z), (a*z+b)/(c*z+d))
f_mobius


Out[105]:
$$f{\left (z \right )} = \frac{a z + b}{c z + d}$$

In [106]:
[f_mobius.rhs.diff(z, i) for i in range(m)]


Out[106]:
$$\left [ \frac{a z + b}{c z + d}, \quad \frac{a}{c z + d} - \frac{c \left(a z + b\right)}{\left(c z + d\right)^{2}}, \quad \frac{2 c}{\left(c z + d\right)^{2}} \left(- a + \frac{c \left(a z + b\right)}{c z + d}\right), \quad \frac{6 c^{2}}{\left(c z + d\right)^{3}} \left(a - \frac{c \left(a z + b\right)}{c z + d}\right), \quad \frac{24 c^{3}}{\left(c z + d\right)^{4}} \left(- a + \frac{c \left(a z + b\right)}{c z + d}\right), \quad \frac{120 c^{4}}{\left(c z + d\right)^{5}} \left(a - \frac{c \left(a z + b\right)}{c z + d}\right), \quad \frac{720 c^{5}}{\left(c z + d\right)^{6}} \left(- a + \frac{c \left(a z + b\right)}{c z + d}\right), \quad \frac{5040 c^{6}}{\left(c z + d\right)^{7}} \left(a - \frac{c \left(a z + b\right)}{c z + d}\right)\right ]$$

In [107]:
g_mobius = Hermite_interpolation_polynomial(f_mobius, eigendata, Phi_polynomials)
g_mobius = g_mobius.subs(eigenvals)
#g_mobius # too long to show

In [108]:
with lift_to_matrix_function(g_mobius) as G_mobius:
    P = Eq(z, Matrix(m,m, binomial), evaluate=False)
    P_mobius = G_mobius(P)
P_mobius


Out[108]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \left[\begin{matrix}\frac{a + b}{c + d} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{a d - b c}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d} & 0 & 0 & 0 & 0 & 0 & 0\\\frac{- a c d + a d^{2} + b c^{2} - b c d}{c^{3} + 3 c^{2} d + 3 c d^{2} + d^{3}} & \frac{2 \left(a d - b c\right)}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d} & 0 & 0 & 0 & 0 & 0\\\frac{a c^{2} d - 4 a c d^{2} + a d^{3} - b c^{3} + 4 b c^{2} d - b c d^{2}}{c^{4} + 4 c^{3} d + 6 c^{2} d^{2} + 4 c d^{3} + d^{4}} & \frac{- 3 a c d + 3 a d^{2} + 3 b c^{2} - 3 b c d}{c^{3} + 3 c^{2} d + 3 c d^{2} + d^{3}} & \frac{3 \left(a d - b c\right)}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d} & 0 & 0 & 0 & 0\\\frac{- a c^{3} d + 11 a c^{2} d^{2} - 11 a c d^{3} + a d^{4} + b c^{4} - 11 b c^{3} d + 11 b c^{2} d^{2} - b c d^{3}}{c^{5} + 5 c^{4} d + 10 c^{3} d^{2} + 10 c^{2} d^{3} + 5 c d^{4} + d^{5}} & \frac{4 \left(a c^{2} d - 4 a c d^{2} + a d^{3} - b c^{3} + 4 b c^{2} d - b c d^{2}\right)}{c^{4} + 4 c^{3} d + 6 c^{2} d^{2} + 4 c d^{3} + d^{4}} & \frac{- 6 a c d + 6 a d^{2} + 6 b c^{2} - 6 b c d}{c^{3} + 3 c^{2} d + 3 c d^{2} + d^{3}} & \frac{4 \left(a d - b c\right)}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d} & 0 & 0 & 0\\\frac{a c^{4} d - 26 a c^{3} d^{2} + 66 a c^{2} d^{3} - 26 a c d^{4} + a d^{5} - b c^{5} + 26 b c^{4} d - 66 b c^{3} d^{2} + 26 b c^{2} d^{3} - b c d^{4}}{c^{6} + 6 c^{5} d + 15 c^{4} d^{2} + 20 c^{3} d^{3} + 15 c^{2} d^{4} + 6 c d^{5} + d^{6}} & \frac{- 5 a c^{3} d + 55 a c^{2} d^{2} - 55 a c d^{3} + 5 a d^{4} + 5 b c^{4} - 55 b c^{3} d + 55 b c^{2} d^{2} - 5 b c d^{3}}{c^{5} + 5 c^{4} d + 10 c^{3} d^{2} + 10 c^{2} d^{3} + 5 c d^{4} + d^{5}} & \frac{10 \left(a c^{2} d - 4 a c d^{2} + a d^{3} - b c^{3} + 4 b c^{2} d - b c d^{2}\right)}{c^{4} + 4 c^{3} d + 6 c^{2} d^{2} + 4 c d^{3} + d^{4}} & \frac{- 10 a c d + 10 a d^{2} + 10 b c^{2} - 10 b c d}{c^{3} + 3 c^{2} d + 3 c d^{2} + d^{3}} & \frac{5 \left(a d - b c\right)}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d} & 0 & 0\\\frac{- a c^{5} d + 57 a c^{4} d^{2} - 302 a c^{3} d^{3} + 302 a c^{2} d^{4} - 57 a c d^{5} + a d^{6} + b c^{6} - 57 b c^{5} d + 302 b c^{4} d^{2} - 302 b c^{3} d^{3} + 57 b c^{2} d^{4} - b c d^{5}}{c^{7} + 7 c^{6} d + 21 c^{5} d^{2} + 35 c^{4} d^{3} + 35 c^{3} d^{4} + 21 c^{2} d^{5} + 7 c d^{6} + d^{7}} & \frac{6 \left(a c^{4} d - 26 a c^{3} d^{2} + 66 a c^{2} d^{3} - 26 a c d^{4} + a d^{5} - b c^{5} + 26 b c^{4} d - 66 b c^{3} d^{2} + 26 b c^{2} d^{3} - b c d^{4}\right)}{c^{6} + 6 c^{5} d + 15 c^{4} d^{2} + 20 c^{3} d^{3} + 15 c^{2} d^{4} + 6 c d^{5} + d^{6}} & \frac{- 15 a c^{3} d + 165 a c^{2} d^{2} - 165 a c d^{3} + 15 a d^{4} + 15 b c^{4} - 165 b c^{3} d + 165 b c^{2} d^{2} - 15 b c d^{3}}{c^{5} + 5 c^{4} d + 10 c^{3} d^{2} + 10 c^{2} d^{3} + 5 c d^{4} + d^{5}} & \frac{20 \left(a c^{2} d - 4 a c d^{2} + a d^{3} - b c^{3} + 4 b c^{2} d - b c d^{2}\right)}{c^{4} + 4 c^{3} d + 6 c^{2} d^{2} + 4 c d^{3} + d^{4}} & \frac{- 15 a c d + 15 a d^{2} + 15 b c^{2} - 15 b c d}{c^{3} + 3 c^{2} d + 3 c d^{2} + d^{3}} & \frac{6 \left(a d - b c\right)}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d} & 0\\\frac{1}{c^{8} + 8 c^{7} d + 28 c^{6} d^{2} + 56 c^{5} d^{3} + 70 c^{4} d^{4} + 56 c^{3} d^{5} + 28 c^{2} d^{6} + 8 c d^{7} + d^{8}} \left(a c^{6} d - 120 a c^{5} d^{2} + 1191 a c^{4} d^{3} - 2416 a c^{3} d^{4} + 1191 a c^{2} d^{5} - 120 a c d^{6} + a d^{7} - b c^{7} + 120 b c^{6} d - 1191 b c^{5} d^{2} + 2416 b c^{4} d^{3} - 1191 b c^{3} d^{4} + 120 b c^{2} d^{5} - b c d^{6}\right) & \frac{1}{c^{7} + 7 c^{6} d + 21 c^{5} d^{2} + 35 c^{4} d^{3} + 35 c^{3} d^{4} + 21 c^{2} d^{5} + 7 c d^{6} + d^{7}} \left(- 7 a c^{5} d + 399 a c^{4} d^{2} - 2114 a c^{3} d^{3} + 2114 a c^{2} d^{4} - 399 a c d^{5} + 7 a d^{6} + 7 b c^{6} - 399 b c^{5} d + 2114 b c^{4} d^{2} - 2114 b c^{3} d^{3} + 399 b c^{2} d^{4} - 7 b c d^{5}\right) & \frac{21 \left(a c^{4} d - 26 a c^{3} d^{2} + 66 a c^{2} d^{3} - 26 a c d^{4} + a d^{5} - b c^{5} + 26 b c^{4} d - 66 b c^{3} d^{2} + 26 b c^{2} d^{3} - b c d^{4}\right)}{c^{6} + 6 c^{5} d + 15 c^{4} d^{2} + 20 c^{3} d^{3} + 15 c^{2} d^{4} + 6 c d^{5} + d^{6}} & \frac{- 35 a c^{3} d + 385 a c^{2} d^{2} - 385 a c d^{3} + 35 a d^{4} + 35 b c^{4} - 385 b c^{3} d + 385 b c^{2} d^{2} - 35 b c d^{3}}{c^{5} + 5 c^{4} d + 10 c^{3} d^{2} + 10 c^{2} d^{3} + 5 c d^{4} + d^{5}} & \frac{35 \left(a c^{2} d - 4 a c d^{2} + a d^{3} - b c^{3} + 4 b c^{2} d - b c d^{2}\right)}{c^{4} + 4 c^{3} d + 6 c^{2} d^{2} + 4 c d^{3} + d^{4}} & \frac{- 21 a c d + 21 a d^{2} + 21 b c^{2} - 21 b c d}{c^{3} + 3 c^{2} d + 3 c d^{2} + d^{3}} & \frac{7 \left(a d - b c\right)}{c^{2} + 2 c d + d^{2}} & \frac{a + b}{c + d}\end{matrix}\right]$$

normal distribution


In [109]:
f_normal = define(let=f(z), be=exp(-z**2/2)/sqrt(2*pi))
f_normal


Out[109]:
$$f{\left (z \right )} = \frac{\sqrt{2} e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}}$$

In [110]:
f_normal_derivatives = [f_normal.rhs.diff(z, i) for i in range(m)]
f_normal_derivatives


Out[110]:
$$\left [ \frac{\sqrt{2} e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}}, \quad - \frac{\sqrt{2} z e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}}, \quad \frac{\sqrt{2} e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}} \left(z^{2} - 1\right), \quad \frac{\sqrt{2} z e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}} \left(- z^{2} + 3\right), \quad \frac{\sqrt{2}}{\sqrt{\pi}} \left(\frac{z^{4}}{2} - 3 z^{2} + \frac{3}{2}\right) e^{- \frac{z^{2}}{2}}, \quad \frac{\sqrt{2} z}{\sqrt{\pi}} \left(- \frac{z^{4}}{2} + 5 z^{2} - \frac{15}{2}\right) e^{- \frac{z^{2}}{2}}, \quad \frac{\sqrt{2} e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}} \left(z^{6} - 15 z^{4} + 45 z^{2} - 15\right), \quad \frac{\sqrt{2} z e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}} \left(- z^{6} + 21 z^{4} - 105 z^{2} + 105\right)\right ]$$

In [111]:
g_normal = Hermite_interpolation_polynomial(f_normal, eigendata, Phi_polynomials)
#g_normal # to long to show

In [112]:
g_normal = g_normal.subs(eigenvals)
g_normal


Out[112]:
$$\operatorname{f_{ 8 }}{\left (z \right )} = \frac{\sqrt{2} z^{7}}{504 \sqrt{\pi} e^{\frac{1}{2}}} - \frac{\sqrt{2} z^{6}}{360 \sqrt{\pi} e^{\frac{1}{2}}} - \frac{\sqrt{2} z^{5}}{20 \sqrt{\pi} e^{\frac{1}{2}}} + \frac{13 \sqrt{2} z^{4}}{72 \sqrt{\pi} e^{\frac{1}{2}}} - \frac{5 \sqrt{2} z^{3}}{72 \sqrt{\pi} e^{\frac{1}{2}}} - \frac{3 \sqrt{2} z^{2}}{8 \sqrt{\pi} e^{\frac{1}{2}}} - \frac{\sqrt{2} z}{90 \sqrt{\pi} e^{\frac{1}{2}}} + \frac{2081 \sqrt{2}}{2520 \sqrt{\pi} e^{\frac{1}{2}}}$$

normal function


In [117]:
m=3
rho = symbols(r'\rho')
R = define(symbols('R'), Matrix(m, m, lambda n,k: 1 if n == k else rho if abs(k-n) == 1 else 0))
R


Out[117]:
$$R = \left[\begin{matrix}1 & \rho & 0\\\rho & 1 & \rho\\0 & \rho & 1\end{matrix}\right]$$

In [118]:
m=2
rho = symbols(r'\rho')
R = define(symbols('R'), Matrix(m, m, lambda n,k: 1 if n == k else rho if abs(k-n) == 1 else 0))
R


Out[118]:
$$R = \left[\begin{matrix}1 & \rho\\\rho & 1\end{matrix}\right]$$

In [119]:
eigendata = spectrum(R)
eigendata


Out[119]:
$$\sigma{\left (R \right )} = \left ( \left \{ 1 : \left ( \lambda_{1}, \quad m_{1}\right ), \quad 2 : \left ( \lambda_{2}, \quad m_{2}\right )\right \}, \quad \left \{ \lambda_{1} : \rho + 1, \quad \lambda_{2} : - \rho + 1\right \}, \quad \left \{ m_{1} : 1, \quad m_{2} : 1\right \}\right )$$

In [120]:
data, eigenvals, multiplicities = eigendata.rhs

In [121]:
Phi_polynomials = component_polynomials(eigendata, early_eigenvals_subs=True)
Phi_polynomials


Out[121]:
$$\left \{ \left ( 1, \quad 1\right ) : \Phi_{ 1, 1 }{\left (z \right )} = \frac{z}{2 \rho} + \frac{\rho - 1}{2 \rho}, \quad \left ( 2, \quad 1\right ) : \Phi_{ 2, 1 }{\left (z \right )} = - \frac{z}{2 \rho} + \frac{\rho + 1}{2 \rho}\right \}$$

In [122]:
f = Function('f')
f_geometric = define(let=f(z), be=exp(-z**2/2)/sqrt(2*pi))
f_geometric


Out[122]:
$$f{\left (z \right )} = \frac{\sqrt{2} e^{- \frac{z^{2}}{2}}}{2 \sqrt{\pi}}$$

In [123]:
f = Function('f')
f_geometric = Eq(f(z), f(z).integrate((z,0,oo)), evaluate=False)
f_geometric


Out[123]:
$$f{\left (z \right )} = \int_{0}^{\infty} f{\left (z \right )}\, dz$$

In [124]:
[f_geometric.rhs.diff(z, i) for i in range(11)]


Out[124]:
$$\left [ \int_{0}^{\infty} f{\left (z \right )}\, dz, \quad 0, \quad 0, \quad 0, \quad 0, \quad 0, \quad 0, \quad 0, \quad 0, \quad 0, \quad 0\right ]$$

In [126]:
g_geometric = Hermite_interpolation_polynomial(f_geometric, eigendata, Phi_polynomials)
g_geometric


Out[126]:
$$\operatorname{f_{ 2 }}{\left (z \right )} = z \left(\frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} - \frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\right) + \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2} - \frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}$$

In [127]:
g_geometric_v = g_geometric.subs(eigenvals)
g_geometric_v


Out[127]:
$$\operatorname{f_{ 2 }}{\left (z \right )} = z \left(\frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} - \frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\right) + \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2} - \frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \frac{1}{2 \rho} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}$$

In [128]:
g_g = Eq(Function('g_g')(z), (g_geometric_v.rhs.radsimp()*(2520*sqrt(pi)*exp(1/S(2))/sqrt(2))).radsimp().simplify())
g_g


Out[128]:
$$\operatorname{g_{g}}{\left (z \right )} = \frac{630 \sqrt{2}}{\rho} \sqrt{\pi} \left(\rho \left(\int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\right) + z \left(\int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} - \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\right) - \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\right) e^{\frac{1}{2}}$$

In [129]:
P = Matrix(m, m, binomial)
with lift_to_matrix_function(g_geometric_v) as G_geometric:
    P_geometric = G_geometric(R)
P_geometric
#P_geometric*(2520*sqrt(pi)*exp(1/S(2))/sqrt(2))**(-1)


Out[129]:
$$\operatorname{f_{ 2 }}{\left (R \right )} = \left[\begin{matrix}\frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2} & \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} - \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\\\frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} - \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2} & \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{1} \right )}\, d\lambda_{1} + \frac{1}{2} \int_{0}^{\infty} f{\left (\lambda_{2} \right )}\, d\lambda_{2}\end{matrix}\right]$$

In [130]:
(Integral(exp(-z), (z, 0,oo))/2).doit()


Out[130]:
$$\frac{1}{2}$$

In [131]:
P_geometric.subs({f: Lambda(t, exp(-t))})


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False

TypeError: 'property' object is not iterable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-131-f2ab9f13588c> in <module>()
----> 1 P_geometric.subs({f: Lambda(t, exp(-t))})

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in subs(self, *args, **kwargs)
    914             rv = self
    915             for old, new in sequence:
--> 916                 rv = rv._subs(old, new, **kwargs)
    917                 if not isinstance(rv, Basic):
    918                     break

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval
     97 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1028         rv = self._eval_subs(old, new)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv
   1032 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1000                 if not hasattr(arg, '_eval_subs'):
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):
   1004                     hit = True

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval
     97 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1028         rv = self._eval_subs(old, new)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv
   1032 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1000                 if not hasattr(arg, '_eval_subs'):
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):
   1004                     hit = True

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval
     97 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1028         rv = self._eval_subs(old, new)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv
   1032 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1000                 if not hasattr(arg, '_eval_subs'):
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):
   1004                     hit = True

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval
     97 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1028         rv = self._eval_subs(old, new)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv
   1032 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1000                 if not hasattr(arg, '_eval_subs'):
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):
   1004                     hit = True

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval
     97 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1028         rv = self._eval_subs(old, new)
   1029         if rv is None:
-> 1030             rv = fallback(self, old, new)
   1031         return rv
   1032 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in fallback(self, old, new)
   1000                 if not hasattr(arg, '_eval_subs'):
   1001                     continue
-> 1002                 arg = arg._subs(old, new, **hints)
   1003                 if not _aresame(arg, args[i]):
   1004                     hit = True

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
     93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
---> 95                     retval = func(*args, **kwargs)
     96                 return retval
     97 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/core/basic.py in _subs(self, old, new, **hints)
   1026             return new
   1027 
-> 1028         rv = self._eval_subs(old, new)
   1029         if rv is None:
   1030             rv = fallback(self, old, new)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/concrete/expr_with_limits.py in _eval_subs(self, old, new)
    312                     xab = (old, old)
    313                 limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
--> 314                 if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
    315                     sub_into_func = False
    316                     break

TypeError: 'property' object is not iterable

In [132]:
_.doit()


Out[132]:
$$\frac{1}{2}$$

In [133]:
eigen_data(_)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-133-40a823759534> in <module>()
----> 1 eigen_data(_)

NameError: name 'eigen_data' is not defined

In [59]:
det(_)


Out[59]:
$$- \left(- \frac{1}{2} \log{\left (- \rho + 1 \right )} + \frac{1}{2} \log{\left (\rho + 1 \right )}\right)^{2} + \left(\frac{1}{2} \log{\left (- \rho + 1 \right )} + \frac{1}{2} \log{\left (\rho + 1 \right )}\right)^{2}$$

In [57]:
P_geometric.subs({f: Lambda(z, tanh(z))}).applyfunc(lambda i: i.rewrite(exp).simplify())


Out[57]:
$$\left[\begin{matrix}\frac{\left(-1 + e^{4}\right) e^{2 \rho}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}} & \frac{\left(e^{4 \rho} - 1\right) e^{2}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}}\\\frac{\left(e^{4 \rho} - 1\right) e^{2}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}} & \frac{\left(-1 + e^{4}\right) e^{2 \rho}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}}\end{matrix}\right]$$

In [57]:
P_geometric.subs({f: Lambda(z, tanh(z))}).applyfunc(lambda i: i.rewrite(exp).simplify())


Out[57]:
$$\left[\begin{matrix}\frac{\left(-1 + e^{4}\right) e^{2 \rho}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}} & \frac{\left(e^{4 \rho} - 1\right) e^{2}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}}\\\frac{\left(e^{4 \rho} - 1\right) e^{2}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}} & \frac{\left(-1 + e^{4}\right) e^{2 \rho}}{e^{2 \rho} + e^{2 \rho + 4} + e^{4 \rho + 2} + e^{2}}\end{matrix}\right]$$

In [28]:
P_geometric.subs({f: Lambda(z, 1/z)}).applyfunc(simplify)


Out[28]:
$$\left[\begin{matrix}\frac{\rho^{2} - 1}{2 \rho^{2} - 1} & \frac{\rho}{2 \rho^{2} - 1} & - \frac{\rho^{2}}{2 \rho^{2} - 1}\\\frac{\rho}{2 \rho^{2} - 1} & - \frac{1}{2 \rho^{2} - 1} & \frac{\rho}{2 \rho^{2} - 1}\\- \frac{\rho^{2}}{2 \rho^{2} - 1} & \frac{\rho}{2 \rho^{2} - 1} & \frac{\rho^{2} - 1}{2 \rho^{2} - 1}\end{matrix}\right]$$

In [30]:
(R**(-1)).applyfunc(simplify)


Out[30]:
$$\left[\begin{matrix}\frac{\rho^{2} - 1}{2 \rho^{2} - 1} & \frac{\rho}{2 \rho^{2} - 1} & - \frac{\rho^{2}}{2 \rho^{2} - 1}\\\frac{\rho}{2 \rho^{2} - 1} & - \frac{1}{2 \rho^{2} - 1} & \frac{\rho}{2 \rho^{2} - 1}\\- \frac{\rho^{2}}{2 \rho^{2} - 1} & \frac{\rho}{2 \rho^{2} - 1} & \frac{\rho^{2} - 1}{2 \rho^{2} - 1}\end{matrix}\right]$$

In [56]:
_*(2*sqrt(pi)*exp(1/S(2))/sqrt(2))


Out[56]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\-1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\-1 & -2 & 1 & 0 & 0 & 0 & 0 & 0\\1 & -3 & -3 & 1 & 0 & 0 & 0 & 0\\9 & 4 & -6 & -4 & 1 & 0 & 0 & 0\\23 & 45 & 10 & -10 & -5 & 1 & 0 & 0\\-25 & 138 & 135 & 20 & -15 & -6 & 1 & 0\\-583 & -175 & 483 & 315 & 35 & -21 & -7 & 1\end{matrix}\right]$$

In [57]:
_**(-1)


Out[57]:
$$\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\3 & 2 & 1 & 0 & 0 & 0 & 0 & 0\\11 & 9 & 3 & 1 & 0 & 0 & 0 & 0\\49 & 44 & 18 & 4 & 1 & 0 & 0 & 0\\257 & 245 & 110 & 30 & 5 & 1 & 0 & 0\\1539 & 1542 & 735 & 220 & 45 & 6 & 1 & 0\\10299 & 10773 & 5397 & 1715 & 385 & 63 & 7 & 1\end{matrix}\right]$$

In [58]:
production_matrix(_, exp=True)


Out[58]:
$$\left[\begin{matrix}1 & 1 & 0 & 0 & 0 & 0 & 0\\2 & 1 & 2 & 0 & 0 & 0 & 0\\2 & 2 & 1 & 3 & 0 & 0 & 0\\\frac{4}{3} & 2 & 2 & 1 & 4 & 0 & 0\\\frac{2}{3} & \frac{4}{3} & 2 & 2 & 1 & 5 & 0\\\frac{4}{15} & \frac{2}{3} & \frac{4}{3} & 2 & 2 & 1 & 6\\\frac{4}{45} & \frac{4}{15} & \frac{2}{3} & \frac{4}{3} & 2 & 2 & 1\end{matrix}\right]$$