3

Could you help me write elegant form of formula for Chebysev nodes in $[a,b]$ ? Size of vector of points is $n$.

I am working with octave, but the most important thing is: How to formulate it clear and elegant ?

user40545
  • 155
  • 1
    It seems that your question is about the best way to write a program from Octave; since this is primarily a coding question, it seems off-topic here and should rather be on stackoverflow. –  Dec 28 '15 at 23:19
  • 1
    nodes = cos(pi/n*((1:n)-.5)) –  Dec 28 '15 at 23:24
  • Ok, thanks. Unfortunately I did forget to say that I have interval $[a, b]$. What is form of nodes in case of interval ? – user40545 Dec 28 '15 at 23:54

1 Answers1

5

Consider $n$ Chebyshev interpolation points $x_k=\cos\frac{\pi}2 \frac{2k+1}{n}\in[-1,1]$, $k=0,1,2,\dots, n-1$. Use $x_k$ to define $z_k\in [a,b]$ as following $${z_k} = \frac{{a + b}}{2} + \frac{{b - a}}{2}{x_k}$$

k=0:(n-1);
nodes = cos( (pi/2) * (2*k+1)/(n) ) ;
nodes = (a+b)/2 + nodes*(b-a)/2;