diff options
Diffstat (limited to '845/CH7/EX7.16/Ex7_16.sce')
-rwxr-xr-x | 845/CH7/EX7.16/Ex7_16.sce | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/845/CH7/EX7.16/Ex7_16.sce b/845/CH7/EX7.16/Ex7_16.sce new file mode 100755 index 000000000..fcd56815d --- /dev/null +++ b/845/CH7/EX7.16/Ex7_16.sce @@ -0,0 +1,31 @@ +//Example 7.16
+
+clc
+clear
+
+function [f] = fun1(x)
+ f = 3*x^2 + x^3;
+endfunction
+
+n = 4;
+if n==1 then
+ M = [0 2];
+elseif n==2
+ M = [sqrt(1/3) 1];
+elseif n==3
+ M = [0 8/9; -0.774597 5/9; 0.774597 5/9];
+elseif n==4
+ M = [-0.339981 0.652145; -0.861136 0.347855; 0.339981 0.652145; 0.861136 0.347855];
+elseif n==5
+ M = [-0 0.568889; -0.538469 0.467914; -0.906180 0.236927; 0 0.568889; 0.538469 0.467914; 0.906180 0.236927];
+elseif n==6
+ M = [-0.238619 0.467914; -0.661209 0.360762; -0.932470 0.171325; 0.238619 0.467914; 0.661209 0.360762; 0.932470 0.171325];
+end
+
+X = M(:,1);
+W = M(:,2);
+I = 0;
+for i = 1:length(X)
+ I = I + W(i)*fun1(X(i));
+end
+disp(I,"I = ")
|