File: introExample37bis.tex

package info (click to toggle)
sollya 8.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,592 kB
  • sloc: ansic: 124,655; yacc: 7,543; lex: 2,440; makefile: 888; cpp: 77
file content (23 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> ChebPolynomials = proc(n) {
    var i, res;
    if (n<0) then res = [||]
    else if (n==0) then res = [|1|]
    else {
       res = [|1, _x_|];
       for i from 2 to n do res[i] = horner(2*_x_*res[i-1]-res[i-2]);
    };
    return res;
  };
> 
> f = sin(x);
> T = ChebPolynomials(4);
> canonical = on!;
> for i from 0 to 4 do T[i];
1
x
-1 + 2 * x^2
-3 * x + 4 * x^3
1 - 8 * x^2 + 8 * x^4
\end{Verbatim}
\end{minipage}\end{center}