Early Integration.
At least as many problems can be solved using integration as can be solved using differentiation, so we need to find out about it too.
Integration involves adding up, which Maple does with sum .
Learning to use the Maple words Sum and sum .
> Sum(i, i=1..100)=sum(i, i=1..100);
>
Suppose we wanted to compute the sum of the arithmetic sequence
4 + 7 + 10 + 13 + .... + 301
First thing we need to figure out is the number of terms in this sum. Well, the common difference is 3 and the last term can be written as
where
> i = (301-4)/3;
So, there are 100 terms and we can sum this as
> Sum(4+i*3,i=0..99)=sum(4+i*3,i=0..99);
Exercise: Find the sum of the square roots of i, as i goes from 1 to 10.
If we proceed as before,
> Sum(sqrt(i),i=1..10)=sum(sqrt(i),i=1..10);
the sum is not computed. Use evalf to convert it to a decimal.
> Sum(sqrt(i),i=1..10)=evalf(sum(sqrt(i),i=1..10));
Exercise: Calculate the value of the following sum for n taking values 4, 8, 12 and n. What is the limiting value of the sum as n gets large?
> seq(Sum((1/2)^i,i=0..4*j)=sum((1/2)^i,i=0..4*j),j=1..3);
>
> Sum((1/2)^i,i=0..n)=sum((1/2)^i,i=0..n);
>
>
As n gets large,
goes to 0, so the whole sum goes to 2.
> Sum((1/2)^i,i=0..infinity) =limit(Sum((1/2)^i,i=0..n),n=infinity);
>
Riemann Sums with the student package
There are some useful words in the student package dealing with integration.
> with(student);
> middlesum(x^2,x=0..1,10) = value(middlesum(x^2,x=0..1,10));
> middlebox(x^2,x=0..1,10);
>
Two Area Problems
Exercise: Plot the ellipse
with a parametric plot. Estimate the area of the ellipse. Use the fact that it is four times the area under the graph of
for x between 0 and 2.
Solution:
A
parameterization of the ellipse
is to let
, as t goes from 0 to
.
> ellipse := [2*cos(t),sin(t),t=0..2*Pi];
> plot(ellipse,scaling=CONSTRAINED);
The upper ellipse is the graph of the function
> f := x -> sqrt(1- x^2/4);
>
We can use leftsum and rightsum to estimate the area.
>
for i from 1 to 5 do
left := 4*evalf(value(leftsum(f(x),x=0..2,25*i)));
right := 4*evalf(value(rightsum(f(x),x=0..2,25*i)));
print(left,right,right-left); od:
By inspecting the table of numbers, we see that area is between 6.24 and 6.31.
>
Solution:
First plot the function and calculate the endpoints of R.
> y := 10 - x^4 + 10*x;
> plot(y,x=-2..3);
> sol := fsolve(y,x);
>
for i from 1 to 5 do
value(student[middlesum](y,x=sol[1]..sol[2],20*i))
od;
The area looks to be 41.7 to the nearest 0.1, using middlesum with 100 subdivisions.
Learning to use Int and int.
The fundamental theorem of calculus tells us that a definite integral of a continuous function f can be evaluated by first finding an antiderivative of f and then calculating the difference of its values at the endpoints: In symbols,
provided
.
You can use the Maple word int to find antiderivatives, (aka indefinite integrals).
For example, to find an antiderivative of
, use int.
> Int(x^2 + cos(x/5),x)=int(x^2 + cos(x/5),x);
Notice that there is a passive form of int, Int , for typesetting purposes.
You can also use int to evaluate definite integrals. For example, if we want to plot the region under the graph of
for x between 0 and 2 and calculate its area.
> restart;
> f := x-> x^2 + cos(x/5);
> Int(f(x),x=0..2)=int(f(x),x=0..2);
> area := evalf(int(f(x),x=0..2));
>
We will use plots[polygonplot] to shade the region.
>
### WARNING: semantics of type `string` have changed
plots[polygonplot]( [ [2,0],[0,0],[0,f(0)],seq([x/10,f(x/10)] , x=0..20) ],color=gray,title= cat(`Area = `,convert(area,string)) );
>
Exercises:
Exercise: For each of the functions below, Sketch the region under the graph and calculate the area of the region using the fundamental theorem of calculus.
a)
, for
>
>
b) Under the arch of
which contains x=0. .
>
>
c) f(x) = piecewise( x<1, sqrt(x) ,x>=1,x^2); for x between 0 and 2.
>
>
Average value.
Modeling the flow of air in lungs:
The rate of change of the volume of air in the lungs can be modeled very roughly (according to some texts) by the function
> f := t -> 1/2*sin(2*Pi*t/5);
>
>
where volume is measured in liters and time is measured in seconds. So the actual volume of air in the lungs would obtained by integrating f. Here we are assuming there is no air in the lungs at time 0.
> Int(f(tau),tau=0..t) = int(f(tau),tau=0..t);
> F := unapply(int(f(tau),tau=0..t),t);
Let's plot the rate of airflow and the volume function to get a feel for their behavior.
> plot({f,F},0..10);
>
Questions.
Question: Which is the rate of airflow function and which is its integral?
Question: What is the maximum volume of air in the lungs in this model? The minimum volume?
Question: When are the lungs half-full?
Question: What is the average rate of airflow in the lungs over the time interval [0,2.5]? [2.5,5]? [0,5]?
> ar := evalf(int(f(t),t=0..2.5)/2.5);
>
About .32 liters per second on average.
Question: What is the average volume of air in the lungs over the time interval [0,2.5]? [0,5]?
> av := evalf(int(F(t),t=0..2.5)/2.5);
>
About .4 liter air in the lungs on average.
Actually, there are different, perhaps more realistic models of the rate of airflow into the lungs. For example, consider this one,
> g := t -> (3/8-1/4*cos(4*Pi*t/5))*sin(2*Pi*t/5);
>
Problem: Using the function g to model the rate of airflow in the lungs, find the volume G of air in the lungs at time t. (Assume as before that G(0) = 0.) Plot both g and G over the time interval [0,10]. Describe qualitatively a difference that you note between this model and the model we looked at above. Calculate the maximum rate of airflow in this model. What is the maximum volume of air in the lungs in this model? What is the average volume of air in the tank in the time interval [0,5]
Two Area problems.