# Linear Algebra Done Right 2nd Edition – Chapter 1 Exercise 9

Chapter 1 Exercise 9.

Prove that the union of two subspaces of V is a subspace of V if and only if one of the subspaces is contained in the other.

$\text{Proof:}\\\\ \text{Given } X \text{ and } Y \text{ are subspaces of } V.\\\\ \text{Let } X \cup Y \text{ be a subspace of } V.\\\\ \text{Suppose } X \not\subseteq Y \text{ and } Y \not\subseteq X. \\\\ \text{Since } X \text{ and } Y \text{ are subspaces, they are non-empty. So, } \exists x \in X \text{ such that x } \not\in Y \text{ and } \exists y \in Y \text{ such that } y \not\in X.\\\\ \text{By definition of union, } x \in X \cup Y \text{ and } y \in X \cup Y.\\\\ \text{Since } X \cup Y \text{ is a subspace, } x + y \in X \cup Y.\\\\ \text{That is, } x + y \in X \text{ or } x + y \in Y \text{ or both}.\\\\ \text{Say } x + y \in X. \text{ Since } X \text{ is a subspace } -x \in X \text{ and } -x + (x + y) \in X.\\\\ \text{Then, by the associative property of subspaces and the definition of additive inverse, }\\ (-x + x) + y \in X \Rightarrow O_V + y \in X \Rightarrow y \in X.\\\\ \text{But } y \not\in X. \text{ We reach a similar contradiction for } x + y \in Y.\\\\ \text{(1) Thus, if } X \cup Y \text{ is a subspace of } V \text{, either } X \subseteq Y \text{ or } Y \subseteq X.$

$\text{Now, let either } X \subseteq Y \text{ or } Y \subseteq X \text{, say }X \subseteq Y\\\\ \text{For every } x_i, x_j \in X \text{ and } y_i, y_j \in Y,\text{ since } X \text{ is a subspace, } \\\\ x_i + x_j \in X \Rightarrow x_i + x_j \in X \cup Y.\text{ Similarly } y_i + y_j \in X \cup Y.\\\\ \text{Since } Y \text{ is a subspace, and by the assumption } x_i \in Y, x_i + y_j \in X \cup Y\\\\ \indent \text{a) Thus, for every } w_i, w_j \in X \cup Y, w_i + w_j \in X \cup Y\\\\ \text{Let } u \in X \cup Y. \text{ Since } X \subseteq Y, u \in Y. \text{ Since } Y \text{ is a subspace, } au \in Y, \forall a \in F.\\\\ \indent \text{b) Thus, } au \in X \cup Y \ \forall a \in F\\\\ \text{Since } X \text{ is a subspace, } O_V \in X.\\\\ \indent \text{c) Thus, } O_V \in X \cup Y\\\\ \text{(2) Thus, by a, b and c, if } X \subseteq Y, \text{ then } X \cup Y \text{ is a subspace of } V$

Therefore, by 1 and 2, the union of two subspaces of V is a subspace of V if and only if one of the subspaces is contained in the other. $\square$

# Linear Algebra Done Right 2nd Edition – Chapter 1 Exercise 8

Chapter 1 Exercise 8.
Prove the intersection of any collection of subspaces of V is a subspace of V .

Proof:
Let $X_1, X_2,...$ be subspaces of $V$.
Then $O_V \in X_q \forall q$. Thus,

(1) $O_V \in X_1 \cap X_2 \cap ...$

Therefore, $X_1 \cap X_2 \cap ... \neq \emptyset$.
Suppose $X_1 \cap X_2 \cap ... = \{ x_1, x_2, ... \}$. Then $x_i, x_j \in X_q \forall i, j, q$.
Since $X_q$ is a subspace, $x_i + x_j \in X_q \forall q$. Thus

(2) $x_i + x_j \in X_1 \cap X_2 \cap ...$

Since $X_q$ is a subspace, $ax_i \in X_q \forall q, i$ and scalar $a$. Thus

(3) $ax_i \in X_1 \cap X_2 \cap ...$

By 1, 2 and 3, $X_1 \cap X_2 \cap ...$ is a subspace of $V$.

$\square$

