Session 03
More Calculus: Summation of series and integration
> sum(k,k=1..n);
> factor(%); # a finite sum formula you may remember
> subs(n=100,%);
> factor(sum(k^2,k=1..n));
The formula won't look so familiar without the “factor”. Try it.
> Sum(k^2,k=1..30)=sum(k^2,k=1..30); # Sum just display the sum
> factor(sum(k^3,k=1..n));
Here are sums you might not recall from calculus.
> a:=sum(1/((2*k-1)*(2*k+1)),k=1..n);
> limit(a,n=infinity);
> b:=sum(1/k^2,k=1..n);
> ?Psi
> limit(b,n=infinity);
This is a result you have probably seen before. Do you remember how it is derived?
> sum(1/k^4,k=1..infinity);
It is often surprising to students how slowly the harmonic series diverges. What is the significance of the following calculation?
> evalf(sum(1/k,k=1..100)-ln(100));
> evalf(sum(1/k,k=1..1000)-ln(1000));
> evalf(sum(1/k,k=1..10000)-ln(10000));
Try this:
> limit(sum(1/k,k=1..n)-ln(n),n=infinity);
> evalf(%);
Integration
Note that “Int” just displays the integral. If you wanted to evaluate this you could use the value command. Here it is used for display purposes.
> Int(sin(x),x)=int(sin(x),x);
> diff(%,x);
> Int(sin(x)*x^2,x=0..Pi)=int(sin(x)*x^2,x=0..Pi);
There are some built- in packages that are useful for instructional purposes.
> with(student): # note the use of : instead of ; to suppress printing
> f:=x->x-x^3;
> plot(f(x),x=0..3/2);
> leftbox(f(x),x=0..3/2,10); # try changing the number of boxes
> ls:=leftsum(f(x),x=0..3/2,10);
> ms:=middlesum(f(x),x=0..3/2,10);
> rs:=rightsum(f(x),x=0..3/2,10);
> vls:=value(ls); vms:=value(ms); vrs:=value(rs);
> evalf(vls); evalf(vms); evalf(vrs);
Can you offer an explanation for the above results? Now let’s compute a sum with N boxes.
> lsn:=leftsum(f(x),x=0..3/2,N);
> msn:=middlesum(f(x),x=0..3/2,N);
> rsn:=rightsum(f(x),x=0..3/2,N);
> vlsn:=value(lsn); vmsn:=value(msn); vrsn:=value(rsn);
> lsn:=simplify(vlsn); msn:=simplify(vmsn); rsn:=simplify(vrsn);
The infinite limit should be the integral.
> limit(lsn,N=infinity);
> limit(msn,N=infinity);
> limit(rsn,N=infinity);
Now use Maple to do the integral the easy way.
> int(f(x),x=0..3/2);
Often Maple can not perform an integration unless you suggest a technique of integration, such as parts or a substitution. The use of integration by parts or substitution can only be performed within the student package. The following two examples illustrate that without some prodding, Maple can't perform the requested integrations..
Integration by substitution:
> with(student):
> f:=1/sqrt(1+sqrt(x));
> int(f,x);
> changevar(1+sqrt(x)=u, Int(f,x), u);
> value(%);
> subs(u=1+sqrt(x),%);
Integration by parts:
> F:=Int(ln(x + sqrt(1+x^2)),x);
> intparts(F,ln(x + sqrt(1+x^2)));
> simplify (%);
> value(%);
Integration by parts:
> i0:=Int(exp(2*x)*sin(3*x),x);
> i1:=intparts(i0,sin(3*x));
> i2:=intparts(i1,cos(3*x));
Use “op” to extract parts of the above expression.
> i00:=op(3,i2);
> ls:=combine(i0-i00);
> simplify((4/13)*ls)=(4/13)*(op(1,i2) + op(2,i2));
Here's some more on “op”.
> a:=x^2-2*y^3-x*z^2;
> nops(a);
> op(1,a); op(2,a); op(3,a);
When Maple cannot find an antiderivative, it employs a numerical method to evaluate a definite integral.
> f:=sin(x^3);
> int(f,x=0..1);
> appr:=evalf(%);
You could specify that the trapezoid rule or Simpson's method be used. Compare the results with the above calculation.
> evalf(trapezoid(f,x=0..1,10)); appr;
> evalf(simpson(f,x=0..1,6)); appr;
Finally, we use Maple to compute some areas bounded by curves.
> f:=x*exp(-.5*x); g:=(-x^3+4*x^2-3*x);
> plot({f,g},x=-1..4,y=-2..3);
> r1:=fsolve(f=g,x=-1..1);
> r2:=fsolve(f=g,x=1..2);
> r3:=fsolve(f=g,x=2..3);
> area:=Int(f-g, x=r1..r2) + Int(g-f, x=r2..r3);
> value(area);
Exercises
Problem 1: Summation problems
Use sum and value (or evalf) to compute the approximate sum out to n=100, 500 and 1000.
a) sum from n=1 to infinity, (2^n+3^n)/6^n
b) sum from n=1 to infinity, n/((n+1)*(n+2)*(n+3))
c) sum from n=1 to infinity, (2n+1)/(n^2*(n+1)^2)
d) sum from n=1 to infinity, (2^n+n^2+n)/(2^(n+1)*n*(n+1))
e) sum from n=1 to infinity, (-1)^(n-1)*(2n+1)/(n*(n+1))
f) sum from n=2 to infinity, (n-1)/n!
In the last two parts of this problem binomial(n,k) are the binomial coefficients (see help: ? binomial).
g) sum from k=1 to n, binomial(n,k)*(-1)^(k+1)
h) sum from k=1 to n, (k+1)*binomial(n,k)
Problem 2: Use leftbox, middlebox, rightbox, leftsum, middlesum, rightsum together with limit, int, Int, evalf to analyze the integrals of the functions over the given interval. For example, plot using some value of n (boxes) that gives a reasonable approximation to the value obtained using int. Also apply the trapezoid and simpson rules to each integral (try a couple of different values for n).
a) sin(x)+x, 0 <x<1
b) x *sin(1/x), 0 <x<1
c) x^2*sin(1/x), 0 <x<1
d) x* sin(1/x^2), 0 <x<1
Problem 3: Find the points of intersection of the curves and find the area bounded by the two curves.
a) e1:=x+y^2=0; e2:=x+3*y^2=2;
b) e1:=x^3-y^2=0;e2:=x+y^4=2;
Problem 4: Find the antiderivatives of
a) 1/(x^5+1) Check your answer by differentiation.
b) sqrt(1-x^2) *asin(x)
c) sqrt(2*x^3 + 3*x^2 +1) * (x^2 +x)
d) x*ln(x)
e) x^2 * sin(2*x)
<< Back - Next >>
|