\(A[n_]\  := 
      Table[
	Switch[i, 
		1, 
          Switch[j, \ 1, \ 1 + p, \ 2, \ \(-2\) p, \ 3, \ p, \ _, \ 0], 
		
          n, Switch[j, n, \ 1 + p, n - 1, \ \(-2\) p, \ n - 2, \ p, \ _, 0], 
          
		_, 
          Switch[j - i, \ \(-1\), p, 0, \ 1 - 2  p, \ 1, \ p, \ _, \ 0]\ ], 

        			\ {i, \ n}, \ {j, \ n}]\)

MatrixForm[A[6]]

B[n_]  := 
      Table[Switch[Mod[j - i, n],  n - 1, p, 0,  1 - 2  p,  1,  p,  _,  
          0] , {i,  n},  {j,  n}]

MatrixForm[B[6]]

circleBasis[n_]  :=  
      Table[Cos[
            2  Floor[j/2] i π/n + If[j == 1, 0, Mod[j, 2]] π/2], 
           {i, n},  {j, n}]  // FullSimplify

MatrixForm[circleBasis[6]]

\(intBasis[n_]\  := \ 
      Module[{i, j}, 
		
        Transpose[
          Table[
			
            \(Switch[i, 
				1, Table[1, {j, n}], 
				2, 
                  Table[j - 1, {j, n}], 
				3, 
                  Table[\((j - 1)\) \((j - 2)\)/2, {j, n}], 
				_, 
                  Table[Cos[
                        \(\(2  π\)\/\(2  n - 4\)\) \((i - 3)\) 
                          \((j - 3\/2)\)]/
                      Cos[\(\(2  π\)\/\(2  n - 4\)\) \((i - 3)\)\/2], {j, 
                      n}]]\  // TrigExpand\)\  // FullSimplify, 

            			{i, n}]]]\)

MatrixForm[intBasis[6]]

study[F_, n_] :=
	Module[
		{a, b,  c,  d,  f,  i,  z},
		a  =  F[n];
		Print["n = ",  n];
		Print["a = ", MatrixForm[a]];
		z =JordanDecomposition[a];
		b  =  
              Collect[Expand[
                  FullSimplify[z[[1]]]], 
                 p];
		c  =  
              Collect[Expand[
                  FullSimplify[z[[2]]]], 
                 p];
		d  =  
              Table[c[[i
                    ]][[i
                  ]],  {i,  n}];
		
		z  =   
              Block[{p = 0.1}, 
                Table[{d[[i]],  i}, 
                   {i,  n}]];
		f[a_, b_]  :=  
              a[[1]]  >=  
                b[[1]];
		z  =  Sort[z,  f];
		z  =  
              Table[z[[i
                    ]][[2
                  ]],  {i,  n}];
		b  =  
              Transpose[
                Transpose[b][[z]]]
                ;
		c  =  
              Transpose[
                Transpose[c[[z]]]
                    [[z]]];
		Print["b = ", MatrixForm[b]];
		Print["c = ", MatrixForm[c]];
		
		b  =  Block[{p = 1}, Transpose[b]];
		For[i = 1, i <= n, ++i,ListPlot[b[[i]], ImageSize  ->  {200, 75}, AspectRatio  ->  0.25,PlotJoined -> True, Axes -> False, PlotLabel -> b[[i]]]];
		Print[];
	]

study[A, 6]

study2[F_, G_, n_] :=
	Module[
		{a, b, bi, c, d, i, j},
		a  =  F[n];
		Print["n = ",  n];
		Print["a = ", MatrixForm[a]];

		b  =  G[n];
		bi  =  Inverse[b]  // FullSimplify;
		c  =  bi . a . b  // FullSimplify;
		d  =  
              Table[c[[i
                    ]][[i
                  ]],  {i,  n}];
		
		Print["b = ", MatrixForm[b]];
		Print["c = ", MatrixForm[c]];
		Print["d = ", MatrixForm[d], " = ",  
              MatrixForm[N[d, 3]]];
		
		For[i = 1, i <= n, ++i,ListPlot[Transpose[b][[i
                      ]] , ImageSize  ->  {144, 54}, AspectRatio  ->  0.25,PlotJoined -> True, Axes -> False, PlotLabel -> Expand[N[d[[i]], 3]]]];
		Print[];
	]

study2[B, circleBasis, 6]

study2[A, intBasis, 6]

study2[A, intBasis, 8]

f[x_, n_]  :=  Max[0, x - ((n + 1)/2.) ]

Plot[f[x, 8], {x, 1, 8}];

\(transform[f_, G_, GFn_, n_]\  := 
	
      Module[
		{a, ai, b, i}, 
		a\  = \ G[n]\  // N; 
		
        ai\  = \ Inverse[a]; 
		b\  = \ Table[f[i, n], {i, n}]; 
		
        c\  = \ ai . b; 
		

        		 (*\ Print["b = ", MatrixForm[b], ",  ai.b = ", 
            MatrixForm[Chop[c]]]; \ *) 
		
        Plot[∑\+\(i = 1\)\%n c[[i]] 
                GFn[i, n, x] - f[x, n], {x, 1, n}, \ PlotRange -> All, \ 
          AxesOrigin -> {1, 0}]; ]\)

\(NintBasis[n_]\  := \ 
      Module[{i, j}, 
		
        Transpose[
          Table[
			
            Switch[i, 
				1, Table[1. , {j, n}], 
				2, 
              Table[j - 1. , {j, n}], 
				3, 
              Table[\((j - 1)\) \((j - 2)\)/2. , {j, n}], 
				_, 
              Table[N[Cos[
                      \(\(2  π\)\/\(2  n - 4\)\) \((i - 3)\) 
                        \((j - 3\/2)\)]/
                    Cos[\(\(2  π\)\/\(2  n - 4\)\) \((i - 3)\)\/2]], {j, 
                  n}]], 
			{i, n}]]]\)

\(\(NintFn[i_, n_, x_]\  := 
      Switch[i, 
		1, 1. , 
		2, x - 1. , 
		3, 
        \((x - 1)\) \((x - 2)\)/2. , 
		_, 
        Cos[\(\(2  π\)\/\(2  n - 4\)\) \((i - 3)\) \((x - 3\/2. )\)]/
          Cos[\(\(2  π\)\/\(2  n - 4\)\) \((i - 3)\)\/2. ]]
		\)\)

Do[transform[f, NintBasis, NintFn, i], {i, 10, 30, 10}];

g[x_, n_]  :=  
      (E^((((((x - (n + 1)/2. )/n)))^2)))

Plot[g[x, 8], {x, 1, 8}];

Do[transform[g, NintBasis, NintFn, i], {i, 10, 30, 10}];

diffuse[f_, x_, n_, Δt_]  := 
      (1/(2 (Sqrt[ π Δt]))) 
        (∫_(-
              ∞)^∞) 
                (E^(-((z^2)/(4  Δt)))) 
            f[x - z, n] \[DifferentialD]z