I wish to make a matrix that has an inverse. I need rows that look like oscillating functions so I decided to base my matrix on ChebyshevT. This code makes an n by n matrix.

makeMat[nn_] := 
 Table[Table[ChebyshevT[n, x], {x, -1, 1, 2/(nn - 1)}], {n, nn}]

An example with n = 7 is

mat = makeMat[7]; mat // MatrixForm

Mathematica graphics

The determinate of this matrix is zero



In fact all matrices with n odd are zero. It is not obvious by looking at the matrix which rows are linear combinations of others (or columns). If we do

Eigenvalues[mat] // N

{2.09478, 1.65033, -0.540451 + 1.45434 I, -0.540451 - 1.45434 I, 1.09427, -0.698129, 0.}

We can see that there is a zero entry indicating that the determinant is zero. For n = 5 there are two zero eigenvalues.

I would like to replace one row with random numbers, or possibly more appropriate values, so that the determinant is not zero.

Trying to do this in a crude manner does suggests I can change rows {1,3,5,7} but not {2,4,6}:

Table[mat1 = mat;
 mat1[[n]] = RandomReal[{-1, 1}, 7];
 {n, 7}]

{-43.7443, 0., -1.4494, 0., 1.06642, 0., 39.3547}

Is there a known way to do this? I would like to keep most of the rows unaltered because they can be interpolated nicely. I need n to be upto about 50. I have looked at other functions, e.g. Legendre and they also give zero determinants.

Any thoughts

  • $\begingroup$ try mat=makeMat[7]; mat2=MapAt[RandomReal[1, Length@mat] &, mat, {RandomChoice[ Range[1, Length[mat], 2]]}]? or mat3=MapAt[RandomReal[1, Length@mat] &, mat, {1}]? $\endgroup$ – kglr Aug 6 at 21:29
  • 2
    $\begingroup$ why don't you include a constant shift, e.g., ChebyshevT[n, x + n] instead of ChebyshevT[n, x]? This should still look oscillating, but is non-singular. $\endgroup$ – AccidentalFourierTransform Aug 6 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.