home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
calculat
/
sm30a.zip
/
SYMBMATH.H40
< prev
next >
Wrap
Text File
|
1993-11-07
|
4KB
|
120 lines
4.8 Sums, Products, Series and Polynomials
You can compute partial, finite or infinite sums and
products. Sums and products can be differentiated and integrated. You
construct functions like Taylor polynomials or finite Fourier series.
The procedure is the same for sums as products so all examples will
be restricted to sums. The general formats for these functions are:
sum(expr, x from xmin to xmax)
sum(expr, x from xmin to xmax step dx)
prod(expr, x from xmin to xmax)
prod(expr, x from xmin to xmax step dx)
The expression expr is evaluated at xmin, xmin+dx, ... up to the last
entry in the series not greater than xmax, and the resulting values
are added or multiplied. The part "step dx" is optional and defaults
to 1. The values of xmin, xmax and dx can be any real number.
Here are some examples:
sum(j, j from 1 to 10)
for 1 + 2 + .. + 10.
sum(3^j, j from 0 to 10 step 2)
for 1 + 3^2 + ... + 3^10.
Here are some sample Taylor polynomials:
sum(x^j/j!, j from 0 to n)
for exp(x).
sum((-1)^j*x^(2*j+1)/(2*j+1)!, j from 0 to n)
for sin(x) of degree 2*n+2.
Remember, the 3 keywords (from, to and step) can be replaced by
the comma ,.
4.8.1. Partial Sum
The function
partsum(f(x),x)
finds the partial sum (symbolic sum).
Example 4.8.1.1.
Find the sum of 1^2 + 2^2 ... + n^2.
IN: partsum(n^2, n)
OUT: 1/6 n (1 + n) (1 + 2 n)
4.8.2 Infinite Sum
The function
infsum(f(x),x)
finds the infinite sum, i.e. sum(f(x), x from 0 to inf).
Example:
IN: infsum(1/n!, n)
OUT: e
4.8.3. Series
The external functions
series(f(x), x)
series(f(x), x, order)
to find the Taylor series at x=0. The arguement (order) is optional and
defaults to 5.
Example 4.8.3.1.
Find the power series expansion for cos(x) at x=0.
IN: series(cos(x), x)
OUT: 1 - 1/2 x^2 + 1/24 x^4
The series expansion of f(x) is useful for numeric calculation
of f(x). If you can provide derivative of any function of f(x) and f(0),
you may be able to calculate the function value at any x, by series
expansion. Accurary of calculation depends on the order of series
expansion. Higher order, more accuracy, but longer calculation time.
Example 4.8.3.2.
calculate f(i), knowing f'(x)=-sin(x) and f(0)=1.
IN: f'(x_) := -sin(x)
IN: f(0) := 1
IN: f(x_) := eval(series(f(x), x)) # must eval()
OUT: f(x_) := 1 - 1/2 x^2 + 1/24 x^4
IN: f(i)
OUT: 37/24
4.8.4 Polynomials
Polynomials are automately sorted in order from low to high.
You can pick up one of coefficient of x in polynomials by
coef(poly, x^n)
e.g.
IN: coef(x^2+5*x+6, x)
OUT: 5
Note that you cannot pick up the coefficient of x^0 by coef(y,x^0).
You can pick up one of coefficient of x in polynomials with
order < 5 by
coef(poly, x,n)
e.g.
IN: coef(x^2+5*x+6, x,0)
OUT: 6
You can pick up all of coefficients of x in polynomials with
order < 5 by
coefall(poly, x)
e.g.
IN: coefall(x^2+5*x+6, x)
OUT: [6, 5, 1] # 6 + 5*x + x^2
IN: coefall(a*x^2+b*x+c, x)
OUT: [c, b, a] # symbolic values of coefficients
You can pick up the highest order of x in polynomials with
order < 5 by
order(poly, x)
e.g.
IN: order(x^2+5*x+6, x)
OUT: 2
You can factor polynomials in order < 5 with respect with x by
factor(poly, x)
e.g.
IN: factor(x^2+5*x+6, x)
OUT: (2 + x) (3 + x)
Note that Shareware version of SymbMath cannot do this factor as
it lacks solve().