# Linear Algebra Done Right 2nd Edition – Chapter 1 Exercises 5(b), 5(c), 5(d), 6, 7

Chapter 1

5.(b)Determine if $U = {(x_1,x_2,x_3) \in \textbf{F}^3:x_1 + 2x_2 + 3x_3 = 4}$ is a subspace of $\textbf{F}^3$.

Solution: Since $0 + 0x_2 + 0x_3 \neq 4, (0,0,0) \notin U$. Thus $U$ is not a subspace of $\textbf{F}^3$.

5.(c)Determine if $U = {(x_1,x_2,x_3) \in \textbf{F}^3:x_1x_2x_3 = 0}$ is a subspace of $\textbf{F}^3$.

Solution: Since $x_1x_2x_3 = 0$ at least one of $x_i = 0$. Consider $(0,1,1)$ and $(1,0,1)$. Both are in $U$ but $(0,1,1) + (1,0,1) = (1,1,2) \notin U$. Thus, $U$ is not a subspace of $\textbf{F}^3$.

5.(d)Determine if $U = {(x_1,x_2,x_3) \in \textbf{F}^3:x_1 = 5x_3}$ is a subspace of $\textbf{F}^3$.

Solution:

Clearly $(0,0,0) \in U$.

Consider $(a,b,c)$ and $(x,y,z)$ both in $U$.
Then $(5c,b,c) + (5z,y,z) = (5c+5z, b+y, c+z) = ( 5(c+z), (b+y), (c+z) ) \in U$

Let $(x,y,z) = (5z, y, z) \in U$ and $a \in \textbf{F}$
Then $a(x,y,z) = (a5z, ay, az) = (5az, ay, az) \in U$.

$U$ is a subspace of $\textbf{F}^3$

6. Give an example $U$ of $\mathbb{R}^2$ such that $U$ is closed under addition and under taking additive inverses (meaning $-u \in U$ whenever $u \in U$), but $U$ is not a subspace of $\mathbb{R}^2$.

Solution 1:

Let $U = \{ (x,y) \in \mathbb{R}^2 : x,y \text{ are rational } \}$

$U \neq \emptyset$ since $(0,0) \in U$.

If $(a,b), (c,d) \in U$ then $(a+c, b+d) \in U$ since the sum of rationals is rational. Thus, $U$ is closed under addition.

Also, $-a, -b$ are are rational since $a, b, -1$ are rational and the product of rationals is rational. Then $(-a,-b) \in U$. So $U$ is closed under taking additive inverses.

Now, let $a \in \mathbb{R}, a \text{ is irrational }$. Consider $(1,1) \in U$. Then $a(1,1) = (a,a) \notin U$ since the product of an irrational and a non-zero rational is an irrational. Thus, $U$ is not closed under scalar multiplication.

$U$ is not a subspace of $\mathbb{R}^2$

Solution 2: This is the one in the solution manual.

Let $U = \{ (x,y) \in \mathbb{R}^2 : x,y \in \mathbb{Z} \}$

$U \neq \emptyset$ since $(0,0) \in U$.

Given $(a,b) \in U$ and $(c,d) \in U$ then $a+c \in \mathbb{Z}$ and $b+d \in \mathbb{Z}$ and $(a+c,b+d) \in U$.
Thus, $U$ is closed under addition.

Also, $-a, -b$ are integers since $a, b$ are integers. Then $(-a,-b) \in U$.
So $U$ is closed under taking additive inverses.

Consider $(1,1) \in U$ and $\frac{1}{2} \in \mathbb{R}$.
Then $\frac{1}{2} (1,1) = (\frac{1}{2}, \frac{1}{2}) \notin U$.
Thus, $U$ is not closed under scalar multiplication.

$U$ is not a subspace of $\mathbb{R}^2$

7. Give an example of a nonempty subset $U$ of $\mathbb{R}^2$ such that $U$ is closed under scalar multiplication, but $U$ is not a subspace of $\mathbb{R}^2$.

Solution:

Let $U = \{ (x,y) \in \mathbb{R}^2 : \text{ if } x = 0, y = 0 \text{ otherwise } y \neq 0 \}$

