0

I would like to know if there is a fast way to create the following matrix (note that the matrix is defined with arbitrary precision):

ny=500;
nyt=ny-100;
$MinPrecision=100;
t1 = AbsoluteTime[];
If[ny == nyt,
  Miy = IdentityMatrix[ny + 1]
  ,
  ct[j_] := If[j == 0 || j == nyt, 2, 1];
  Cm = Table[
    N[2/(nyt ct[j] ct[i]) Cos[(i j \[Pi])/nyt], $MinPrecision], {i, 0,
      nyt}, {j, 0, nyt}];
  Cm = If[ny - nyt == 0, Cm, 
    Flatten[Join[{Cm, ConstantArray[0, {ny - nyt, nyt + 1}]}], 1]];
  CIm = Table[
    N[Cos[(i j \[Pi])/ny], $MinPrecision], {i, 0, ny}, {j, 0, ny}];
  Miy = CIm.Cm;
  Clear[ct, Cm, CIm];
  Print[" Delta t= ", AbsoluteTime[] - t1];
  Clear[t1]
  ];

This matrix is needed to interpolate (via matrix multiplication) a function f(x) defined on a Chebyshev grid with nyt points, into a Chebyshev grid with ny points, with nyt>ny.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
user12588
  • 585
  • 3
  • 8
  • 1
    I am pretty sure that one should use the fast Fourier transform instead of matrix-vector multiplication for that, but I am not knowledgable enough to work out the details. – Henrik Schumacher Apr 07 '20 at 05:45
  • 1
    By the way: have you run your code? It throws plenty of errors. Please be sure that it is correct before you ask other people for their investment. – Henrik Schumacher Apr 07 '20 at 05:47
  • For some reason, when I copied the string $MinPrecision into into StackExchanged, it got transformed into MinPrecision. It has been amended. It runs on my machine without any errors. Just takes way too long to run. – user12588 Apr 07 '20 at 13:13
  • If you look at the first code block here, then variable cc contains the coefficients of the Chebyshev expansion of the interpolating polynomial at the Chebyshev nodes. – Michael E2 Apr 07 '20 at 22:29
  • Thanks Michael. In your link, you seem to have access to f as a function, but in my case I only know f at some number of points nyt<ny. – user12588 Apr 08 '20 at 00:53
  • Do you have a reference for this matrix you're constructing? – J. M.'s missing motivation May 16 '20 at 04:57

0 Answers0