Professional Documents
Culture Documents
LAB9
LAB9
In this Lab
Also remember that we used to perform the following steps for the evaluation
(that is finding the value) of this double integral
Also remember that we can evaluate the double integrals over rectangular (where
limits of integration are constant) and non-rectangular (where limits of
integration are not all constant) regions.
The further detail about double integrals can be found in Calculus books, and here
in this Lab we shall write a program in Matlab which will evaluate the double
integrals for us over rectangular and non-rectangular regions.
The Matlab function which we shall use for the evaluation of double integrals is
called integral2.
clc;
clear all;
close all;
switch ch
case 1
len = length(x1);
for i = 1: len
Qvalues(i) = integral2(f,x1(i),x2(i),y1(i),y2(i));
end
for i = 1:len
end
case 2
switch ch
case 1
len = length(x1);
for i = 1: len
Qvalues(i) = integral2(f,x1(i),x2(i),y1{i},y2(i));
end
for i = 1:len
end
case 2
len = length(x1);
for i = 1: len
Qvalues(i) = integral2(f,x1(i),x2(i),y1(i),y2{i});
end
for i = 1:len
end
case 3
len = length(x1);
for i = 1: len
Qvalues(i) = integral2(f,x1(i),x2(i),y1{i},y2{i});
end
for i = 1:len
6
end
end
end
Let us now, test this program for the following double integrals.
Integral Number 1
In this way, we have obtained the value of above double integral for various
limits of integration.
8
Integral Number 2
In this way, we have obtained the value of above mentioned double integral for
various limits of integration.
We know from Calculus courses that the average value of function of two
variables f (x, y) over a region R (for example, a thin plate covering R) is equal to
the integral over the region divided by the area of R.
Here,
Area of R = (x2-x1) * (y2-y1)
Let us now, write an interactive program in Matlab which will find for the average
values of entered function of two variables f(x, y) at entered values of limits of
integration.
11
The program will also display the mean or average of set of average values of
function and their standard deviation. And will display a bar chart of average
values of function f(x, y) versus area.
clc;
clear all;
close all;
len = length(x1);
for i = 1:len
Qvalues(i) = integral2(f,x1(i),x2(i),y1(i),y2(i));
Avgvaluesoff(i) = Qvalues(i)./Area(i);
fprintf('\n\n');
end
12
Averageofavgvalues = mean(Avgvaluesoff);
Stdeviation = std(Avgvaluesoff);
xlabel('Areas');
Let us now use the above program to find the average value of function
f(x,y) = xsin2(xy)
The average value of average values of f is 1.17724 and the standard deviation of
this set of average values is 0.39296
14
1.4
X 22.21
Y 1.178
1.2
0.8
0.6
0.4
0.2
0
0 5 10 15 20 25 30 35 40 45 50
Areas
Application Number 1.
Let us compute the value of this double integral at various limits of integration by
writing an interactive program in Matlab.
len = length(x1);
for i = 1: len
Qvalues(i) = integral2(p,x1(i),x2(i),y1(i),y2(i));
end
for i = 1:len
end
x2 = [3 7 10]
Enter the values of lower limit of integration as a vector
y1 = [-3 -3 -3]
Enter the values of upper limit of integration as a vector
y2 = [3 7 10]
Application Number 2
We take our second application of double integrals from economics, and we shall
study the profit function.
18
A car manufacturer estimates that when x-units of a particular car are sold
domestically and y-units of the same car are sold to foreign countries. Then, the
profit in dollars is given by.
clc;
clear all;
close all;
len = length(x1);
for i = 1:len
Pvalues(i) = integral2(P,x1(i),x2(i),y1(i),y2(i));
fprintf('\nThe total profit is %.2f $ when x varies from %.2f to %.2f and
y varies from %.2f to %.2f\n\n', Pvalues(i), x1(i),x2(i),y1(i),y2(i));
end
The total profit is 11825837.50 $ when x varies from 100.00 to 125.00 and y
varies from 70.00 to 89.00
The total profit is 27878497.50 $ when x varies from 100.00 to 135.00 and y
varies from 70.00 to 99.00
The total profit is 63600000.00 $ when x varies from 100.00 to 150.00 and y
varies from 70.00 to 110.00
Application Number 3:
21
Then, our task is to find the average value of subject’s response to the stimuli.
We know from Calculus courses that this average value will be equal to
22
Let us now write, an interactive program in Matlab which will compute the above
average value.
The program will also display the mean or average of set of average values of
function and their standard deviation. And will display a bar chart of average
values of function E(x, y) versus area.
clc;
clear all;
close all;
len = length(x1);
for i = 1:len
Evalues(i) = integral2(E,x1(i),x2(i),y1(i),y2(i));
Avgvaluesoff(i) = Evalues(i)./Area(i);
fprintf('\n\n');
end
Averageofavgvalues = mean(Avgvaluesoff);
Stdeviation = std(Avgvaluesoff);
xlabel('Areas');
24
The average Value of Entered function is 10.1431725 when x-units vary from
0.00000 to 1.00000 and y-units vary from 0.00000 to 3.00000
The average Value of Entered function is 10.0833904 when x-units vary from
0.00000 to 2.00000 and y-units vary from 0.00000 to 4.00000
25
The average Value of Entered function is 10.0452991 when x-units vary from
0.00000 to 3.00000 and y-units vary from 0.00000 to 5.00000
0
3 8 15
Areas
26
Application Number 4
Q (K, L) = 50K3/5L2/5
Where
K is the monthly capital investment (in units of $1000), and L is the number of
monthly labor hours.
Now, suppose that monthly capital investment varies between $10,000 and
$12,000, while monthly use of labor varies between 2800 and 3200 worker-hours.
Find the monthly output for the manufacturer.
27
To achieve this task we shall write an interactive program in Matlab, which will
find for us the average monthly output for different variations of L and K.
The program will also display the mean or average of set of average values of
function and their standard deviation. And will display a bar chart of average
values of function Q (K, L) versus area.
clc;
clear all;
close all;
len = length(K1);
K1units1000doll = K1./1000;
K2units1000doll = K2./1000;
for i = 1:len
Qvalues(i) =
integral2(Q,K1units1000doll(i),K2units1000doll(i),L1(i),L2(i));
AvgvaluesofQ(i) = Qvalues(i)./Area(i);
fprintf('\n\n');
end
Averageofavgvalues = mean(AvgvaluesofQ);
Stdeviation = std(AvgvaluesofQ);
% Display
xlabel('\bf Areas');
The average Value of Entered function is 5181.2319971 units when K vary from
10000.00000 $ to 12000.00000 $ and L vary from 2800.00000 worker-hours to
3200.00000 worker-hours
The average Value of Entered function is 5525.5472262 units when K vary from
10000.00000 $ to 14000.00000 $ and L vary from 2800.00000 worker-hours to
3400.00000 worker-hours
30
The average Value of Entered function is 5863.9334492 units when K vary from
10000.00000 $ to 16000.00000 $ and L vary from 2800.00000 worker-hours to
3600.00000 worker-hours
The average Value of Entered function is 6197.4205220 units when K vary from
10000.00000 $ to 18000.00000 $ and L vary from 2800.00000 worker-hours to
3800.00000 worker-hours
The average Value of Entered function is 6526.7840081 units when K vary from
10000.00000 $ to 20000.00000 $ and L vary from 2800.00000 worker-hours to
4000.00000 worker-hours
The average Value of Entered function is 6852.6244604 units when K vary from
10000.00000 $ to 22000.00000 $ and L vary from 2800.00000 worker-hours to
4200.00000 worker-hours
The average value of average values of Q(K,L) is 6024.5902772 and the standard
deviation of this set of average values is 625.1107449
31
6000 X 8000
Y 6197
5000
4000
3000
2000
1000
0
800 2400 4800 8000 12000 16800
Areas
Application Number 5
We know that
varies with temperature and wavelength. This model matched remarkably well
with experimental intensity distribution curves.
Let us now, write a program which will find for us the average value of this
function
When
And
clc;
clear all;
close all;
K = (h * c) ./ (lamda .* k .* Temp);
len = length(lamda1);
for i = 1:len
AvgvaluesofI(i) = Ivalues(i)./Area(i);
fprintf('\n\n');
end
The average Value of Entered function is 6.859062e+09 when lamda vary from
1.000000e-07 to 1.000000e-06 and temperature vary from 100.0000 to
2000.0000
The average Value of Entered function is 1.210689e+11 when lamda vary from
1.000000e-07 to 2.000000e-06 and temperature vary from 100.0000 to
2500.0000
The average Value of Entered function is 2.673163e+11 when lamda vary from
1.000000e-07 to 3.000000e-06 and temperature vary from 100.0000 to
3000.0000
The average Value of Entered function is 4.177683e+11 when lamda vary from
1.000000e-07 to 4.000000e-06 and temperature vary from 100.0000 to
3500.0000
36
The average Value of Entered function is 5.899102e+11 when lamda vary from
1.000000e-07 to 5.000000e-06 and temperature vary from 100.0000 to
4000.0000