Mat523 Mini Project PDF
Mat523 Mini Project PDF
LINEAR ALGEBRA 2
PRERARED BY:
NAME MATRIC NO
AUNI ARDINI BINTI ADDY AZHAR 2020819486
GROUP:
T5CS2672B2
PREPARED FOR:
DR.NUR ATIKAH SALAHUDIN
DATE OF SUBMISSION:
6 MAY 2021
INDEX
NO CONTENT PAGE
1 Introduction 2
2 Medhotology
3 Conclusion 15
4 Appendix 16
1
1.INTRODUCTION
The table below is the data about the investigation on the number of rape cases. The
data or statistic are based on cases reported to the Royal Malaysia Police (PDRM)
and collected from 2000 until 2017. We can define that the year as variable X and the
number of rape cases as variable Y,since the number of cases was increasing by year.
We have to observe by using 3 model which are Linear Model, Quadraric Model and
Cubic Model and calculating the best fit curve for the data.
Year,X 10 11 12 13 14 15 16 17 18
Number 3626 3595 3301 2998 2767 2045 1873 1698 1582
of rape
cases,Y
2
2. METHODOLOGY
a) Find the equation of the curve by using the least squares method.
(MTM)v=MTv v=(MTM)-1((MTy)
(MTM)=
(MTM)-1=
3
MTy=
Therefore: v = (MTM)-1((MTy)
v=
y=
4
b)Find the error vector and the magnitude of this error vector.
e= - =
Magnitude of error :
||e||= 3322.180495
5
b) Plot the graphs:
I. Points of scattered data and best fir curve that you have calculated.
6
2.2 Quadratic Model, y= a + bx + cx²
a) Find the equation of the curve by using the least squares method
(MTM) =
(MTM)-1
=
7
(MTy) =
v=
y=
8
b) Find the error vector and the magnitude of this error vector.
e=y-Mv
e= - =
9
c) Plot the graphs
i) Points of scattered data and best fit curve that you have calculated.
10
2.3 Cubic model y = a + bx + cx² + dx³
a) Find the equation of the curve by using the least squares method.
(MTM) =
(MTM)-1=
11
(MTy) =
v=
y=
12
b) Find the error vector and the magnitude of this error vector.
Error vector, e = y -Mv
e= - =
13
c) Plot the graphs:
i. Points od scattered data and best fit curve that you have calculated.
14
3. CONCLUSION
Based on the investigation that we have done, there are many ways toknowthe best
method that can be used based on the method :
Therefore from the research that we have done, the best method that can be use for
this problem is linear cubic equation method because linear cubic equation has the
smallest magnitude of error than linear equation and linear quadratic equation.
15
4. APPENDIX
A:= Matrix(18,1,fill=1)
B:=<1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18>
x:=<1217,1386,1431,1479,1760,1930,
2455,3098,3409,3629,3595,3301,2998,
2767,2045,1873,1698,1552> A:= B:= x:=
16
M:=<A|B>
M:=
M+
c:=M+M
c:=
d:=LinearAlgebra[MatrixInverse](c)
d:=
f:=
f:=M+x
v:=
v:=d.f
17
g:=M.v
e:=x-g
g:= e:=
evalf(VectorCalculus[Norm](e))
|e|:=
18
restart
with(plots)
B:= 286555/153+(44827/969)*x
19
restart
with(stats[fit])
m := 286555/153+(44827/969)*x
x := 44827/969
y := 286555/153
20
plot([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18], [resid], symbol =
solidcircle)
21
o Maple command for Quadratic Model
interface(rtablesize = 50)
A := Matrix(18, 1, fill = 1)
22
x := <1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18>
X := <12, 22, 32, 42, 52, 62, 72, 82, 92, 102,
112, 122, 132, 142, 152, 162, 172, 182>
M := <<A>|<x>|<X>>
23
m := M+M
inverse := LinearAlgebra[MatrixInverse](m)
f :=M+y
v := inverse . f
mv := M . f
24
e := y-mv
evalf(VectorCalculus[Norm](e)) |e|=
25
restart
with(plots);
A := [[1, 1217], [2, 1386], [3, 1431], [4, 1479], [5,
1760], [6, 1931], [7, 2455], [8, 3098], [9, 3409], [10,
3629], [11, 3595], [12, 3301], [13, 2998], [14, 2767],
[15, 2045], [16, 1873], [17, 1698], [18, 1552]]
B := -(26099/912)*x^2+(9147209/15504)*x+8225/136
26
restart
with(stats[fit]);
year := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, year:=
17, 18]
a := -26099/912 a:=
b := 9147209/15504 b:=
c := 8225/136 c:=
27
plot([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18], [resid], symbol = solidcircle)
28
o Maple Command for Cubic Model
COMMAND OUTPUT
interface(rtablesize = 50)
A := Matrix(18, 1, fill = 1)
A:=
29
aa := <1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18>
M:=<<A>|<aa>\<aaa.>\<aaaa>>
M:=
30
y:= `<,>`(1217, 1386, 1431, 1479,
1760, 1930, 2455, 3098, 3409, 3629,
3595, 3301, 2998, 2767, 2045, 1873,
1698, 1552)
y:=
M+
c:=M+M c:=
d:=LinearAlgebra[MatrixInverse](c) d:=
31
f:=M+y
f:=
v := d . f v:=
g := M . v
g:=
32
e := y-g
e:=
evalf(VectorCalculus[Norm](e)) |e|=
33
restart
with(plots)
A := [[1, 1217], [2, 1386], [3, 1431], [4, 1479], [5, A:=
1760], [6, 1930], [7, 2455], [8, 3098], [9, 3409],
[10, 3629], [11, 3595], [12, 3301], [13, 2998], [14,
2767], [15, 2045], [16, 1873], [17, 1698], [18,
1552]]
eqn:= eqn:=
158585/204+(4423651/23256)*x+(14593/646)*x2-
(41785/23256)*x3
34
restart
with(stats[fit]);
eqn:= eqn:=
158585/204+(4423651/23256)*x+(14593/646)
*x2-(41785/23256)*x3
a := 158585/204 a:=
b := 4423651/23256 b:=
c := 14593/646 c:=
d := -41785/23256 d:=
35
with(plots); resid := seq(cases[i]-E[i], i = 1 ..
18)
36