File: series.ys

package info (click to toggle)
yacas 1.3.2-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 6,164 kB
  • sloc: cpp: 16,893; java: 12,423; ansic: 11,040; sh: 4,726; makefile: 564; perl: 517
file content (27 lines) | stat: -rw-r--r-- 573 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

/* Generate a polynomial base1 + base2*x + ....*/
ArbPoly(_base,n_IsPositiveInteger) <-- Sum(MakeVector(base,n)*x^(0 .. (n-1)));

/*
   SinTaylor and ExpTaylor: direct series for the taylor series expansions
   of Sin and Exp.
   Examples:
   
   In> Simplify(SinTaylor(10) - Taylor(x,0,10)Sin(x))
   Out> 0;
   In> Simplify(ExpTaylor(10) - Taylor(x,0,10)Exp(x))
   Out> 0;
*/

SinTaylor(n_IsPositiveInteger) <-- 
[
  Local(m);
  n:=((n-1)>>1);
  m:=(1+2*(0 .. n));
  Sum((-1)^(0 .. n)*x^m/(m!));
];

ExpTaylor(n_IsPositiveInteger) <-- 
[
  Sum(x^(0 .. n)/((0 .. n)!));
];