{"id":175,"date":"2022-04-25T21:35:00","date_gmt":"2022-04-25T19:35:00","guid":{"rendered":"https:\/\/bowfinger.de\/blog\/?p=175"},"modified":"2022-04-25T16:36:58","modified_gmt":"2022-04-25T14:36:58","slug":"numbers-games-z-transform-and-some-sympy","status":"publish","type":"post","link":"https:\/\/bowfinger.de\/blog\/2022\/04\/numbers-games-z-transform-and-some-sympy\/","title":{"rendered":"Numbers games: Z-Transform and some sympy"},"content":{"rendered":"\n<p>Back in uni me and control systems never really clicked. So I took a dive into the topic as I had the time. Long story short for all who know equally little or even less about the maths of control systems as I do:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Often, you model control systems using the Laplace transform. That&#8217;s nice and good for continuous systems.<\/li><li>Once you&#8217;re going to the discrete (digital) world, you want to use the Z-transform.<\/li><li>There is a (complicated) relation between Laplace domain and <em>Z<\/em> domain.<\/li><li>There are approximations, using a complex maps to map from Laplace to Z domain (a bilinear transformation, Tustin&#8217;s method, being the one used here).<\/li><\/ul>\n\n\n\n<p>This is a post on serendipity, because what this is about is actually neither control systems, <em>Z<\/em>-, or Laplace transforms but a numbers game. Bare with me.<\/p>\n\n\n\n<p>Many systems can be modelled using a rational function of the form<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-0d1b4c7b91f7cc326bd87fab8fc9cb57_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#71;&#40;&#115;&#41;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#115;&#117;&#109;&#92;&#108;&#105;&#109;&#105;&#116;&#115;&#95;&#123;&#105;&#61;&#48;&#125;&#94;&#109;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#105;&#32;&#115;&#94;&#105;&#125;&#123;&#92;&#115;&#117;&#109;&#92;&#108;&#105;&#109;&#105;&#116;&#115;&#95;&#123;&#105;&#61;&#48;&#125;&#94;&#110;&#32;&#92;&#97;&#108;&#112;&#104;&#97;&#95;&#105;&#32;&#115;&#94;&#105;&#125;&#32;&#92;&#113;&#113;&#117;&#97;&#100;&#92;&#116;&#101;&#120;&#116;&#123;&#92;&#97;&#108;&#112;&#104;&#97;&#95;&#48;&#32;&#61;&#32;&#49;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"63\" width=\"110\" style=\"vertical-align: -27px;\"\/><\/p>\n\n\n\n<p>You can easily put this into <code>sympy<\/code> and play around with it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import sympy as sy\n\ns, z, Ts = sy.symbols(\"s, z, T_s\")\n\na0 = sy.S.One\na1, a2 = sy.symbols(\"alpha_1, alpha_2\")\nb0, b1, b2 = sy.symbols(\"beta_0, beta_1, beta_2\")\n\nG = (b0 * s**2 + b1 * s + b2) \/ (a0 * s**2 + a1 * s + a2)\nG # use `print(sy.latex(G))` to get the LaTeX representation<\/code><\/pre>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-9c972f6fcf78ff27f4f7e7825a131d56_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#102;&#114;&#97;&#99;&#123;&#92;&#98;&#101;&#116;&#97;&#95;&#123;&#48;&#125;&#32;&#115;&#94;&#123;&#50;&#125;&#32;&#43;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#123;&#49;&#125;&#32;&#115;&#32;&#43;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#123;&#50;&#125;&#125;&#123;&#92;&#97;&#108;&#112;&#104;&#97;&#95;&#123;&#49;&#125;&#32;&#115;&#32;&#43;&#32;&#92;&#97;&#108;&#112;&#104;&#97;&#95;&#123;&#50;&#125;&#32;&#43;&#32;&#115;&#94;&#123;&#50;&#125;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"29\" width=\"85\" style=\"vertical-align: -9px;\"\/><\/p>\n\n\n\n<p>Nice. Let&#8217;s generalise this a little bit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import sympy as sy\n\ns, z, Ts = sy.symbols(\"s, z, T_s\")\n\nN, M = 2, 2\n\na = sy.symbols(f\"alpha_1:{N+1}\")\na = (sy.S.One, *a)\nb = sy.symbols(f\"beta_0:{M+1}\")\n\nG = sy.Add(*[b[i] * s**i for i in range(M+1)]) \/ sy.Add(*[a[i] * s**i for i in range(N+1)])<\/code><\/pre>\n\n\n\n<p>By playing with the values for <code>N<\/code> and <code>M<\/code> we can now generate any order of rational function we wish. Again, not the thing this article is about.<\/p>\n\n\n\n<p>Then there is the bilinear transform called Tustin&#8217;s method that approximately maps the function <em>G<\/em> from the Laplace domain into the <em>Z<\/em> domain.<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-bef9bdc094adebe0f86ae6bcd34849fb_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#115;&#32;&#92;&#82;&#105;&#103;&#104;&#116;&#97;&#114;&#114;&#111;&#119;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#125;&#123;&#84;&#95;&#115;&#125;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#122;&#45;&#49;&#125;&#123;&#122;&#43;&#49;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"24\" width=\"81\" style=\"vertical-align: -8px;\"\/><\/p>\n\n\n\n<p>Let&#8217;s do this in <code>sympy<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">tustin = 2\/Ts * (z-1)\/(z+1)\n\nG.subs({s: tustin}).simplify()<\/code><\/pre>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-ee1a1f8d9dae033c13bc580b6ebdb54d_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#102;&#114;&#97;&#99;&#123;&#84;&#95;&#123;&#115;&#125;&#94;&#123;&#50;&#125;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#123;&#48;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#43;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#94;&#123;&#50;&#125;&#32;&#43;&#32;&#50;&#32;&#84;&#95;&#123;&#115;&#125;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#123;&#49;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#45;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#43;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#43;&#32;&#52;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#123;&#50;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#45;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#94;&#123;&#50;&#125;&#125;&#123;&#84;&#95;&#123;&#115;&#125;&#94;&#123;&#50;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#43;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#94;&#123;&#50;&#125;&#32;&#43;&#32;&#50;&#32;&#84;&#95;&#123;&#115;&#125;&#32;&#92;&#97;&#108;&#112;&#104;&#97;&#95;&#123;&#49;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#45;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#43;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#32;&#43;&#32;&#52;&#32;&#92;&#97;&#108;&#112;&#104;&#97;&#95;&#123;&#50;&#125;&#32;&#92;&#108;&#101;&#102;&#116;&#40;&#122;&#32;&#45;&#32;&#49;&#92;&#114;&#105;&#103;&#104;&#116;&#41;&#94;&#123;&#50;&#125;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"34\" width=\"265\" style=\"vertical-align: -13px;\"\/><\/p>\n\n\n\n<p>Sweet. Now, I want to have the representation in two polynomials in <em>z<\/em> (numerator and denominator) to extract the coefficients (because that&#8217;s what I wanted to hack into code):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">num, den = G.as_numer_denom()\nnum = sy.Poly(num, z)\nden = sy.Poly(den, z)\n\nnum.coeffs()\nden.coeffs()<\/code><\/pre>\n\n\n\n<p>This gives you a nice, codeable result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">num: [  T_s**2*beta_0 + 2*T_s*beta_1  + 4*beta_2,\n      2*T_s**2*beta_0                 - 8*beta_2,\n        T_s**2*beta_0 - 2*T_s*beta_1  + 4*beta_2]\nden: [  T_s**2        + 2*T_s*alpha_1 + 4*alpha_2,\n      2*T_s**2                        - 8*alpha_2,\n        T_s**2        - 2*T_s*alpha_1 + 4*alpha_2]<\/pre>\n\n\n\n<p>&#8230; but my eye spotted a pattern here. Do you see it? It&#8217;s easier to see in matrix representation, and I&#8217;ll only look at <code>num<\/code> (i.e. the expression with \u03b2<em><sub>i<\/sub><\/em> in it, because I set \u0251<sub>0<\/sub> to 1):<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-0111e93f51a33f323518a06ce9b77417_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#116;&#101;&#120;&#116;&#123;&#110;&#117;&#109;&#125;&#94;&#123;&#40;&#78;&#61;&#50;&#41;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#38;&#32;&#43;&#50;&#32;&#38;&#32;&#43;&#52;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#50;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#45;&#56;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#38;&#32;&#45;&#50;&#32;&#38;&#32;&#43;&#52; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#50;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#49;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#48;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#50; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"64\" width=\"294\" style=\"vertical-align: -27px;\"\/><\/p>\n\n\n\n<p>Here is the resulting matrix for N = M = 3 and for N = M = 5:<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-1dcb0a9e54b893690c2472b5a7a7f433_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#116;&#101;&#120;&#116;&#123;&#110;&#117;&#109;&#125;&#94;&#123;&#40;&#78;&#61;&#51;&#41;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#50;&#32;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#51;&#32;&#32;&#32;&#32;&#38;&#32;&#50;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#52;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#51;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#32;&#32;&#32;&#38;&#32;&#50;&#52;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#51;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#50;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#49;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#50;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#48;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#51; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#92;  &#92;&#116;&#101;&#120;&#116;&#123;&#110;&#117;&#109;&#125;&#94;&#123;&#40;&#78;&#61;&#53;&#41;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#50;&#32;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#38;&#32;&#51;&#50;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#53;&#32;&#32;&#32;&#32;&#38;&#32;&#54;&#32;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#56;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#48;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#32;&#32;&#38;&#32;&#51;&#50;&#32;&#32;&#32;&#38;&#32;&#51;&#50;&#48;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#48;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#38;&#32;&#51;&#50;&#32;&#32;&#32;&#38;&#32;&#45;&#51;&#50;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#53;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#54;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#56;&#32;&#32;&#38;&#32;&#49;&#54;&#48;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#38;&#32;&#45;&#51;&#50; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#53;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#52;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#51;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#50;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#50;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#51;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#49;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#52;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#48;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#53; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32; \" title=\"Rendered by QuickLaTeX.com\" height=\"221\" width=\"455\" style=\"vertical-align: -59px;\"\/><\/p>\n\n\n\n<p>Here are the resulting matrices for N = M = 4:<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-d20fc9b003b94abf81b6ecbcf9ceeb43_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#116;&#101;&#120;&#116;&#123;&#110;&#117;&#109;&#125;&#94;&#123;&#40;&#78;&#61;&#52;&#41;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#50;&#32;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#32;&#32;&#38;&#32;&#45;&#54;&#52;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#54;&#32;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#57;&#54;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#38;&#32;&#45;&#54;&#52;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#49;&#54; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#52;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#51;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#50;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#50;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#49;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#51;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#48;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#52; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"108\" width=\"390\" style=\"vertical-align: -49px;\"\/><\/p>\n\n\n\n<p>Here are the resulting matrices for N = M = 6<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-820ba4837214deab8e2d618e1f703e23_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#116;&#101;&#120;&#116;&#123;&#110;&#117;&#109;&#125;&#94;&#123;&#40;&#78;&#61;&#54;&#41;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#50;&#32;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#38;&#32;&#51;&#50;&#32;&#32;&#32;&#38;&#32;&#54;&#52;&#32;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#54;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#51;&#50;&#32;&#32;&#38;&#32;&#45;&#49;&#50;&#56;&#32;&#38;&#32;&#45;&#51;&#56;&#52;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#53;&#32;&#32;&#32;&#38;&#32;&#49;&#48;&#32;&#32;&#32;&#38;&#32;&#45;&#52;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#52;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#32;&#32;&#38;&#32;&#49;&#54;&#48;&#32;&#32;&#38;&#32;&#57;&#54;&#48;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#50;&#48;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#54;&#52;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#49;&#50;&#56;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#53;&#32;&#32;&#32;&#38;&#32;&#45;&#49;&#48;&#32;&#32;&#38;&#32;&#45;&#52;&#32;&#32;&#32;&#38;&#32;&#50;&#52;&#32;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#32;&#32;&#38;&#32;&#45;&#49;&#54;&#48;&#32;&#38;&#32;&#57;&#54;&#48;&#32;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#54;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#56;&#32;&#32;&#32;&#32;&#38;&#32;&#48;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#51;&#50;&#32;&#32;&#38;&#32;&#49;&#50;&#56;&#32;&#32;&#38;&#32;&#45;&#51;&#56;&#52;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#49;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#50;&#32;&#32;&#32;&#38;&#32;&#52;&#32;&#32;&#32;&#32;&#38;&#32;&#45;&#56;&#32;&#32;&#32;&#38;&#32;&#49;&#54;&#32;&#32;&#32;&#38;&#32;&#45;&#51;&#50;&#32;&#32;&#38;&#32;&#54;&#52;&#32; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#54;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#48;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#53;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#52;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#50;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#51;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#51;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#50;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#52;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#49;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#53;&#32;&#92;&#92; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#84;&#95;&#115;&#94;&#48;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#54; &#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#32;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"152\" width=\"538\" style=\"vertical-align: -70px;\"\/><\/p>\n\n\n\n<p>The odd values for N and M produce matrices with all non-zero values, so I&#8217;ll look at those first.<\/p>\n\n\n\n<p>What I find stunning is the fact that there are so many patterns and yet I fail to think of a pattern that creates the whole matrix. For example, the first column clearly follows the binomial distribution:<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-a7684aab495933bff8c72f4c31be9ad0_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#78;&#32;&#92;&#92;&#32;&#107;&#92;&#101;&#110;&#100;&#123;&#112;&#109;&#97;&#116;&#114;&#105;&#120;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"43\" width=\"36\" style=\"vertical-align: -17px;\"\/><\/p>\n\n\n\n<p>where <em>k<\/em> is the row number starting with 0.<\/p>\n\n\n\n<p>The first and last rows of the matrix are power series of 2 and -2 respectively:<\/p>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bowfinger.de\/blog\/wp-content\/ql-cache\/quicklatex.com-708eda5fdbd59193ec017ea25de109ae_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#50;&#94;&#108;&#32;&#92;&#113;&#117;&#97;&#100;&#32;&#92;&#116;&#101;&#120;&#116;&#123;&#97;&#110;&#100;&#125;&#32;&#92;&#113;&#117;&#97;&#100;&#32;&#40;&#45;&#50;&#41;&#94;&#108; \" title=\"Rendered by QuickLaTeX.com\" height=\"20\" width=\"119\" style=\"vertical-align: -5px;\"\/><\/p>\n\n\n\n<p>where <em>l<\/em> is the column number starting at 0.<\/p>\n\n\n\n<p>Every column has a different sign pattern starting at <em>all positive<\/em> on column 0 and <em>alternating, starting with +<\/em> on the last column.<\/p>\n\n\n\n<p>Ignoring the signs, the columns are related like this<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>N<\/td><td>#0 \u21b7 #N-1<\/td><td>#1 \u21b7 #N-2<\/td><td>#2 \u21b7 #N-3<\/td><td>#3 \u21b7 #N-4<\/td><\/tr><tr><td>3<\/td><td>\u0fbe 8<\/td><td>\u0fbe 2<\/td><td><\/td><td><\/td><\/tr><tr><td>5<\/td><td>\u0fbe 32<\/td><td>\u0fbe 8<\/td><td>\u0fbe 2<\/td><td><\/td><\/tr><tr><td>7<\/td><td>\u0fbe 128<\/td><td>\u0fbe 32<\/td><td>\u0fbe 8<\/td><td>\u0fbe 2<\/td><\/tr><\/tbody><\/table><figcaption>What multiples relate the l<sup>th<\/sup> column from the left with the l<sup>th<\/sup> column from the right, ignoring the sign.<\/figcaption><\/figure>\n\n\n\n<p>Maybe this follows from the power series mentioned earlier. But looking at the coefficients in each column the binomial pattern is lost as you move to the inside.<\/p>\n\n\n\n<p>And last but not least wild zeros appear when you look at the even values for N and M:<\/p>\n\n\n\n<p>Apparently, in the middle row as well as the middle column, every other value is zero.<\/p>\n\n\n\n<p>All right, I&#8217;m absolutely sure mathematicians and control systems theoreticians have looked at this back in the day and this is all solved and done. Still, I found it interesting to look at.<\/p>\n\n\n\n<p>If you want to create those values yourself, you can use this little script, and modify <code>N<\/code> and <code>M<\/code>. But beware, at N = 10 the script runs for 10 seconds. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import sympy as sy\n\ns, z, Ts = sy.symbols(\"s, z, T_s\")\n\nN, M = 3, 3  # &lt;-- Modify here\n\na = sy.symbols(f\"alpha_1:{N+1}\")\na = (sy.S.One, *a)\nb = sy.symbols(f\"beta_0:{M+1}\")\n\nG = sy.Add(*[b[i] * s**i for i in range(M+1)]) \/ sy.Add(*[a[i] * s**i for i in range(N+1)])\n\ntustin = 2\/Ts * (z-1)\/(z+1)\nG = G.subs({s: tustin}).simplify()\n\nnum, den = G.as_numer_denom()\nnum = sy.Poly(num, z)\nden = sy.Poly(den, z)\n\nfor l in num.coeffs():\n    p = sy.Poly(l, Ts)\n    for i, B in enumerate(p.all_coeffs()):\n        try:\n            coeff, _ = B.as_two_terms()\n        except:\n            coeff = 0 if B is sy.S.Zero else 1\n        print(f\"{repr(coeff):6s} &amp; \", end=\"\")\n    print()<\/code><\/pre>\n\n\n\n<p>Oh, and of course you can change <code>N<\/code> and <code>M<\/code> independently from each other, but I could not be bothered to look at this as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I was working on digital control systems, namely PID controllers. But this proved to become a weird pattern generator.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[30,31,29],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-mathematics","tag-numbers","tag-sympy"],"_links":{"self":[{"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":52,"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions\/233"}],"wp:attachment":[{"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bowfinger.de\/blog\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}