3.0. A COLLECTION OF NUMBERS AS A MATHEMATICAL OBJECT
Exercise 1: Pick three other applications and propose natural groupings of numbers for those
applications.
i. Group of whole numbers e.g.{0,1,2,3,4,5,6,7,8,9} are applicable in of coordinates axes
for graphical representation.
ii. Group of rational number for instance { 31,
32,
74
} are applicable in precise proration
concerning probability and statistics.
iii. Group o or set {0,1} is natural grouping and its application is in computational
Mathematical analysis appertaining to group of numbers leads us to will check into Set
theory
Definition: a set is a group or collection of distinct elements. Set’s are represented by capital
letters and are bracketed with curly brackets. Example D= {a, f, m, o, e, r, f} and N= {4, 9, 16,
25, 36}, Set D and N is a set of distinct letters and number respectively. Numbers can be group
or collected according to specific property, for instance this is a set {1, 4, 9, 16} is of numbers
related because they are perfect squares.
Function of sets is used in algebraic analysis especially in analytical operation of grouping of
various elements in categories that appertain to a certain property.
Below are illustration of binary operation of union denoted by “ ” and operation of intersection
denoted by “ ”
a) Operation of union denoted by “ ”.Definition: Union operation of sets is collection or
grouping of all elements contained either set or in both concerning sets and avoiding double
listing of coexisting elements or repetitive existence of an element or elements in the
concerning sets.
Example
Set Z= {k, h, e, f, m} and another set X={c, y. f. m, r, s}.
Union of Z and X that is },,,,,,,,{srycmfehkXZ note that f and m are listed once
b) Operation of Intersection denoted by
Definition: intersection of two sets contains only elements in both sets in our case only
elements in set Z and X
Example:
Set Z= {k, h, e, f, m} and another set X={c, y. f. m, r, s}.Intersection of Z and X that is
},{mfXZ
Two Sets can be added even with aid of tuple which is systematic additional of elements in sets
according to order of arrangement.
Exercise 2
i. Go back to the example with two coordinate systems, and verify by hand that addition
produces the same result.
In coordinate system addition of sets that is a coordinates containing elements of x axis and y
axis produces same result meaning the result has same tuple as the constituents added because
tuple being the number of elements is a set. In addition of two points as tuples like (4, 3) + (5,
7) = (9, 10).We illustrate this by first considering 1 dimension and additional operation is on
number line. First on x axis point (4, 0) is moved to point (5, 0) which is then moved to point
(9, 0). And on still1D dimension on y axis point (0, 3) is moved to point (0, 7) which is the
moved to point (0.10). Verification by hand from point (4, 3) to point (9, 10) move 5 units by
hand from 4 and get 9 on x-axis and move 7 units from3 by hand and get 10 thus the resulting
coordinate (9, 10) has x coordinate and y coordinate and this has same tuple as in point (4, 3)
and point (5, 7).The result (9, 10) is same as the previous one.
ii. How would you prove that addition produces the same result regardless of coordinate
system?
This is proven with aid moving vectors. Vector heading to (4, 3) from 0 and vector from 0
heading to (5, 7) when added give results (9, 10) this operation is illustrated as
10
9
7
5
3
4
This is the mathematical legitimate additional operation of vectors.
iii. By the rules above, we aren't allowed to change the orientation of an arrow when it's
moved for addition. Why is that? What would go wrong with the theory if we allowed
the direction to change?
Changing orientation of the moving arrow or vector for purpose of additions is not
allowed because the arrow drawn between (5, 7) and (9, 10) doesn’t exist as a tuple and if
orientation is changed it will not give correct result
3.1 Vectors-
a. Exercise 3: Why is it true that the orientation (angle), except for flips, is unchanged
by scalar multiplication?
Generally orientation of the vector is unchanged my scalar multiplication, in additional.
There is special vector0= {0, 0, 0} which is 0 additive. Orientation (angle) of flip changes
by negative scalar multiplication stretch and Negative scalar multiplication stretch
negate the values of coordinates and the direction linearly shifts to negative quadrant of
the Cartesian plane thus orientation is changed. Flips direction is likely to be an
orientation (angle) of 180 0 (angles on a straight line).
3.2 Linear Combination
4: Exercise:
Download LinCombExample.java and DrawTool.java. Then, examine the code
in LinCombExample to see how vectors and arrows are drawn. Then, draw the
remaining arrows to complete the parallelogram.
OEFG is the parallelogram
/ Instructions:
// 1. Read the code in main() to understand how DrawTool is used.
// 2. Compile and execute to see.
// 3. Draw the remaining arrows to complete the parallelogram.
public class LinCombExample {
public static void main (String[] argv)
{DrawTool.display ();
DrawTool.setXYRange (-10,10, -10,10);
DrawTool.drawMiddleAxes (true);
double[] u = {6,4};
double[] v = {1.5,6};
double[] z = {7.5,10};
DrawTool.drawVector (u);
DrawTool.drawVector (v);
// Alternatively: DrawTool.drawArrow (0,0, 6,4);
DrawTool.setArrowColor ("blue");
DrawTool.drawVector (z);
// INSERT YOUR CODE HERE: (Use DrawTool.drawArrow())
class DrawObject {
double x,y; // For Points, one end of lines,
// and top-left of ovals/rectangles.
double x2,y2; // For the other end of lines, arrows.
double width,height; // Forrectangles.
double a, b, c; // For the line ax+by+c=0
BasicStroke drawStroke = new BasicStroke (1.0f);}
// What we draw: points, lines, \\rectangle.
static java.util.List<DrawObject>lines, rectangles,
// Animated versions: these will clear between successive frames.
static java.util.List<DrawObject> animPoints, animLines, animOvals,
animRectangles, animLabels;
static double minX=0, maxX=10, minY=0, maxY=10; // Bounds.
static int numIntervals = 10; // # tick marks.
static int pointDiameter =7.5; // Size of dot.
// GUI stuff.
static JPanel drawArea = new DrawTool ();
static Dimension D; // Size of drawing area.
static int inset=60; // Inset of axes and bounding box.
// Static initializer.
static{rectangles = Collections.synchronizedList (new
ArrayList<DrawObject>());
public static void drawLine (double x1, double y1, double x2, double y2)
{drawLine (x1, y1, x2, y2, false)}
public static void drawArrow (double x1, double y1, double x2, double y2)
{drawLine (x1, y1, x2, y2, true);}
public static void drawVector (double x, double y)
{drawLine (0, 0, x, y, true);public static void drawVector (double[] x)
{drawVector (x[0], x[1]);}
public static void drawLineFromEquation (double a, double b, double c)
{// Draw the equation ax+by+c=0 in the available range.
DrawObject L = new DrawObject ();
L.color = lineEqnColor;
L.a = a; L.b = b; L.c = c;
L.sequenceNum = currentSequenceNum;
L.drawStroke = drawStroke;
synchronized(eqnLines) { eqnLines.add (L); }
drawArea.repaint ();}
public static void drawLin
public static void drawRectangle (double x1, double y1, double width, double
height)
{
DrawObject R = new DrawObject ();
R.color = rectangleColor;
R.x = x1; R.y = y1; R.width = width; R.height = height;
R.sequenceNum = currentSequenceNum;
R.drawStroke = drawStroke;
if (animationMode) {synchronized(animRectangles) { animRectangles.add
(R); }}else {synchronized(rectangles) { rectangles.add (R); }drawArea.repaint
();} public static void drawImage (int[][][] pixels, int startX, int startY)
{} );}cPane.add (drawArea, BorderLayout.CENTER);drawArea.addMouseListener
(new MouseAdapter(){public void mouseClicked (MouseEvent
e){handleMouseClick(e);
}
public void mouseReleased (MouseEvent e){handleMouseReleased (e);}});
void drawOvalOrRectangle (Graphics g, DrawObject R, boolean isRect)
{if (R == null) {return;}
if ((sequencingOn) && (R.sequenceNum!=currentSequenceNumDisplay)) {
return;}
Graphics2D g2 = (Graphics2D) g;
g2.setStroke (R.drawStroke);
int x1 = (int) ( (R.x-minX)/(maxX-minX) * (D.width-2*inset) );
int y1 = (int) ((R.y-minY) / (maxY-minY) * (D.height-2.0*inset) );
double x = R.x + R.width;
double y = R.y – R.height;
int x2 = (int) ( (x-minX)/(maxX-minX) * (D.width-2*inset) );
int y2 = (int) ((y-minY) / (maxY-minY) * (D.height-2.0*inset) );
if (isRect) {
g.drawRect (inset+x1, D.height-y1-inset, x2-x1, y1-y2);}else {
g.drawOval (inset+x1, D.height-y1-inset, x2-x1, y1-y2);}}
// Remove this line to leave arrow head unpainted:
g2d.fillPolygon(tmpPoly);}
private int yCor (int len, double dir) {return (int)(len * Math.cos(dir));}
private int xCor (int len, double dir)
{return (int)(len * Math.sin(dir));}
void drawImage (Graphics g, DrawObject I){
// Instructions:
// Compile and execute.
import java.util.*;
public class LinCombExample {
public static void main (String[] argv)
{Function G = new Function ("g(x) vs x");for (double x=0; x<=6.283; x+=0.1) {
G.add (x, g(x));}
// Draw the curve.
G.show ();}
static double g (double x)
{// Array of coefficients (scalars in the linear combination).
double[] alpha = {0, 1.0, 0, -0.16666666666666666};
// Here, f_1(x) = x, f_2(x) = 0, f_3(x) = x^3.
double g = alpha[1] * x + alpha[3] * Math.pow(x,3) ;
return g;}}
Exercise 5: Download LinCombExample2.java (you already have DrawTool). Write
code to implement vector addition and scalar multiplication, and test with the example
in main().
// Instructions:
// 1. Write code to implement vector addition and scalar multiplication
// 2. Then compile and execute.
public class LinCombExample2 {
public static void main (String[] argv) {
DrawTool.display ();
DrawTool.setXYRange (-12,12, -12,12);
DrawTool.drawMiddleAxes (true);
double[] u = {6,4};
double[] v = {1.5,6};
double alpha = 1.5, beta = 2;
double[] z = add (scalarMult(alpha, u), scalarMult(beta,v));
DrawTool.setArrowColor ("blue");
DrawTool.drawVector (z);}
static double[] add (double[] u, double[] v)
{/ INSERT YOUR CODE HERE}
static double[] scalarMult (double alpha, double[] v)
{// INSERT YOUR CODE HERE}}
Exercise 6: Download LinCombExample3.java. The double-for loop tries to systematically
search over possible values of α,β to see if some combination will work. Write code to see if
the linear combination αu+βv is approximately equal to z
// Instructions:
// Try values of n=3, n=5, n=7, n=13 in the function g().
// Do the same after changing the intervalEnd to Math.PI.
import java.util.*;public class LinCombExample3 {
public static void main (String[] argv){double totalError = 0;
double deltaX = 0.1;
double intervalEnd = 2*Math.PI;
for (double x=0; x<=intervalEnd; x+=deltaX) {
double errorAtX = Math.abs (g(x) – Math.sin(x));
totalError += errorAtX * deltaX;}
System.out.println ("Total error: " + totalError);}
static double g (double x)
{// Array of coefficients (scalars in the linear combination).
double[] alpha = {0, 1.5, 0, -0.1819178256658966614, 0, 0.007545573338983125,
0, -1.847412689841269839E-6, 0, 2.6857319228185884E-4, 0, –
1.69871083854125764E-8, 0, 2.69822585583682161E-10};
// How many terms to include: Start with n=1.5, then change to n=7.5,
// n=6, then n=10.
int n = 4;
double g = 0;
for (int k=0; k<=n; k++) {g = g + alpha[k] * Math.pow (x, k);}
return g;}}
Exercise 7: Solve the above problem by hand: are there values of α,β such
that αu+βv=z when u=(1,4), v=(3,2) and z=(7.5,10)?
Solution
10
5.7
2
3
4
1
1
4
1024
5.731
2
20100
1024
30124
5.1
64
1044
10224
It’s confirmed there are values for the said scalars
Exercise 8: Suppose u= (1, 2), v=(3,6) and z=(7.5,10).
Download LinCombExample4.java and draw all three vectors. Then: Use the drawing to
explain why no linear combination of u and v will work.
Solve by hand to confirm the explanation algebraically.
Public static void main (String[] argv)
{DrawTool.display ();
DrawTool.setXYRange (-12,12, -12,12);
DrawTool.drawMiddleAxes (true);
double[] u = {1, 2};
double[] v = {6, 4};
double[] z = {7.5,10};
// INSERT YOUR CODE HERE.}}
The linear combination of vectors u and v gives a vector. Vector (1.5, 6) achieved from
stretching (1,) by scalar 1.5 and (6, 4) is achieved from stretching (3,2) by multiplying by scalar
2 and that is 2(3,2).This linear combination work since the result is a vector
Exercise 9: Now consider u=(1,2),v=(3,6) and z=(4,8). Write code
in LinCombExample5.java to draw these. Is there a unique solution? Explain both
geometrically and algebraically.
public class LinCombExample5 {public static void main (String[] argv) {
DrawTool.display ();
DrawTool.setXYRange (-10,10, -10,10);
DrawTool.drawMiddleAxes (true);
double[] u = {1, 2};
double[] v = {3, 6};
double[] z = {4,8};
DrawTool.setArrowColor ("blue");
// INSERT YOUR CODE HERE.}}
Exercise 10: Finally, consider u=(1,4),v=(3,2),w=(−1,1) and z=(7.5,10). We will ask whether
there is a linear combination αu+βv+γw such that αu+βv+γw=z. Write out the equations
and explain algebraically whether there is a solution. The code
in LinCombExample6.java draws all four vectors. Can a linear combination of any two
of u,v,w suffice to produce z?
public class LinCombExample6 {
public static void main (String[] argv){
DrawTool.display ();
DrawTool.setXYRange (-10,10, -10,10);
DrawTool.drawMiddleAxes (true);
double[] u = {1, 4};
double[] v = {3, 2};
double[] w = {-1, 1};
double[] z = {7.5, 10};
// INSERT YOUR CODE HERE.
DrawTool.setArrowColor ("blue");
DrawTool.drawVector (u);
DrawTool.drawVector (v);
DrawTool.drawVector (w);
DrawTool.setArrowColor ("green");
DrawTool.drawVector (z);}}
A linear combination of any two of u,v,w suffice to produce z?.Yes linear combination of u and
v when stretched by a given scalar suffice to produce z
Exercise 11: The code in LinComb3DExample.java displays the vectors in the above
example. (You need to have the Draw3D jar in your CLASSPATH). Write down the
equations for α,β,γ and solve by hand
public class LinCombExample6 {
public static void main (String[] argv){
DrawTool.display ();
DrawTool.setXYRange (-10,10, -10,10);
DrawTool.drawMiddleAxes (true);
double[] u = {1, 4};
double[] v = {3, 2};
double[] w = {-1, 1};
double[] z = {7.5, 10};
// INSERT YOUR CODE HERE.
DrawTool.setArrowColor ("blue");
DrawTool.drawVector (u);
DrawTool.drawVector (v);
DrawTool.drawVector (w);
DrawTool.setArrowColor ("green");
DrawTool.drawVector (z);}}
Solve α(1,3,1)+β(4,1,0)+γ(3,2,6)=(1,7,8)
Solution
1
44
1342
2
68
816
1
183183
18717611
4711
1716
241803
7213
4711
723
39123
8601
2
3
723
134
8
7
1
6
2
3
0
1
4
1
3
1
nsubtractio
Exercise 12: Add code to LinComb3DExample2.java to display the 3D version of the 2D
parallelogram. That is, draw arrows that show the stretched vectors when scaling
by α,β,γ respectively. Then draw arrows from the tips of the stretched vectors to the resultant
vector z.
import org.edisonwj.draw3d.*;
import javafx.application.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.stage.*;
public class LinComb3DExample2 extends Application {
String title = "Vector example";
void drawingCommands () {
// Type all drawing commands in here.
// The three vectors u,v,w:
d3.setDrawColor (Color.BLUE);
d3.drawVector (1,3,1);
d3.drawVector (4,1,0);
d3.drawVector (3,2,6);
// Example of using drawArrow(). The vector z:
d3.setDrawColor (Color.BLACK);
d3.drawArrow (0,0,0, 1,7,8);
// Stretched vectors:
// Use drawArrow to draw the added stretch.
d3.setDrawColor (Color.GREEN);
// Write here …
// Use drawArrow to draw arrows from the tips of
// the stretched vectors to the final vector z=(1,7,8).
d3.setDrawColor (Color.RED);
// Write here …}
// No need to read further
//////////////////////////////////////////////////////////
Draw3D d3;
void preambleCommands (){
d3.setAmbientLight(false);
d3.setPointLight(true);
d3.setCumulate(false);
d3.setSequencingOn();
d3.setVectorRadius(1);
d3.setArrowRadius(1);}
public void start (Stage primaryStage) {
d3 = new Draw3D ();
Scene scene = d3.buildScene ();
preambleCommands ();
drawingCommands ();
d3.setStart ();
primaryStage.setScene (scene);
primaryStage.setTitle (title);
primaryStage.show (); }
public static void main (String[] argv){
launch (argv);}}
Arrows showing stretch vectors scales by and,
Exercise 13: Suppose now that u=(1,3,1),v=(4,1,0),w=(9,5,1) and z=(1,7,9). We seek α, β,
γ such that αu+βv + γw=z. Write down the equations for α,β,γ and solve by hand. The code
in LinComb3DExample3.java displays the four vectors. Explain geometrically why this is
consistent with your solution.
Geometrically the resultant values of scalars consistent with four vectors since they are scale by
the scalar to get the final values
0,0,9
4404422
84422
202
2733
753
42211
753
327123
9
753
1943
9
7
1
1
5
9
0
1
4
1
3
1
3.5 The matrix vector equation
Exercise 14: Apply the matrix A= [a11a12a21a22] to the vector x=[x1x2].
What are the dimensions of the resulting product?
2
1
222121
212111
2
1
2221
1211
c
c
xaxa
xaxa
x
x
aa
aa
The resulting product has got two dimensions (2D)
Exercise 15: Apply the matrix A= [2−301] to the vector x= [23] to get the
vector y. Then apply B= [120−3] to y to get z. What are y and z? Show your
calculations
9
1
,
3
5
9
1
3
5
30
21
3
5
3
2
10
32
10
32
3012
zy
ZyB
y
A
Exercise 16: Download MatrixVectorExample.java and write code to perform the matrix-vector
product. Then confirm your calculations above from the displayed vectors
Multiplication: (u1,u2,…,un)⋅(v1,v2,…,vn)=u1v1+u2v2+…+u n v n
(u1,u2,…,un)+(v1,v2,…,vn)=(u1+v1,u2+v2,…,un+vn)
Example: (1,2,0,3)+(-,5,6)=(1×-5,0×-5+,2×-5+3×6)=(-1,9)
Multiplication: (u 1 , u 2 ,…, un)⋅(v1,v2,…,vn)=u1v1+u2v2+…+unv=
n
i
iivu
1
Exercise 17: Compute the vector obtained by multiplying x above by the
matrix C= [2−10−3]. Compare with the value of z calculated earlier
9
1
3
2
30
12
30
12
3012
xC
CC
This value is same as the value of z and all of them are similar because they are column matrix
Exercise 18: Compute the vector obtained by multiplying z above by the matrix C2=
[1.0/2−1.0/60−1.0/3]. Compare with the value of x calculated earlier.
3494.7
15.0
9
1
3333.0
0167.0
5.0
3333.01670.05.03/0.160/0.12/0.12C
The values of product achieved are in column same as the values of x which is also in column
matrix.
Exercise 19: Earlier, you computed the product of A=[a11a12a21a22] with the vector x=[x1x2],
which produces a result vector. Multiply this result vector by B=[b11b12b21b22]. (The result is
admittedly not pretty.)
222121
2121111
2221
1211
222121
212111
2cbcb
cbcb
c
c
bb
bb
xaxa
xaxa
It true the result is long expression and complex and admittedly not pretty
3.6 Matrix-Matrix Multiplication
Exercise 20: Download MatrixVectorExample2.java and write matrix multiplication code to
make the example work. Confirm that you obtained the same matrix in Exercise 17, and the same
resulting vector.
(U 1 , U 2 ,,,,,,,,,,,,,,,U n )+(V 1 ,V 2 ,…,V n ))=(U 1 +V 1 ,U 2 +V 2 ,…,U n +V n )
Example: (1,2,3)+(4,5,6)=(1+4,2+5,3+6)=(5,7,9)
Multiplication: (U 1 ,U 2 ,…,U n )⋅(V 1 ,V 2 ,…,V n )=U 1 V 1 +U 2 V 2 +…+U n V n = n∑U i V i
The result is a single number.
Example: (1, 2, 3) ⋅ (3, 5, 6) =1×3+1×5+3×5=4+10+17=28
Exercise 21: Consider the matrices
A= [321−235003] and B=[−4101013−21]Let x=(1,−1,2) and
define y=Ax and z=By. Calculate each of y,z and the matrix product C=BA. Confirm
by calculating Cx.
7
9
7
2
1
1
10013
423
1514
10013
423
1514
300
532
123
123
101
014
12106
12106
18159
653
123
101
014
653
2
1
1
300
532
123
CxConfirm
BAC
ByZ
Axy
Exercise 22: Download MatrixVector3DExample.java, then fill in the code (from previous
exercises) to perform matrix multiplication and matrix-vector multiplication. Confirm that the
results match the calculations in the previous exercise.
(U 1 , U 2 ,…,U n )+(V 1 ,V 2 ,…,V n )=(U 1 +V 1 ,U 2 +V 2 ,…,U n +V n )
Example: (1,2,3)+(4,5,6)=(1+4,2+5,3+6)=(5,7,9)
Multiplication: (u1,u2,…,un)⋅(v1,v2,…,vn)=u1v1+u2v2+…+unvn=n∑i=1uivi
The result is a single number.
Exercise 23: Suppose A and B are two n×n matrices. Prove or disprove: AB=BA
10013
423
1514
369
81226
317
BAAB
I disapprove that AB is not equal to BA
3.7 Non-Square Matrices
Exercise 24: What is the result of
multiplying A=[010−120] and B=[11220−3]? What is Ax when x=(2,3,4)?
4
3
4
3
2
021
010
33
22
3
2
1
0
2
1
021
010
Ax
3.8 A review of three cases involving equations
Parallelogram edge that is parallel to the (1, 4) line in intersect with line lie on (3,2) which is
possible stretch and where they intersect is a unique point .
References
1. Stuart, J. (1988). Inflation Matrices and ZME-Matrices that Commute with a Permutation
Matrix. SIAM Journal on Matrix Analysis and Applications, 9(3), 408-418. doi:
10.1137/0609036.
2. Cambridge Univ Pr. (2016). Matices Intermediate + Eleteca.
3. Zhang, S., & Holzapfel, W. Orthogonal polarization in lasers.