Professional Documents
Culture Documents
CALCULUS 1
MATLAB PROJECT
Class: CC09
Group members:
Phạm Văn Minh Toàn 1953028
Hoàng Thắng 1952992
Dương Ngọc Trúc Uyên 1953091
Trương Ngọc Kim Ngân 1952351
Nguyễn Ngọc Lam 1952807
Phạm Thảo Nhiên 1952904
Lê Nguyễn Khánh Trúc 1953056
HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY
1. Theorem
1.1. Derivatives
The derivative of a function f at a number a, denoted by f’(a) is
( ) ( )
( )
( ) ( )
( )
∫ ( ) ∑ ( )
provided that this limit exists and gives the same value for all possible
choices of sample points. If it does exist, we say that is integrable on
.
b) If is integrable on , then
∫ ( ) ∑ ( )
where and
∫ ( ) ∑ ( ̅ ) ( ̅ ( ̅ )
Where
̅ ( )
∫ ( ) ( ( ) ( ) ( )
is here approximated by the value at the Right Endpoint. This gives multiple rectangles with
base and height ( ). Doing this for and adding up the resulting areas
produces.
( )
|∫ ( ) |
( ) ( )
Where and are continuos function of . This first-order linear differential equation is said to
be in standard form.
( ) with
PROBLEM 1. For each of the functions ƒ below, approximate its derivative at the
given value x = a in two different ways.
First, use a computer microscope (i.e., a graphing program) to view the graph of ƒ near x
= a. Zoom in until the graph looks straight and find its slope.
Second, use a calculator to find the value of the quotient
( ) ( )
for h = .1, .01, .001, ..., .000001. Based on these values of the quotients, give your best
estimate for ƒ’(a), and say how many decimal places of accuracy it has.
a) ƒ(x) = 1/x at x = 2.
b) ƒ(x) = sin(7x) at x = 3.
c) ƒ(x) = x3 at x = 200.
d) ƒ(x) = 2x at x = 5.
SOLUTION
a) ƒ(x) = 1/x at x = 2
Code:
syms x;
fplot(1/x);
xlim ([1.998, 2.0002])
ylim ([0.4995005, 0.5005005])
h ( ) ( )
0.1 -0.2506265664
0.01 -0.2500062502
0.001 -0.2500062502
0.0001 -0.2500000006
0.00001 -0.2500000001
0.000001 -0.2500000000
b) ƒ(x) = sin(7x) at x = 3.
Code:
syms x;
fplot(sin(7*x));
xlim ([2.9998, 3.0002])
ylim ([0.835, 0.84])
( ) ( )
h ( ) ( )
0.1140555285
0.1
0.1140583375
0.01
0.1140583656
0.001
0.1140583659
0.0001
0.1140583659
0.00001
0.1140583659
0.000001
c) ( ) = 3 at = 200
Code:
syms x;
fplot(x^3);
xlim ([199.998, 200.002])
ylim ([199.998^3,
200.002^3])
( ) ( )
h ( ) ( )
120000.00999999233
0.1
120000.00009988435
0.01
120000.00000186265
0.001
120000.00000186265
0.0001
120000.00006519257
0.00001
119999.9996461
0.000001
d) ( ) = 2 at =5
Code:
syms x;
fplot(2^x);
xlim ([4.9996,5.0004])
ylim ([2^4.9996,2^5.0004])
( ) ( )
h ( ) ( )
22.1984753
0.1
22.18808873
0.01
22.1807115
0.001
22.18079795
0.0001
22.18079797
0.00001
22.18079797
0.000001
PROBLEM 2. Write some short programs using Left Endpoint, Right Endpoint and
Midpoint Rules to compute the definite integral of functions ƒ below xi
SOLUTION
Code:
a=1; for i=1:10
b=2; s=s+y(i)*((b-a)./10);
s=0; end
x=linspace(1,2,11); disp ('Left Endpoint 10
y=1./x; subsintevrals:');
s end
disp('Right Endpoint 20
a=1; subsintevrals:');
b=2; s
x=linspace(1,2,21);
y=1./x; a=1;
s=0; b=2;
for i=1:20 s=0;
s=s+y(i)*((b-a)./20); z=linspace(1,2,11);
end x=[];
disp('Left Endpoint 20 for i=1:10
subsintevrals:'); x(i)=(z(i)+z(i+1))/2;
s end
y=1./x;
for j=1:10
a=1; s=s+y(j)*((b-a)./10);
b=2; end
s=0; disp('Midpoint 10 subsintevrals:');
x=linspace(1,2,11); s
y=1./x;
for i=2:11 a=1;
s=s+y(i)*((b-a)./10); b=2;
end s=0;
disp('Right Endpoint 10 z=linspace(1,2,21);
subsintevrals:'); x=[];
s for i=1:20
x(i)=(z(i)+z(i+1))/2;
a=1; end
b=2; y=1./x;
s=0; for j=1:20
x=linspace(1,2,21); s=s+y(j)*((b-a)./20);
y=1./x; end
for i=2:20 disp('Midpoint 20 subsintevrals:')
s=s+y(i)*((b-a)./20); s
Code:
a = 0; %gia tri dau
b = 1; % gia tri cuoi
N = 10; % number of subintervals
deltax = (b-a)/N;
x = a + deltax/2 ; % /2 neu là midpoint , *1 neu la rightpoint , *0 neu la
leftpont
f = exp(-x^2); %pt theo de bai
Ar = 0 ;
for n = 1 : N
f = exp(-x^2); %pt theo de bai
x = x + deltax;
Ar = Ar + f ;
end
disp('midpoint 10 subsintervals: ');
disp(Ar*deltax);
PROBLEM 3. Study the Euler method to approximate the solution of first order
differential equations. The following questions concern a rabbit population described by
the logistic model.
( ) rabbits per month
a) What happens to a population of 2000 rabbits after 6 months, after 24
months, and after 5 years? To answer each question, present a table of successive
approximations that allows you to give the exact value to the nearest whole number.
b) Sketch the functions determined by the logistic equation if you start with either
2000 or 4000 rabbits. Compare the two functions. How are they differ? In what
ways are they similar?
SOLUTION
a) What happens to a population of 2000 rabbits after 6 months, after 24
months, and after 5 years? To answer each question, present a table of successive
approximations that allows you to give the exact value to the nearest whole number.
Steps Population Rate (R’) Population Rate (R’) Population Rate (R’)
(R) (R) (R)
Code:
t = input('Initial t: ');
R = input('Initial R: ');
Rprime = 0.1*R*(1-R/25000);
while (t<=period)
t = t + step;
R = R + Rprime*step;
Rprime = 0.1*R*(1-R/25000);
end
b) Sketch the functions determined by the logistic equation if you start with either
2000 or 4000 rabbits. Compare the two functions. How are they differ? In what
ways are they similar?
Code:
%3b)
syms R1 R2 Rprimeb toAdd
R1 = 2000;
R2 = 40000;
Value1 = [0,R1];
Value2 = [0,R2];
%This is the plot for 2000 rabbits as starter
for Month = 0:0.01:200
%Step: 0.01, Time: 200 months
Rprimeb = (.1*R1*(1 - (R1/25000)));
R1 = R1+Rprimeb*0.01;
toAdd = [Month,R1];
%Add rows to matrix 2*N
Value1 = [Value1;toAdd];
end
%Plot each point == each row in matrix
subplot(2,2,1)
plot(Value1(:,1),Value1(:,2)), title('From 2000')
%Similarly, for 40000 as starter
for Month = 0:0.01:200
Rprimeb = (.1*R2*(1 - (R2/25000)));
R2 = R2+Rprimeb*0.01;
toAdd = [Month,R2];
Value2 = [Value2;toAdd];
end
subplot(2,2,2)
plot(Value2(:,1),Value2(:,2)), title('From 40000')