Just for fun, this is a different subset than the one found in the solution manual.

$U \neq \emptyset$ since $(0,0) \in U$.

Let $(x,y) \in U$ and $a \in \mathbb{R}$. If $a = 0$ or $(x,y) = (0,0)$, then $a(x,y) = (0,0)$ otherwise $a(x,y) = (ax, ay) : ay \neq 0$. So $a(x,y) \in U$. Thus, $U$ is closed under scalar multiplication.

Consider $(10, 1)$ and $(-5, -1)$. Both are in $U$. But $(10, 1) + (-5, -1) = (5, 0) \notin U$.

$U$ is not a subspace of $\mathbb{R}^2$.

# HTML5 Dynamic Charts – JavaScript and the Canvas 2D Context

Now that the HTML5 and Canvas 2D specifications are feature complete (December 2012) and most companies have pushed IE9 to their clients, I wanted to take advantage of the canvas element's 2D Context to create dynamic charts - without using Flash, ActiveX, Web Parts, browser add-ins or anything else extraneous to HTML and JavaScript. The first addition to my JavaScript chart library was a pieChart object.

Go right to the full featured demo and download the source from my example site. Or continue reading for a detailed explanation of how I created the chart objects.

To start creating my charts, I'll define the base object from which I'll derive all my chart objects including the pieChart.

<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function chart() { }
chart.prototype = {
canvas: null,
data: null,
colors: null,
currentColor: null,
currentColorIndex: null,
width: null,
height: null,
initChart: function(canvasWidth, canvasHeight, chartData, chartColors) {
this.data = chartData.slice();
this.colors = chartColors.slice();
this.canvas = document.createElement('canvas');
this.canvas.width = canvasWidth;
this.canvas.height = canvasHeight;
this.width = canvasWidth;
this.height = canvasHeight;
},
randomColor: function() {
var r = ('0' + (Math.random() * 256 | 0).toString(16)).slice(-2),
g = ('0' + (Math.random() * 256 | 0).toString(16)).slice(-2),
b = ('0' + (Math.random() * 256 | 0).toString(16)).slice(-2);
return '#' + r + g + b;
},
resetColor: function() { this.currentColorIndex = -1; },
moveToNextColor: function() {
if (!this.colors) {//check for 'null' or 'undefined' color array. if so, use a random color
this.currentColor = this.randomColor();
return this.currentColor;
}
else {
if (this.currentColorIndex == null) {
this.currentColorIndex = 0;
}
else {
this.currentColorIndex = this.currentColorIndex + 1
if ((this.currentColorIndex >= this.colors.length) || (this.currentColorIndex < 0)) { this.currentColorIndex = 0; }
}
this.currentColor = this.colors[this.currentColorIndex];
return this.currentColor;
}
}
}
</script>

Although I don't use jQuery (line 1) in the base chart object, I'll use it later to extend the prototype of each chart object. Lines 13 and 14 initialize the data and color arrays for the chart. Notice the slice() array method. Since passing a JavaScript array object behaves like a "pass by reference", I use slice() to create new arrays with the same values as the parameter arrays. Now I won't accidentally change the originals while I'm manipulating the chart's data or colors.

The pieChart object is defined as follows:

