Oliverio, Liwayway Jade C.
Math 205
Assignment 2
Exercise 2.1
function y = liwayfunc(x)
% Computes the function x.^2 .* exp(-x.^2)
% Input ; x a number of vector
% for a vector the computation is element wise
% Output ; y - a number of vector of the same size as x
y = x.^2 .* exp(-x.^2)
>> x=-5:.1:5
x=
Columns 1 through 9:
-5.0000 -4.9000 -4.8000 -4.7000 -4.6000 -4.5000 -4.4000 -4.3000 -4.2000
Columns 10 through 18:
-4.1000 -4.0000 -3.9000 -3.8000 -3.7000 -3.6000 -3.5000 -3.4000 -3.3000
Columns 19 through 27:
-3.2000 -3.1000 -3.0000 -2.9000 -2.8000 -2.7000 -2.6000 -2.5000 -2.4000
Columns 28 through 36:
-2.3000 -2.2000 -2.1000 -2.0000 -1.9000 -1.8000 -1.7000 -1.6000 -1.5000
Columns 37 through 45:
-1.4000 -1.3000 -1.2000 -1.1000 -1.0000 -0.9000 -0.8000 -0.7000 -0.6000
Columns 46 through 54:
-0.5000 -0.4000 -0.3000 -0.2000 -0.1000 0 0.1000 0.2000 0.3000
Columns 55 through 63:
0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000
Columns 64 through 72:
1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000
Columns 73 through 81:
2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000
Columns 82 through 90:
3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000
Columns 91 through 99:
4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 4.8000
Columns 100 and 101:
4.9000 5.0000
>> y = liwayfunc(x)
y=
Columns 1 through 10:
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Columns 11 through 20:
0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0002 0.0004 0.0006
Columns 21 through 30:
0.0011 0.0019 0.0031 0.0050 0.0078 0.0121 0.0182 0.0267 0.0383 0.0536
Columns 31 through 40:
0.0733 0.0977 0.1269 0.1606 0.1979 0.2371 0.2761 0.3118 0.3412 0.3608
Columns 41 through 50:
0.3679 0.3603 0.3375 0.3002 0.2512 0.1947 0.1363 0.0823 0.0384 0.0099
Columns 51 through 60:
0 0.0099 0.0384 0.0823 0.1363 0.1947 0.2512 0.3002 0.3375 0.3603
Columns 61 through 70:
0.3679 0.3608 0.3412 0.3118 0.2761 0.2371 0.1979 0.1606 0.1269 0.0977
Columns 71 through 80:
0.0733 0.0536 0.0383 0.0267 0.0182 0.0121 0.0078 0.0050 0.0031 0.0019
Columns 81 through 90:
0.0011 0.0006 0.0004 0.0002 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000
Columns 91 through 100:
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Column 101:
0.0000
>> plot(x,y)
Exercise 2.2
% mygraph
% plots the graphs of sin x, sin 2x, sin 3x, sin 4x, sin 5x, and sin 6x
% on the interval [0,2pi]
% fix the domain and evaluation points
x = 0:.1:2*pi
% calculate powers
z = sin(x)
z2 = (sin(x)).^2
z3 = (sin(x)).^3
z4 = (sin(x)).^4
z5 = (sin(x)).^5
z6 = (sin(x)).^6
% plot each of the graphs
plot (x,z,'black',x,z2, 'blue',x,z3, 'red',x,z4, 'yellow',x,z5, 'green',x,z6, 'cyan')
>> x= 0:.1:2*pi
x=
Columns 1 through 15:
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
1.1000 1.2000 1.3000 1.4000
Columns 16 through 30:
1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000
2.6000 2.7000 2.8000 2.9000
Columns 31 through 45:
3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000
4.1000 4.2000 4.3000 4.4000
Columns 46 through 60:
4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000
5.6000 5.7000 5.8000 5.9000
Columns 61 through 63:
6.0000 6.1000 6.2000
>> mygraph
z=
Columns 1 through 9:
0 0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174
Columns 10 through 18:
0.7833 0.8415 0.8912 0.9320 0.9636 0.9854 0.9975 0.9996 0.9917
Columns 19 through 27:
0.9738 0.9463 0.9093 0.8632 0.8085 0.7457 0.6755 0.5985 0.5155
Columns 28 through 36:
0.4274 0.3350 0.2392 0.1411 0.0416 -0.0584 -0.1577 -0.2555 -0.3508
Columns 37 through 45:
-0.4425 -0.5298 -0.6119 -0.6878 -0.7568 -0.8183 -0.8716 -0.9162 -0.9516
Columns 46 through 54:
-0.9775 -0.9937 -0.9999 -0.9962 -0.9825 -0.9589 -0.9258 -0.8835 -0.8323
Columns 55 through 63:
-0.7728 -0.7055 -0.6313 -0.5507 -0.4646 -0.3739 -0.2794 -0.1822 -0.0831
z2 =
Columns 1 through 9:
0 0.0100 0.0395 0.0873 0.1516 0.2298 0.3188 0.4150 0.5146
Columns 10 through 18:
0.6136 0.7081 0.7943 0.8687 0.9284 0.9711 0.9950 0.9991 0.9834
Columns 19 through 27:
0.9484 0.8955 0.8268 0.7451 0.6537 0.5561 0.4563 0.3582 0.2657
Columns 28 through 36:
0.1827 0.1122 0.0572 0.0199 0.0017 0.0034 0.0249 0.0653 0.1230
Columns 37 through 45:
0.1958 0.2807 0.3744 0.4730 0.5728 0.6696 0.7596 0.8394 0.9055
Columns 46 through 54:
0.9556 0.9874 0.9998 0.9923 0.9652 0.9195 0.8571 0.7805 0.6927
Columns 55 through 63:
0.5972 0.4978 0.3985 0.3033 0.2159 0.1398 0.0781 0.0332 0.0069
z3 =
Columns 1 through 9:
0 0.0010 0.0078 0.0258 0.0591 0.1102 0.1800 0.2674 0.3692
Columns 10 through 18:
0.4807 0.5958 0.7078 0.8097 0.8946 0.9570 0.9925 0.9987 0.9752
Columns 19 through 27:
0.9236 0.8474 0.7518 0.6432 0.5285 0.4147 0.3082 0.2144 0.1370
Columns 28 through 36:
0.0781 0.0376 0.0137 0.0028 0.0001 -0.0002 -0.0039 -0.0167 -0.0432
Columns 37 through 45:
-0.0867 -0.1487 -0.2291 -0.3253 -0.4335 -0.5479 -0.6621 -0.7690 -0.8617
Columns 46 through 54:
-0.9341 -0.9812 -0.9998 -0.9885 -0.9483 -0.8818 -0.7935 -0.6895 -0.5765
Columns 55 through 63:
-0.4615 -0.3512 -0.2516 -0.1670 -0.1003 -0.0523 -0.0218 -0.0060 -0.0006
z4 =
Columns 1 through 9:
0 0.0001 0.0016 0.0076 0.0230 0.0528 0.1016 0.1722 0.2648
Columns 10 through 18:
0.3765 0.5014 0.6308 0.7546 0.8620 0.9431 0.9900 0.9983 0.9671
Columns 19 through 27:
0.8994 0.8019 0.6836 0.5552 0.4273 0.3092 0.2082 0.1283 0.0706
Columns 28 through 36:
0.0334 0.0126 0.0033 0.0004 0.0000 0.0000 0.0006 0.0043 0.0151
Columns 37 through 45:
0.0383 0.0788 0.1402 0.2238 0.3280 0.4483 0.5771 0.7045 0.8200
Columns 46 through 54:
0.9131 0.9750 0.9997 0.9847 0.9316 0.8455 0.7347 0.6092 0.4798
Columns 55 through 63:
0.3566 0.2478 0.1588 0.0920 0.0466 0.0195 0.0061 0.0011 0.0000
z5 =
Columns 1 through 9:
0 0.0000 0.0003 0.0023 0.0090 0.0253 0.0574 0.1110 0.1900
Columns 10 through 18:
0.2949 0.4219 0.5622 0.7033 0.8306 0.9293 0.9875 0.9979 0.9590
Columns 19 through 27:
0.8759 0.7588 0.6216 0.4793 0.3455 0.2306 0.1406 0.0768 0.0364
Columns 28 through 36:
0.0143 0.0042 0.0008 0.0001 0.0000 -0.0000 -0.0001 -0.0011 -0.0053
Columns 37 through 45:
-0.0170 -0.0418 -0.0858 -0.1539 -0.2483 -0.3669 -0.5030 -0.6455 -0.7803
Columns 46 through 54:
-0.8926 -0.9689 -0.9996 -0.9810 -0.9153 -0.8108 -0.6802 -0.5382 -0.3993
Columns 55 through 63:
-0.2756 -0.1748 -0.1002 -0.0506 -0.0216 -0.0073 -0.0017 -0.0002 -0.0000
z6 =
Columns 1 through 9:
0 0.0000 0.0001 0.0007 0.0035 0.0121 0.0324 0.0715 0.1363
Columns 10 through 18:
0.2310 0.3550 0.5010 0.6555 0.8003 0.9158 0.9851 0.9974 0.9510
Columns 19 through 27:
0.8530 0.7181 0.5652 0.4137 0.2793 0.1720 0.0950 0.0459 0.0188
Columns 28 through 36:
0.0061 0.0014 0.0002 0.0000 0.0000 0.0000 0.0000 0.0003 0.0019
Columns 37 through 45:
0.0075 0.0221 0.0525 0.1058 0.1879 0.3002 0.4384 0.5914 0.7426
Columns 46 through 54:
0.8725 0.9627 0.9995 0.9772 0.8992 0.7775 0.6297 0.4755 0.3323
Columns 55 through 63:
0.2130 0.1233 0.0633 0.0279 0.0101 0.0027 0.0005 0.0000 0.0000
% mygraph
% plots the graphs of sin x, sin 2x, sin 3x, sin 4x, sin 5x, and sin 6x
% on the interval [0,2pi]
% fix the domain and evaluation points
x = 0:.1:2*pi
% calculate powers
z = sin(x)
z2 = sin(2.*x)
z3 = sin(3.*x)
z4 = sin(4.*x)
z5 = sin(5.*x)
z6 = sin(6.*x)
% plot each of the graphs
plot (x,z,'black',x,z2, 'blue',x,z3, 'red',x,z4, 'yellow',x,z5, 'green',x,z6, 'cyan')
x = 0:.1:2*pi
x=
Columns 1 through 8:
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000
Columns 9 through 16:
0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000
Columns 17 through 24:
1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000
Columns 25 through 32:
2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000
Columns 33 through 40:
3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000
Columns 41 through 48:
4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000
Columns 49 through 56:
>> mygraph 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 5.5000
x=
Columns 1 through 8:
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000
Columns 9 through 16:
0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000
Columns 17 through 24:
1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000
Columns 25 through 32:
2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000
Columns 33 through 40:
3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000
Columns 41 through 48:
4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000
Columns 49 through 56:
4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000
Columns 57 through 63:
5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000
z=
Columns 1 through 9:
0 0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174
Columns 10 through 18:
0.7833 0.8415 0.8912 0.9320 0.9636 0.9854 0.9975 0.9996 0.9917
Columns 19 through 27:
0.9738 0.9463 0.9093 0.8632 0.8085 0.7457 0.6755 0.5985 0.5155
Columns 28 through 36:
0.4274 0.3350 0.2392 0.1411 0.0416 -0.0584 -0.1577 -0.2555 -0.3508
Columns 37 through 45:
-0.4425 -0.5298 -0.6119 -0.6878 -0.7568 -0.8183 -0.8716 -0.9162 -0.9516
Columns 46 through 54:
-0.9775 -0.9937 -0.9999 -0.9962 -0.9825 -0.9589 -0.9258 -0.8835 -0.8323
Columns 55 through 63:
-0.7728 -0.7055 -0.6313 -0.5507 -0.4646 -0.3739 -0.2794 -0.1822 -0.0831
z2 =
Columns 1 through 9:
0 0.1987 0.3894 0.5646 0.7174 0.8415 0.9320 0.9854 0.9996
Columns 10 through 18:
0.9738 0.9093 0.8085 0.6755 0.5155 0.3350 0.1411 -0.0584 -0.2555
Columns 19 through 27:
-0.4425 -0.6119 -0.7568 -0.8716 -0.9516 -0.9937 -0.9962 -0.9589 -0.8835
Columns 28 through 36:
-0.7728 -0.6313 -0.4646 -0.2794 -0.0831 0.1165 0.3115 0.4941 0.6570
Columns 37 through 45:
0.7937 0.8987 0.9679 0.9985 0.9894 0.9407 0.8546 0.7344 0.5849
Columns 46 through 54:
0.4121 0.2229 0.0248 -0.1743 -0.3665 -0.5440 -0.6999 -0.8278 -0.9228
Columns 55 through 63:
-0.9809 -1.0000 -0.9792 -0.9193 -0.8228 -0.6935 -0.5366 -0.3582 -0.1656
z3 =
Columns 1 through 9:
0 0.2955 0.5646 0.7833 0.9320 0.9975 0.9738 0.8632 0.6755
Columns 10 through 18:
0.4274 0.1411 -0.1577 -0.4425 -0.6878 -0.8716 -0.9775 -0.9962 -0.9258
Columns 19 through 27:
-0.7728 -0.5507 -0.2794 0.0168 0.3115 0.5784 0.7937 0.9380 0.9985
Columns 28 through 36:
0.9699 0.8546 0.6630 0.4121 0.1245 -0.1743 -0.4575 -0.6999 -0.8797
Columns 37 through 45:
-0.9809 -0.9946 -0.9193 -0.7620 -0.5366 -0.2632 0.0336 0.3275 0.5921
Columns 46 through 54:
0.8038 0.9437 0.9993 0.9657 0.8457 0.6503 0.3967 0.1078 -0.1909
Columns 55 through 63:
-0.4724 -0.7118 -0.8876 -0.9841 -0.9927 -0.9126 -0.7510 -0.5223 -0.2470
z4 =
Columns 1 through 9:
0 0.3894 0.7174 0.9320 0.9996 0.9093 0.6755 0.3350 -0.0584
Columns 10 through 18:
-0.4425 -0.7568 -0.9516 -0.9962 -0.8835 -0.6313 -0.2794 0.1165 0.4941
Columns 19 through 27:
0.7937 0.9679 0.9894 0.8546 0.5849 0.2229 -0.1743 -0.5440 -0.8278
Columns 28 through 36:
-0.9809 -0.9792 -0.8228 -0.5366 -0.1656 0.2315 0.5921 0.8592 0.9906
Columns 37 through 45:
0.9657 0.7883 0.4864 0.1078 -0.2879 -0.6381 -0.8876 -0.9969 -0.9488
Columns 46 through 54:
-0.7510 -0.4346 -0.0495 0.3433 0.6820 0.9129 0.9998 0.9288 0.7112
Columns 55 through 63:
0.3813 -0.0089 -0.3976 -0.7235 -0.9352 -0.9993 -0.9056 -0.6689 -0.3266
z5 =
Columns 1 through 9:
0 0.4794 0.8415 0.9975 0.9093 0.5985 0.1411 -0.3508 -0.7568
Columns 10 through 18:
-0.9775 -0.9589 -0.7055 -0.2794 0.2151 0.6570 0.9380 0.9894 0.7985
Columns 19 through 27:
0.4121 -0.0752 -0.5440 -0.8797 -1.0000 -0.8755 -0.5366 -0.0663 0.4202
Columns 28 through 36:
0.8038 0.9906 0.9349 0.6503 0.2065 -0.2879 -0.7118 -0.9614 -0.9756
Columns 37 through 45:
-0.7510 -0.3425 0.1499 0.6055 0.9129 0.9968 0.8367 0.4716 -0.0089
Columns 46 through 54:
-0.4872 -0.8462 -0.9981 -0.9056 -0.5914 -0.1324 0.3591 0.7626 0.9794
Columns 55 through 63:
0.9564 0.6992 0.2709 -0.2238 -0.6636 -0.9410 -0.9880 -0.7931 -0.4040
z6 =
Columns 1 through 9:
0 0.5646 0.9320 0.9738 0.6755 0.1411 -0.4425 -0.8716 -0.9962
Columns 10 through 18:
-0.7728 -0.2794 0.3115 0.7937 0.9985 0.8546 0.4121 -0.1743 -0.6999
Columns 19 through 27:
-0.9809 -0.9193 -0.5366 0.0336 0.5921 0.9437 0.9657 0.6503 0.1078
Columns 28 through 36:
-0.4724 -0.8876 -0.9927 -0.7510 -0.2470 0.3433 0.8137 0.9998 0.8367
Columns 37 through 45:
0.3813 -0.2073 -0.7235 -0.9869 -0.9056 -0.5079 0.0672 0.6188 0.9543
Columns 46 through 54:
0.9564 0.6244 0.0743 -0.5018 -0.9026 -0.9880 -0.7284 -0.2143 0.3747
Columns 55 through 63:
0.8328 0.9999 0.8178 0.3500 -0.2401 -0.7463 -0.9918 -0.8908 -0.4786