<script type="text/javascript">
function pieChart(chartData, chartDiameter, chartColors) {
this.diameter = chartDiameter;
this.initChart(chartDiameter, chartDiameter, chartData, chartColors);
this.draw();
}
pieChart.prototype = {

draw: function() {

this.resetColor();
this.canvas.width = this.diameter;
this.canvas.height = this.diameter;
var canvas = this.canvas;
var amounts = this.data.slice();

var context = canvas.getContext('2d');
var x = canvas.width / 2;
var y = canvas.height / 2;
var counterClockwise = false;

var percentDenominator = 0;
for (var i = 0; i < amounts.length; i++) { percentDenominator += amounts[i]; }
for (var i = 1; i < amounts.length; i++) { amounts[i] += amounts[i - 1]; }
for (var i = 0; i < amounts.length; i++) { amounts[i] = amounts[i] / percentDenominator * 2 * Math.PI; }

var points = new Array();
points.push([0, amounts[0]]);
for (var i = 1; i < amounts.length; i++) { points.push([amounts[i - 1], amounts[i]]); }

for (var i = 0; i < amounts.length; i++) {
context.lineWidth = 1;
context.beginPath();
context.moveTo(x, y);
context.arc(x, y, radius, points[i][0], points[i][1], false);
context.lineTo(x, y);
context.closePath();
context.fillStyle = this.moveToNextColor();
context.fill();
context.strokeStyle = "#ffffff";
context.stroke();
}
}
}
$.extend(pieChart.prototype, chart.prototype); </script> The idea is to change each data item into a running percentage of the total circumference of the pie (no pun intended - lines 23-26). Then we create a multidimensional array such that the end point of the first arc is the starting point of the next one (lines 28-30). We now draw consecutive arcs along the circle shown in Figure 1. Each arc has a radius that is equal to the radius of the pie chart and a length that is the percentage of the circumference correlating to the value of the input data item. The last line (56) of the script extends the pieChart with the prototype of the base chart object. For example, [10,20,20,50] is transformed to [0.10, 0.30, 0.50, 1.00] and then we create the points array [ [0, 0.10*2Pi], [0.10*2Pi, 0.30*2Pi], [0.30*2Pi, 0.50*2Pi], [0.50*2Pi, 1.00*2Pi ] Here's some sample code to create the chart when the document is ready and a function to call when you need to update it: var myPie = new pieChart([10,20,20,50],200,["#993333","#669966","#FFCC66","#336699"]);$(document).ready(function() {
\$("div#myPieChart").html(myPie.canvas);
});

function updateChart(newData){
myPie.data = newData;
myPie.draw();
}

to Change the chart Data to [120,140,75,90]. Several other properties of the chart object can be set to change the pie chart. For example, setting the color property to an empty string will cause the chart to be drawn using random colors. See a full featured demo and download the source from my examples site. The source download contains bar and line charts in addition to the pie chart. I'm adding new charts all the time, so check back often!

# Linear Algebra Done Right 2nd Edition – Chapter 1 Exercises 2, 3, 4, 5(a)

Chapter 1

2. Show that $\frac{-1 + \sqrt{3}i}{2}$ is a cube root of 1 (meaning that its cube equals 1).

Solution:

$\frac{(-1 + \sqrt{3}i)(-1 + \sqrt{3}i)(-1 + \sqrt{3}i)}{8} =$
$\frac{(1 + (3)(-1) - 2\sqrt{3}i)(-1 + \sqrt{3}i)}{8} =$
$\frac{(-2 + -2\sqrt{3}i)(-1 + \sqrt{3}i)}{8} =$
$\frac{2 -2(3)(-1) + 2\sqrt{3}i - 2\sqrt{3}i)}{8} =$
$\frac{2 + 6}{8} = 1$

3. Prove that $-(-v) = v$ for every $v \in V$.

Solution:

$-(-v) = -1(-v)$ by proposition 1.6
$-1(-v) = -1( (-1) v)$ by proposition 1.6
$-1( (-1) v) = 1v = v$ $\blacksquare$

This is the alternate proof suggested in the solutions manual.

4. Prove that if $a \in F, v \in V$ and $av = 0$, then $a = 0$ or $v = 0$.

Solution:

$\text{Suppose } a \ne 0$
$av = 0 = a0$ by proposition 1.5
$av - a0 = 0$
$a(v - 0) = 0$
$(v - 0) = 0 \text{ since } a \ne 0$
$v = 0$

Now let $a = 0$, then done. $\blacksquare$

Check: The solution manual provides a different proof
$\frac{1}{a}(av) = \frac{1}{a}0 \text{ since } a \ne 0$
$1v = 0$
$v = 0$

5.(a) Determine if ${(x_1,x_2,x_3) \in \textbf{F}^3:x_1 + 2x_2 + 3x_3 = 0}$ is a subspace of $\textbf{F}^3$.

Solution:

Let $U = {(x_1,x_2,x_3) \in \textbf{F}^3:x_1 + 2x_2 + 3x_3 = 0}$

$0 + 20 + 30 = 0 \Rightarrow (0,0,0) \in U$
Additive identity in $U$.

Let $(a,b,c) \in U$ and $(p,q,r) \in U$
Then
$a + 2b + 3c = 0$ and
$p + 2q + 3r = 0$
$\Rightarrow$
$(a,b,c) + (p,q,r) =$
$a + p + 2b + 2q + 3c + 3r =$
$(a + 2b + 3c) + (p + 2q + 3r) = 0$
$\Rightarrow (a,b,c) + (p,q,r) \in U$

Let $a \in \textbf{F}$ and $(p,q,r) \in U$
Then
$a(p,q,r) = a(p + 2q + 3r) = 0$
$\Rightarrow$
$ap + a2q + a3r = 0$
$\Rightarrow$
$(ap, aq, ar) \in U$
$\Rightarrow$
$a(p, q, r) \in U$
Closed under scalar multiplication.

# Linear Algebra Done Right 2nd Edition – Solutions to Selected Problems

Today, I’m starting a series of posts on my solutions to selected problems in the popular mathematics text Linear Algebra Done Right by Sheldon Axler. This is the second time I have worked through the exercises. The first time, I was in grad school and really enjoyed how this book concentrates on the math instead of the simple mechanics of linear algebra. In fact, it was of such interest that I took one of my qualifiers on linear algebra. Some of the first exercises are deceptively simple, but challenges come quickly.

I’ve always been somewhat hesitant to post solutions to problems from well know textbooks. However, solutions for this book are readily available and examples like these must be understood to be of use to the student. Simply copying the solutions won’t make the grade. In addition, my solutions may not be correct. Please use them at your own risk. Hopefully, I will remember to notate on each post whether or not the particular solution was validated by one of my professors, peers or Mr. Axler’s solution manual.

Let’s get started…

Chapter 1

1. Suppose $a$ and $b$ are real number, not both $0$. Find real numbers $c$ and $d$ such that

$1/(a+bi) = c+di$

Solution:

$1 = (a+bi)(c+di) = (ac+bd) + (ad+bc)i$

$\Rightarrow$

 $ca-db=1$ $cb+da=0$ $\Rightarrow$ $-bca + bdb = -b$ $acb+ada = 0$ $\Rightarrow$ $0 + (b^2+a^2)d = -b$ $\Rightarrow$ $d=\frac{-b}{(b^2+a^2)}$ $ca-db=1$ $cb+da=0$ $\Rightarrow$ $aca-adb=a$ $bcb+bda=0$ $\Rightarrow$ $(a^2+b^2)c = a$ $\Rightarrow$ $c=\frac{a}{(a^2+b^2)}$

Check:

$\frac{a}{(a^2+b^2)} + \frac{-b}{(b^2+a^2)}i = \frac{a-bi}{(a^2+b^2)}$

and

$= \frac{1}{(a+bi)} = \frac{a-bi}{(a-bi)} \frac{1}{(a+bi)}$
$= \frac{a-bi}{(a-bi)(a+bi)} = \frac{a-bi}{[aa-(-b)(b)]+[ab+(-ba)]} = \frac{a-bi}{(a^2+b^2)}$

# LaTeX in WordPress

A proof of the irrationality of $\sqrt{2}$ just to try $\LaTeX$ in WordPress

Assume $\sqrt{2}$ is rational.

Then $\exists a$ and $b$ such that $\sqrt{2} = \frac{a}{b}$
where $a$ and $b$ are integers and $\frac{a}{b}$ is in lowest terms.

$\Rightarrow 2b^2 = a^2$

$\Rightarrow a^2$ is even

$\Rightarrow a$ is even

$\Rightarrow a$ is divisible by $2$

$\Rightarrow \exists k$ such that $a = 2k$

substitute $2k$ for $a$ in the assumption to get
$\sqrt{2} = \frac{2k}{b}$

$\Rightarrow 2 = \frac{(2k)^2}{b^2} = \frac{4k^2}{b^2}$

$\Rightarrow 2k^2 = b^2$

$\Rightarrow b$ is even, similarly.

$\Rightarrow \frac{a}{b}$ is not in lowest terms. $\blacksquare$