## Kitchen renovation progress.

February 1, 2020 Uncategorized 2 comments ,

We are making good progress on the kitchen renovation (a _lot_ of it over the last couple days).  Here’s a couple weeks ago with the cabinets and backspash removed

then Friday with some of the tile removed:

yesterday, with the tiles, subfloor and unsavable drywall removed

and finally today, after piles of back breaking work and bruises and scratches (removing old tile is not easy!), we’ve got things cleaned up

The wall that had been butchered by the first owners of the house is rebuilt, ready for new drywall on both sides (no more microwave cavity in the stairwell.)

We’ll have to take out the electrical outlet in the stairwell, and fix up the stairwell sconce, which had been “installed” without a standard octagon box.

I was glad to see that the kitchen outlets were all run properly, so we don’t have to cut into the subfloor to run new lines back to the panel.

Next steps:

• choose and order tile, and underlay material
• rough in plumbing
• drywall and flooring installation
• priming
• cabinet and appliance installation
• trimwork and finishing.

## Lines and planes in geometric algebra.

January 30, 2020 Uncategorized No comments

## Motivation.

I have way too many Dover books on mathematics, including [1], which is a nice little book, covering all basics, plus some higher level material like gamma functions, Fourier series, and Laplace transforms. I’d borrowed this book from the Toronto Public Library in my youth. I’ve been meaning to re-read it, and bought my own copy to do so (too long ago.)

Perusing the chapter on vectors, I saw his treatment of lines, specifically the distance from a point to a line, and realized I’d left that elementary geometry topics out of my book.

Let’s tackle this and the similar distance from a plane problem here.

## Distance from a line.

Given a point $$\Bx$$ on a line, and a direction vector $$\Bu$$ for the line, we can parameterize all points $$\By$$ on the line by
\label{eqn:lineAndPlane:20}
\By(t) = \Bx + a \Bu.

In particular, the vector $$\Bx – \By$$ is directed along the line if
\label{eqn:lineAndPlane:40}
\lr{ \Bx – \By } \wedge \Bu = 0.

While \ref{eqn:lineAndPlane:40} holds in $$\mathbb{R}^2$$ (and in fact $$\mathbb{R}^N$$), this relationship is usually written in the $$\mathbb{R}^3$$ specific dual form
\label{eqn:lineAndPlane:60}
\lr{ \Bx – \By } \cross \Bu = 0.

Given a vector $$\Bs$$, representing a point, not necessarily on the line, we can compute the (shortest) distance from that point to the line.

Fig 1. Distance to line.

Referring to fig. 1, it’s clear that we want this distance is just the rejection of $$\Bu$$ from $$\Bd = \Bx – \Bs$$. We can decompose $$\Bd$$ into components parallel and perpendicular to $$\Bu$$ using the usual trick
\label{eqn:lineAndPlane:260}
\begin{aligned}
\Bd
&= \Bd \Bu \inv{\Bu} \\
&=
\lr{ \Bd \cdot \Bu }
\inv{\Bu}
+
\lr{ \Bd \wedge \Bu }
\inv{\Bu},
\end{aligned}

where the first component is the projection along $$\Bu$$, and the last is the rejection. This means that the
directed distance to the line from the point $$\Bs$$ is
\label{eqn:lineAndPlane:80}
\BD = \lr{\lr{\Bx – \Bs} \wedge \Bu } \inv{\Bu}.

Should we want the conventional cross product formulation of this vector, this product may be expanded within a no-op grade-1 selection, applying the duality relation ($$\Bx \wedge \By = I \lr{ \Bx \cross \By }$$) twice
\label{eqn:lineAndPlane:100}
\begin{aligned}
\Bd \wedge \Bu \inv{\Bu}
&=
\Bd \wedge \Bu \frac{\Bu}{\Bu^2}
} \\
&=
\inv{\Bu^2}
I (\Bd \cross \Bu) \Bu
} \\
&=
\inv{\Bu^2}
I (\Bd \cross \Bu) \cdot \Bu
+
I (\Bd \cross \Bu) \wedge \Bu
} \\
&=
\inv{\Bu^2}
I^2 (\Bd \cross \Bu) \cross \Bu
} \\
&=
\frac{\Bu \cross (\Bd \cross \Bu)}{\Bu^2}.
\end{aligned}

## Distance from a plane.

Given two linearly independent vectors $$\Ba, \Bb$$ that span a plane, and a point $$\Bx$$ in the plane, the points in that plane are parameterized by
\label{eqn:lineAndPlane:140}
\By(s,t) = \Bx + s \Ba + t \Bb.

We can form a trivector equation of a plane by wedging both sides, first with $$\Ba$$ and then with $$\Bb$$, yielding
\label{eqn:lineAndPlane:160}
\lr{ \Bx – \By } \wedge \Ba \wedge \Bb = 0.

This equation is satisfied by all points $$\Bx, \By$$ that lie in the plane

We are used to seeing the equation of a plane in dot product form, utilizing a normal. That $$\mathbb{R}^3$$ representation can be recovered utilizing a dual transformation. We introduce a bivector (2-blade) representation of the plane itself
\label{eqn:lineAndPlane:180}
B = \Ba \wedge \Bb,

and then let
\label{eqn:lineAndPlane:200}
B = I \Bn.

With such a substitution, \ref{eqn:lineAndPlane:160} can be transformed
\label{eqn:lineAndPlane:220}
\begin{aligned}
0
&= \lr{ \Bx – \By } \wedge B \\
\lr{ \Bx – \By } B
} \\
\lr{ \Bx – \By } I \Bn
} \\
I \lr{ \Bx – \By } \cdot \Bn
+
I \lr{ \Bx – \By } \wedge \Bn
} \\
&=
I \lr{ \Bx – \By } \cdot \Bn,
\end{aligned}

where the last wedge product could be discarded since it contributes only a vector grade object after multiplication with $$I$$, and that is filtered out by the grade three selection. Multiplication of both sides with $$-I$$ yields
\label{eqn:lineAndPlane:240}
\lr{ \Bx – \By } \cdot \Bn = 0,

the conventional form of the equation of an $$\mathbb{R}^3$$ plane.
If we want a more general representation, then we are better off using the wedge product form of this equation
\label{eqn:lineAndPlane:280}
\lr{ \Bx – \By } \wedge B = 0,

where we use \ref{eqn:lineAndPlane:180} to drop the references to the original spanning vectors $$\Ba, \Bb$$. As with rotations, in geometric algebra, it is more natural to encode the orientation of the plane with a bivector, than to use a spanning pair of vectors in the plane, or the normal to the plane.

For the question of shortest distance from a point to our plane, we want to compute the component of $$\Bd = \Bx – \Bs$$ that lies in the plane represented by $$B$$, and the component perpendicular to that plane. We do so using the same method as above for the line distance problem, writing
\label{eqn:lineAndPlane:300}
\begin{aligned}
\Bd
&= \Bd B \inv{B} \\
&=
\lr{ \Bd \cdot B } \inv{B}
+
\lr{ \Bd \wedge B } \inv{B}.
\end{aligned}

It turns out that these are both vector grade objects (i.e. there are no non-vector grades that cancel perfectly). The first term is the projection of $$\Bd$$ onto the plane $$B$$ whereas the second term is the rejection. Let’s do a few things here to get comfortable with these components. First, let’s verify that they are perpendicular by computing their dot product
\label{eqn:lineAndPlane:320}
\begin{aligned}
\lr{ \lr{ \Bd \cdot B } \inv{B} }
\cdot
\lr{ \lr{ \Bd \wedge B } \inv{B} }
&=
\lr{ \Bd \cdot B } \inv{B}
\lr{ \Bd \wedge B } \inv{B}
} \\
&=
\inv{B^4}
\lr{ \Bd \cdot B } B
\lr{ \Bd \wedge B } B
} \\
&\propto
\lr{ \Bd \cdot B } B^2
\lr{ \Bd \wedge B }
} \\
&\propto
\lr{ \Bd \cdot B }
\lr{ \Bd \wedge B }
} \\
&=
0,
\end{aligned}

where we first used $$B^{-1} = B/B^2$$, then $$\lr{ \Bd \wedge B } B = \pm B \lr{ \Bd \wedge B }$$ (for $$\mathbb{R}^3$$ $$B$$ commutes with the wedge $$\Bd \wedge B$$ is a pseudoscalar, but may anticommute in other dimensions). Finally, within the scalar selection operator we are left with the products of grade-1 and grade-3 objects, which can have only grade 2 or grade 4 components, so the scalar selection is zero.

To confirm the guess that $$\lr{ \Bd \cdot B } \inv{B}$$ lies in the plane, we can expand this object in terms of the spanning vector pair $$\Ba, \Bb$$ to find
\label{eqn:lineAndPlane:340}
\begin{aligned}
\lr{ \Bd \cdot B } \inv{B}
&=
\lr{ \Bd \cdot \lr{ \Ba \wedge \Bb} } \inv{B} \\
&=
\lr{
(\Bd \cdot \Ba) \Bb

(\Bd \cdot \Bb) \Ba
} \inv{B} \\
&\propto
\lr{
u \Ba + v \Bb
}
\cdot \lr{ \Ba \wedge \Bb} \\
&\in \setlr{ \Ba, \Bb }
\end{aligned}

Similarly, if $$\lr{ \Bd \cdot B } \inv{B}$$ has any component in the plane, dotting with $$B$$ should be non-zero, but we have
\label{eqn:lineAndPlane:360}
\begin{aligned}
\lr{ \lr{ \Bd \cdot B } \inv{B} } \cdot B
&=
\gpgradeone{ \lr{ \Bd \cdot B } \inv{B} B } \\
&=
\gpgradeone{ \Bd \cdot B } \\
&= 0,
\end{aligned}

which demonstrates that this is the component we are interested in. The directed (shortest) distance from the point $$\Bs$$ to the plane is therefore
\label{eqn:lineAndPlane:380}
\BD
=
\lr{ \lr{ \Bx – \Bs } \wedge B } \inv{B}.

There should be a dual form for this relationship too, so let’s see what it looks like. First note that for vector $$\Bd$$
\label{eqn:lineAndPlane:400}
\begin{aligned}
\Bd \wedge B
&=
\Bd I \Bn
} \\
&=
I (\Bd \cdot \Bn),
\end{aligned}

so
\label{eqn:lineAndPlane:420}
\begin{aligned}
\BD
&=
I \lr{ \lr{ \Bx – \Bs } \cdot \Bn } \inv{I \Bn} \\
&=
\lr{ \Bx – \Bs } \cdot \Bn \inv{\Bn}.
\end{aligned}

This would conventionally be written in terms of a unit vector $$\ncap$$ as $$\lr{\lr{ \Bx – \Bs } \cdot \ncap} \ncap$$.

## Summary.

We can write the equation of a line, plane, (volume, …) in a uniform fashion as
\label{eqn:lineAndPlane:440}
\lr{ \By – \Bx } \wedge V = 0,

where $$V = \Bu_1, \Bu_1 \wedge \Bu_2, \Bu_1 \wedge \Bu_2 \wedge \cdots \wedge \Bu_n$$ depending on the dimenion of the desired subspace, where $$\Bu_k$$ are linearly independent vectors spanning that space, and $$\Bx$$ is one point in that subspace.

The (directed) distance from a vector $$\Bs$$ to that subspace is given by
\label{eqn:lineAndPlane:460}
\BD = \lr{ \Bx – \Bs } \wedge V \inv{V}.

For the $$\mathbb{R}^3$$ special case of a line, where $$V = \ucap$$ is a unit vector on the line, we showed that this reduces to
\label{eqn:lineAndPlane:480}
\BD = \ucap \cross \lr{ \lr{ \Bx – \Bs } \cross \ucap },

For the $$\mathbb{R}^3$$ special case of a line, where $$V = I \ncap$$ is a unit bivector representing the plane, we found that we could write \ref{eqn:lineAndPlane:460} as a projection onto the normal to the plane
\label{eqn:lineAndPlane:500}
\BD = \lr{ \lr{ \Bx – \Bs } \cdot \ncap } \ncap.

Again, only for $$\mathbb{R}^3$$ we were also able to write the equation of the plane itself in dual form as
\label{eqn:lineAndPlane:520}
\lr{ \By – \Bx } \cdot \ncap = 0.

These dual forms would also be possible for other special cases (like the equation of a volume in $$\mathbb{R}^4$$ and the distance from a point to that volume), but should we desire general relationships valid in all dimension (even $$\mathbb{R}^2$$), we can stick to \ref{eqn:lineAndPlane:440} and \ref{eqn:lineAndPlane:460}.

# References

[1] David Vernon Widder. Advanced calculus. Courier Corporation, 1989.

## Modern errata done right: a git merge request

June 7, 2019 Uncategorized No comments , ,

All the sources for my book, Geometric Algebra for Electrical Engineers, are available on github.  Theoretically, that means that instead of sending me an email when errors are found (and I’m sure there are many), you can simply fork the repo, fix the error to your satisfaction, and submit a merge request.  I didn’t expect that to actually happen, but it did:

Tim Put gets the credit for the first direct non-Peeter contribution to the GAelectrodynamics repository.

## Thoughts about Ayn Rand’s Anthem

May 26, 2019 Uncategorized No comments , , ,

Many libertarian podcasts talk about Ayn Rand positively, sometimes even lovingly.  On the other hand, Rand seems to invoke the worst venom and hate from some on the left.

I found the book Anthem, by Rand, at the local recycling depot, which has a community take a book, leave a book bookshelf.  That presented an opportunity to see for my self what the Rand fuss was about.

It turned out that Anthem is a really tiny book, more of a pamphlet than a book.  The copy that I now have is a two in one, with the 2nd edition at the front half of the book, and Rand’s marked up version of her first edition at the back.

The book has a very 1984 like spirit, set in a dystopian alternate (presumed future) reality, where collectivism has been taken to the extreme.  Sexual distinctions have been eliminated, men and women aren’t allowed to be attracted to each other, outside of a proscribed annual mating ritual, kids are taken away from parents at an early age and raised by the state, and most of the knowledge of the past has been obliterated.

An amusing aspect of the book is that gender specific pronouns have been eliminated, as have all personal pronouns.  This is amusing given the current trend towards exactly that in our modern time, where there is an annoying trend to use words like “they” used instead of he/she.  I found “they” for he or she annoying because I happen to think there is value distinguishing between singular and plural.

The focus of the book is to highlight the evil of collectivism.  It’s therefore no surprise why Rand is hated so thoroughly by the left.  There wasn’t much more in this book that I’d imagine would be objectionable, other than the fact that it shows what communism might look like in the extreme.  That might make it unappealing to those that insist “communism works in theory” despite the fact that communism obliterated millions of their own people last century.

There is bit of a revolutionary bent to the story as well.  At the end, once our protagonist has discovered himself, he plans to educate a selection of potential compatriots and establish a little cell against the system.

As I read this book, I realized a little bit in that I’d read it already eons ago. I’m wondering if I read this in some sort of dystopian or sci-fi collection.  I think that I read it without any idea of who Ayn Rand was, so in retrospect, I didn’t even know that I’d read anything by her.

I enjoyed the discovery aspect of this book. There’s been many a sci-fi book that I’ve read that had a dystopian context where the characters are in the situation of having to rediscover the mysteries of the previous civilization. It’s fun to imagine oneself in such a context, knowing how much there is to learn, and the idea of being able to share everything that you discover.

## Electromagnetic theory notes

February 19, 2019 Uncategorized No comments

I’ve posted a minor update (tweaking some of the figures) of my PDF notes from electromagnetic theory (ECE1228H), such as they are.  You can also find links to Mathematica notebooks, and instructions for cloning the git repositories to build the PDF.

Despite my love of the subject, this course was mediocre, and I’d rate my notes for it the same way.

## Small update to old notes for phy450, Relativistic Electrodynamics

February 9, 2019 Uncategorized No comments

I’ve updated the pdf for my old phy450 notes (Relativistic Electrodynamics) from the current latex sources.  Also included on that page are a contents listing, and instructions for forking the git repos.  That should allow for building the pdf from the latex, so if somebody had changes they’d like to make, either for themselves or as feedback, they should be able to do so.

## PHY2403H Quantum Field Theory. Lecture 15: Perturbation ground state, time evolution operator, time ordered product, interaction. Taught by Prof. Erich Poppitz

### DISCLAIMER: Very rough notes from class, with some additional side notes.

These are notes for the UofT course PHY2403H, Quantum Field Theory, taught by Prof. Erich Poppitz, fall 2018.

## Review

We developed the interaction picture representation, which is really the Heisenberg picture with respect to $$H_0$$.

Recall that we found
\label{eqn:qftLecture15:20}
U(t, t’) = e^{i H_0(t – t_0)} e^{-i H(t – t’)} e^{-i H_0(t’ – t_0)},

with solution
\label{eqn:qftLecture15:200}
U(t, t’)
=
T \exp{\lr{ -i \int_{t’}^t H_{\text{I,int}}(t”) dt”}},

\label{eqn:qftLecture15:220}
\begin{aligned}
U(t, t’)^\dagger
&=
T \exp{\lr{ i \int_{t’}^{t} H_{\text{I,int}}(t”) dt”}} \\
&=
T \exp{\lr{ -i \int_{t}^{t’} H_{\text{I,int}}(t”) dt”}} \\
&= U(t’, t),
\end{aligned}

and can use this to calculate the time evolution of a field
\label{eqn:qftLecture15:40}
\phi(\Bx, t)
=
U^\dagger(t, t_0)
\phi_I(\Bx, t)
U(t, t_0)

and found the ground state ket for $$H$$ was
\label{eqn:qftLecture15:60}
\ket{\Omega}
=
\evalbar{
\frac{ U(t_0, -T) \ket{0} }
{
e^{-i E_0(T – t_0)} \braket{\Omega}{0}
}
}{T \rightarrow \infty(1 – i \epsilon)}.

### Question:

What’s the point of this, since it is self referential?

We will see, and also see that it goes away. Alternatively, you can write it as
\begin{equation*}
\ket{\Omega} \braket{\Omega}{0}
=
\evalbar{
\frac{ U(t_0, -T) \ket{0} }
{
e^{-i E_0(T – t_0)}
}
}{T \rightarrow \infty(1 – i \epsilon)}.
\end{equation*}

We can also show that
\label{eqn:qftLecture15:80}
\bra{\Omega}
=
\evalbar{
\frac{ \bra{0} U(T, t_0) }
{
e^{-i E_0(T – t_0)} \braket{0}{\Omega}
}
}{T \rightarrow \infty(1 – i \epsilon)}.

Our goal is still toe calculate
\label{eqn:qftLecture15:100}
\bra{\Omega} T \phi(x) \phi(y) \ket{\Omega}.

Claim: the “LSZ” theorem (a neat way of writing this) relates this to S matrix elements.

Assuming $$x^0 > y^0$$

\label{eqn:qftLecture15:120}
\bra{\Omega} \phi(x) \phi(y) \ket{\Omega}
=
\frac{
\bra{0}
U(T, t_0)
U^\dagger(x^0, t^0)
\phi_I(x)
U(x^0, t^0)
U^\dagger(y^0, t^0)
\phi_I(y)
U(y^0, t^0)
U(t_0, -T)
\ket{0}
}
{
e^{-i 2 E_0 T} \Abs{\braket{0}{\Omega}}^2
}

Normalize $$\braket{\Omega}{\Omega} = 1$$, gives

\label{eqn:qftLecture15:140}
\begin{aligned}
1
&=
\frac{\bra{0} U(T, t_0) U(t_0, -T) \ket{0}}
{
e^{-i 2 E_0 T} \Abs{\braket{0}{\Omega}}^2
} \\
&=
\frac{\bra{0} U(T, -T) \ket{0}}
{
e^{-i 2 E_0 T} \Abs{\braket{0}{\Omega}}^2
},
\end{aligned}

so that
\label{eqn:qftLecture15:240}
\bra{\Omega} \phi(x) \phi(y) \ket{\Omega}
=
\frac{
\bra{0}
U(T, t_0)
U^\dagger(x^0, t^0)
\phi_I(x)
U(x^0, t^0)
U^\dagger(y^0, t^0)
\phi_I(y)
U(y^0, t^0)
U(t_0, -T)
\ket{0}
}
{
\bra{0} U(T, -T) \ket{0}
}

For $$t_1 > t_2 > t_3$$
\label{eqn:qftLecture15:280}
\begin{aligned}
U(t_1, t_2) U(t_2, t_3)
&=
T e^{-i \int_{t_2}^{t_1} H_I}
T e^{-i \int_{t_3}^{t_2} H_I} \\
&=
T \lr{
e^{-i \int_{t_2}^{t_1} H_I}
e^{-i \int_{t_3}^{t_2} H_I}
} \\
&=
T(
e^{-i \int_{t_3}^{t_1} H_I}
),
\end{aligned}

with an end result of
\label{eqn:qftLecture15:320}
U(t_1, t_2) U(t_2, t_3) = U(t_1, t_3).

(DIY: work through the details — this is a problem in [1])

This gives
\label{eqn:qftLecture15:300}
\bra{\Omega} \phi(x) \phi(y) \ket{\Omega}
=
\frac{
\bra{0}
U(T, x^0)
\phi_I(x)
U(x^0, y^0)
\phi_I(y)
U(y^0, -T)
\ket{0}
}
{
\bra{0} U(T, -T) \ket{0}
}.

If $$y^0 > x^0$$ we have the same result, but the $$y$$’s will come first.

### Claim:

\label{eqn:qftLecture15:340}
\bra{\Omega} \phi(x) \phi(y) \ket{\Omega}
=
\frac{
\bra{0}
T\lr{
\phi_I(x)
\phi_I(y)
e^{-i \int_{-T}^T H_{\text{I,int}}(t’) dt’}
}
\ket{0}
}
{
\bra{0}
T ( e^{-i \int_{-T}^T H_{\text{I,int}}(t’) dt’} )
\ket{0}
}.

More generally
\label{eqn:qftLecture15:360}
\boxed{
\bra{\Omega}
\phi_I(x_1) \cdots
\phi_I(x_n)
\ket{\Omega}
=
\frac{
\bra{0}
T\lr{
\phi_I(x_1) \cdots
\phi_I(x_n)
e^{-i \int_{-T}^T H_{\text{I,int}}(t’) dt’}
}
\ket{0}
}
{
\bra{0}
T ( e^{-i \int_{-T}^T H_{\text{I,int}}(t’) dt’} )
\ket{0}
}.
}

This is the holy grail of perturbation theory.

In QFT II you will see this written in a path integral representation
\label{eqn:qftLecture15:380}
\bra{\Omega}
\phi_I(x_1) \cdots
\phi_I(x_n)
\ket{\Omega}
=
\frac
{
\int [\mathcal{D} \phi] \phi(x_1) \phi(x_2) \cdots \phi(x_n) e^{-i S[\phi]}
}
{
\int [\mathcal{D} \phi] e^{-i S[\phi]}
}.

## Unpacking it.

\label{eqn:qftLecture15:400}
\begin{aligned}
\int_{-T}^T H_{\text{I,int}}(t)
&=
\int_{-T}^T
\int d^3 \Bx \frac{\lambda}{4} \lr{ \phi_I(\Bx, t) }^4 \\
&=
\int d^4 x
\frac{\lambda}{4} \lr{ \phi_I }^4
\end{aligned}

so we have
\label{eqn:qftLecture15:420}
\frac{
\bra{0}
T\lr{
\phi_I(x_1) \cdots
\phi_I(x_n)
e^{-i \frac{\lambda}{4} \int d^4 x \phi_I^4(x) }
}
\ket{0}
}
{
\bra{0}
T
e^{-i \frac{\lambda}{4} \int d^4 x \phi_I^4(x) }
\ket{0}
}.

The numerator expands as
\label{eqn:qftLecture15:440}
\bra{0} T\lr{ \phi_I(x_1) \cdots \phi_I(x_n) } \ket{0}
-i \frac{\lambda}{4} \int d^4 x
\bra{0} T\lr{ \phi_I(x_1) \cdots \phi_I(x_n) \phi_I^4(x) }
+
\inv{2}
\lr{-i \frac{\lambda}{4}}^2 \int d^4 x d^4 y
\bra{0} T\lr{ \phi_I(x_1) \cdots \phi_I(x_n)
\phi_I^4(x)
\phi_I^4(y)
} \ket{0}
+ \cdots

so we see that the problem ends up being the calculation of time ordered products.

## Calculating perturbation

Let’s simplify notation, dropping interaction picture suffixes, writing $$\phi(x_i) = \phi_i$$.

Let’s calculate $$\bra{0} T\lr{ \phi_1 \cdots \phi_n } \ket{0}$$. For $$n = 2$$ we have

\label{eqn:qftLecture15:n}
\bra{0} T\lr{ \phi_1 \cdots \phi_n } \ket{0}
= D_F(x_1 – x_2) \equiv D_F(1-2)

### TO BE CONTINUED.

The rest of the lecture was very visual, and hard to type up. I’ll do so later.

# References

[1] Michael E Peskin and Daniel V Schroeder. An introduction to Quantum Field Theory. Westview, 1995.

## ECE1505H Convex Optimization. Lecture 7: Examples of convex and concave functions, local and global minimums. Taught by Prof. Stark Draper

### Disclaimer

Peeter’s lecture notes from class. These may be incoherent and rough.

These are notes for the UofT course ECE1505H, Convex Optimization, taught by Prof. Stark Draper, from [1].

### Today

• Local and global optimality
• Compositions of functions
• Examples

### Example:

\label{eqn:convexOptimizationLecture7:20}
\begin{aligned}
F(x) &= x^2 \\
F”(x) &= 2 > 0
\end{aligned}

strictly convex.

### Example:

\label{eqn:convexOptimizationLecture7:40}
\begin{aligned}
F(x) &= x^3 \\
F”(x) &= 6 x.
\end{aligned}

Not always non-negative, so not convex. However $$x^3$$ is convex on $$\textrm{dom} F = \mathbb{R}_{+}$$.

### Example:

\label{eqn:convexOptimizationLecture7:60}
\begin{aligned}
F(x) &= x^\alpha \\
F'(x) &= \alpha x^{\alpha-1} \\
F”(x) &= \alpha(\alpha-1) x^{\alpha-2}.
\end{aligned}

fig. 1. Powers of x.

This is convex on $$\mathbb{R}_{+}$$, if $$\alpha \ge 1$$, or $$\alpha \le 0$$.

### Example:

\label{eqn:convexOptimizationLecture7:80}
\begin{aligned}
F(x) &= \log x \\
F'(x) &= \inv{x} \\
F”(x) &= -\inv{x^2} \le 0
\end{aligned}

This is concave.

### Example:

\label{eqn:convexOptimizationLecture7:100}
\begin{aligned}
F(x) &= x\log x \\
F'(x) &= \log x + x \inv{x} = 1 + \log x \\
F”(x) &= \inv{x}
\end{aligned}

This is strictly convex on
$$\mathbb{R}_{++}$$, where
$$F”(x) \ge 0$$.

### Example:

\label{eqn:convexOptimizationLecture7:120}
\begin{aligned}
F(x) &= e^{\alpha x} \\
F'(x) &= \alpha e^{\alpha x} \\
F”(x) &= \alpha^2 e^{\alpha x} \ge 0
\end{aligned}

fig. 2. Exponential.

Such functions are plotted in fig. 2, and are convex function for all $$\alpha$$.

### Example:

For symmetric $$P \in S^n$$

\label{eqn:convexOptimizationLecture7:140}
\begin{aligned}
F(\Bx) &= \Bx^\T P \Bx + 2 \Bq^\T \Bx + r \\
\spacegrad F &= (P + P^\T) \Bx + 2 \Bq = 2 P \Bx + 2 \Bq \\
\end{aligned}

This is convex(concave) if $$P \ge 0$$ ($$P \le 0$$).

### Example:

\label{eqn:convexOptimizationLecture7:780}
F(x, y) = x^2 + y^2 + 3 x y,

that is neither convex nor concave is plotted in fig 3.

fig 3. Function with saddle point (3d and contours)

This function can be put in matrix form

\label{eqn:convexOptimizationLecture7:160}
F(x, y) = x^2 + y^2 + 3 x y
=
\begin{bmatrix}
x & y
\end{bmatrix}
\begin{bmatrix}
1 & 1.5 \\
1.5 & 1
\end{bmatrix}
\begin{bmatrix}
x \\
y
\end{bmatrix},

and has the Hessian

\label{eqn:convexOptimizationLecture7:180}
\begin{aligned}
&=
\begin{bmatrix}
\partial_{xx} F & \partial_{xy} F \\
\partial_{yx} F & \partial_{yy} F \\
\end{bmatrix} \\
&=
\begin{bmatrix}
2 & 3 \\
3 & 2
\end{bmatrix} \\
&= 2 P.
\end{aligned}

From the plot we know that this is not PSD, but this can be confirmed by checking the eigenvalues

\label{eqn:convexOptimizationLecture7:200}
\begin{aligned}
0
&=
\det ( P – \lambda I ) \\
&=
(1 – \lambda)^2 – 1.5^2,
\end{aligned}

which has solutions

\label{eqn:convexOptimizationLecture7:220}
\lambda = 1 \pm \frac{3}{2} = \frac{3}{2}, -\frac{1}{2}.

This is not PSD nor negative semi-definite, because it has one positive and one negative eigenvalues. This is neither convex nor concave.

Along $$y = -x$$,

\label{eqn:convexOptimizationLecture7:240}
\begin{aligned}
F(x,y)
&=
F(x,-x) \\
&=
2 x^2 – 3 x^2 \\
&=
– x^2,
\end{aligned}

so it is concave along this line. Along $$y = x$$

\label{eqn:convexOptimizationLecture7:260}
\begin{aligned}
F(x,y)
&=
F(x,x) \\
&=
2 x^2 + 3 x^2 \\
&=
5 x^2,
\end{aligned}

so it is convex along this line.

### Example:

\label{eqn:convexOptimizationLecture7:280}
F(\Bx) = \sqrt{ x_1 x_2 },

on $$\textrm{dom} F = \setlr{ x_1 \ge 0, x_2 \ge 0 }$$

For the Hessian
\label{eqn:convexOptimizationLecture7:300}
\begin{aligned}
\PD{x_1}{F} &= \frac{1}{2} x_1^{-1/2} x_2^{1/2} \\
\PD{x_2}{F} &= \frac{1}{2} x_2^{-1/2} x_1^{1/2}
\end{aligned}

The Hessian components are

\label{eqn:convexOptimizationLecture7:320}
\begin{aligned}
\PD{x_1}{} \PD{x_1}{F} &= -\frac{1}{4} x_1^{-3/2} x_2^{1/2} \\
\PD{x_1}{} \PD{x_2}{F} &= \frac{1}{4} x_2^{-1/2} x_1^{-1/2} \\
\PD{x_2}{} \PD{x_1}{F} &= \frac{1}{4} x_1^{-1/2} x_2^{-1/2} \\
\PD{x_2}{} \PD{x_2}{F} &= -\frac{1}{4} x_2^{-3/2} x_1^{1/2}
\end{aligned}

or
\label{eqn:convexOptimizationLecture7:340}
=
-\frac{\sqrt{x_1 x_2}}{4}
\begin{bmatrix}
\inv{x_1^2} & -\inv{x_1 x_2} \\
-\inv{x_1 x_2} & \inv{x_2^2}
\end{bmatrix}.

Checking this for PSD against $$\Bv = (v_1, v_2)$$, we have
\label{eqn:convexOptimizationLecture7:360}
\begin{aligned}
\begin{bmatrix}
v_1 & v_2
\end{bmatrix}
\begin{bmatrix}
\inv{x_1^2} & -\inv{x_1 x_2} \\
-\inv{x_1 x_2} & \inv{x_2^2}
\end{bmatrix}
\begin{bmatrix}
v_1 \\ v_2
\end{bmatrix}
&=
\begin{bmatrix}
v_1 & v_2
\end{bmatrix}
\begin{bmatrix}
\inv{x_1^2} v_1 -\inv{x_1 x_2} v_2 \\
-\inv{x_1 x_2} v_1 + \inv{x_2^2} v_2
\end{bmatrix} \\
&=
\lr{ \inv{x_1^2} v_1 -\inv{x_1 x_2} v_2 } v_1 +
\lr{ -\inv{x_1 x_2} v_1 + \inv{x_2^2} v_2 } v_2
\\
&=
\inv{x_1^2} v_1^2
+ \inv{x_2^2} v_2^2
-2 \inv{x_1 x_2} v_1 v_2 \\
&=
\lr{
\frac{v_1}{x_1}
-\frac{v_2}{x_2}
}^2 \\
&\ge 0,
\end{aligned}

so $$\spacegrad^2 F \le 0$$. This is a negative semi-definite function (concave). Observe that this check required checking PSD for all values of $$\Bx$$.

This is an example of a more general result

\label{eqn:convexOptimizationLecture7:380}
F(x) = \lr{ \prod_{i = 1}^n x_i }^{1/n},

which is concave (prove on homework).

### Summary.

If $$F$$ is differentiable in \R{n}, then check the curvature of the function along all lines. i.e. At all locations and in all directions.

If the Hessian is PSD at all $$\Bx \in \textrm{dom} F$$, that is

\label{eqn:convexOptimizationLecture7:400}
\spacegrad^2 F \ge 0 \, \forall \Bx \in \textrm{dom} F,

then the function is convex.

### Example:

Over $$\textrm{dom} F = \mathbb{R}^n$$

\label{eqn:convexOptimizationLecture7:420}
F(\Bx) = \max_{i = 1}^n x_i

i.e.
\label{eqn:convexOptimizationLecture7:440}
\begin{aligned}
F((1,2) &= 2 \\
F((3,-1) &= 3
\end{aligned}

### Example:

\label{eqn:convexOptimizationLecture7:460}
F(\Bx) = \max_{i = 1}^n F_i(\Bx),

where

\label{eqn:convexOptimizationLecture7:480}
F_i(\Bx)
=
… ?

max of a set of convex functions is a convex function.

### Example:

\label{eqn:convexOptimizationLecture7:500}
F(x) =
x_{[1]} +
x_{[2]} +
x_{[3]}

where

$$x_{[k]}$$ is the k-th largest number in the list

Write

\label{eqn:convexOptimizationLecture7:520}
F(x) = \max x_i + x_j + x_k

\label{eqn:convexOptimizationLecture7:540}
(i,j,k) \in \binom{n}{3}

### Example:

For $$\Ba \in \mathbb{R}^n$$ and $$b_i \in \mathbb{R}$$

\label{eqn:convexOptimizationLecture7:560}
\begin{aligned}
F(\Bx)
&= \sum_{i = 1}^n \log( b_i – \Ba^\T \Bx )^{-1} \\
&= -\sum_{i = 1}^n \log( b_i – \Ba^\T \Bx )
\end{aligned}

This $$b_i – \Ba^\T \Bx$$ is an affine function of $$\Bx$$ so it doesn’t affect convexity.

Since $$\log$$ is concave, $$-\log$$ is convex. Convex functions of affine function of $$\Bx$$ is convex function of $$\Bx$$.

### Example:

\label{eqn:convexOptimizationLecture7:580}
F(\Bx) = \sup_{\By \in C} \Norm{ \Bx – \By }

fig. 3. Max length function

Here $$C \subseteq \mathbb{R}^n$$ is not necessarily convex. We are using $$\sup$$ here because the set $$C$$ may be open. This function is the length of the line from $$\Bx$$ to the point in $$C$$ that is furthest from $$\Bx$$.

• $$\Bx – \By$$ is linear in $$\Bx$$
• $$g_\By(\Bx) = \Norm{\Bx – \By}$$ is convex in $$\Bx$$ since norms are convex functions.
• $$F(\Bx) = \sup_{\By \in C} \Norm{ \Bx – \By }$$. Each $$\By$$ index is a convex function. Taking max of those.

### Example:

\label{eqn:convexOptimizationLecture7:600}
F(\Bx) = \inf_{\By \in C} \Norm{ \Bx – \By }.

Min and max of two convex functions are plotted in fig. 4.

fig. 4. Min and max

The max is observed to be convex, whereas the min is not necessarily so.

\label{eqn:convexOptimizationLecture7:800}
F(\Bz) = F(\theta \Bx + (1-\theta) \By) \ge \theta F(\Bx) + (1-\theta)F(\By).

This is not necessarily convex for all sets $$C \subseteq \mathbb{R}^n$$, because the $$\inf$$ of a bunch of convex function is not necessarily convex. However, if $$C$$ is convex, then $$F(\Bx)$$ is convex.

### Consequences of convexity for differentiable functions

• Think about unconstrained functions $$\textrm{dom} F = \mathbb{R}^n$$.
• By first order condition $$F$$ is convex iff the domain is convex and
\label{eqn:convexOptimizationLecture7:620}
F(\Bx) \ge \lr{ \spacegrad F(\Bx)}^\T (\By – \Bx) \, \forall \Bx, \By \in \textrm{dom} F.

If $$F$$ is convex and one can find an $$\Bx^\conj \in \textrm{dom} F$$ such that

\label{eqn:convexOptimizationLecture7:640}

then

\label{eqn:convexOptimizationLecture7:660}
F(\By) \ge F(\Bx^\conj) \, \forall \By \in \textrm{dom} F.

If you can find the point where the gradient is zero (which can’t always be found), then $$\Bx^\conj$$ is a global minimum of $$F$$.

Conversely, if $$\Bx^\conj$$ is a global minimizer of $$F$$, then $$\spacegrad F(\Bx^\conj) = 0$$ must hold. If that were not the case, then you would be able to find a direction to move downhill, contracting the optimality of $$\Bx^\conj$$.

### Local vs Global optimum

fig. 6. Global and local minimums

Definition: Local optimum
$$\Bx^\conj$$ is a local optimum of $$F$$ if $$\exists \epsilon > 0$$ such that $$\forall \Bx$$, $$\Norm{\Bx – \Bx^\conj} < \epsilon$$, we have

\begin{equation*}
F(\Bx^\conj) \le F(\Bx)
\end{equation*}

fig. 5. min length function

Theorem:
Suppose $$F$$ is twice continuously differentiable (not necessarily convex)

• If $$\Bx^\conj$$ is a local optimum then\begin{equation*}
\begin{aligned}
\end{aligned}
\end{equation*}
• If
\begin{equation*}
\begin{aligned}
\end{aligned},
\end{equation*}then $$\Bx^\conj$$ is a local optimum.

Proof:

• Let $$\Bx^\conj$$ be a local optimum. Pick any $$\Bv \in \mathbb{R}^n$$.\label{eqn:convexOptimizationLecture7:720}
\lim_{t \rightarrow 0} \frac{ F(\Bx^\conj + t \Bv) – F(\Bx^\conj)}{t}
= \lr{ \spacegrad F(\Bx^\conj) }^\T \Bv
\ge 0.

Here the fraction is $$\ge 0$$ since $$\Bx^\conj$$ is a local optimum.

Since the choice of $$\Bv$$ is arbitrary, the only case that you can ensure that $$\ge 0, \forall \Bv$$ is

\label{eqn:convexOptimizationLecture7:740}

( or else could pick $$\Bv = -\spacegrad F(\Bx^\conj)$$.

This means that $$\spacegrad F(\Bx^\conj) = 0$$ if $$\Bx^\conj$$ is a local optimum.

Consider the 2nd order derivative

\label{eqn:convexOptimizationLecture7:760}
\begin{aligned}
\lim_{t \rightarrow 0} \frac{ F(\Bx^\conj + t \Bv) – F(\Bx^\conj)}{t^2}
&=
\lim_{t \rightarrow 0} \inv{t^2}
\lr{
F(\Bx^\conj) + t \lr{ \spacegrad F(\Bx^\conj) }^\T \Bv + \inv{2} t^2 \Bv^\T \spacegrad^2 F(\Bx^\conj) \Bv + O(t^3)
– F(\Bx^\conj)
} \\
&=
\inv{2} \Bv^\T \spacegrad^2 F(\Bx^\conj) \Bv \\
&\ge 0.
\end{aligned}

Here the $$\ge$$ condition also comes from the fraction, based on the optimiality of $$\Bx^\conj$$. This is true for all choice of $$\Bv$$, thus $$\spacegrad^2 F(\Bx^\conj)$$.

# References

[1] Stephen Boyd and Lieven Vandenberghe. Convex optimization. Cambridge university press, 2004.

## New home office and network setup

August 30, 2016 Uncategorized 2 comments

I’ve just bought a nice new desk for my home office:

When I assembled the new desk, I took the opportunity to refine my home network setup.  In this post I’ll walk through that setup.

I’ve got the router in the living room, along with the two NUC6i’s that I use for my lzlabs development work:

I run the NUCs headless, using ssh and command line access for my work.  For those times that I need to refresh the install image and need a display, I also have them HDMI connected to the living room TV, and direct connected with short ethernet cables to the router:

The router is also directly connected to the PS3 (for netflix), and then runs through some ethernet lines that I fished into the basement, before some of the basement finishing work we did just after we moved in.  All the lines I have going into the basement terminate in a patch panel:

Does a patch panel sound like overkill?  Yes, it probably is.  However, I’ve got a pile of roughed in ethernet lines to the kids rooms and the rec room that I’ll eventually fish into the electrical-panel/laundry/network room:

I’d like to also eventually fish some ethernet lines into the upstairs space (i.e. for netflix run off a blue-ray player that sits mostly unused in the master bedroom), but that’s a harder fishing job, and I haven’t done it yet.  From the front of the patch panel things go off to the router:

and from there to a switch:

One line comes from the router (through the patch panel), and then all the rest of the ethernet lines from the switch go to final destinations.  Four of those lines go back to the patch panel and up to the office space.  One is plugged into one of the thunderbolt monitors, so I can use a wired connection while “docked”.  One goes up to the office space and is connected to an Odroid (which can run the Lz stack on aarch64 hardware).  One line goes back to the living room, for optional wired couch surfing, and the last is connected to a voip phone.

I’ve got a lot of finishing touches to do.  I plan to mount the patch panel next to the electrical panel, instead of just placing it on top of the freezer down in the laundry room.  I’ve also got lines that are running through the ceiling, but are hanging loose still.  The wall panel in my office space is currently hanging loose:

I have a low voltage wiring box purchased, but need to cut the hole for it, so I can screw in this little panel and get it nicely out of the way, and do the plastering and painting to fix up the messy fishing holes I made trying to find a route down into the basement.

## Shipping with DHL. They will screw you, but not quite as bad as UPS.

I previously complained about UPS customs clearing charges that I was slammed with receiving back some of my own goods.

Basically, the Canadian government grants shipping companies the right to extort receivers at the point of customs clearing. Canada might add a few cents or a buck or two of tax, but the shipping company is then able to add fees that are orders of magnitude higher than the actual taxes.

I actually stopped buying anything from the United States because of this, and have been buying from Europe and India instead, where I had not yet gotten blasted with customs clearing fees for the items I’ve been buying (usually textbooks).

However, it appears that my luck has run out.  Here’s the newest example, with a $15 dollar clearing fee that DHL added onto about a dollar of tax: Note that I did not pick the shipping company. That was selected by the book seller (one of the abebooks.com resellers). For$1.17 of taxes, DHL has charged me $14.75 of fees, all for the right to allow Canada revenue to steal from me. To add insult to injury, DHL is allowed to charge GST for their extortion service, so I end up paying an additional$3.09 (close to 3x the initial tax amount).  The value of the book + shipping that I purchased was only $23.30! Aside: Why is the GST on$14.75 that high?  I thought that’s a 13% tax, so shouldn’t it be \$1.92?

I’ve found some instructions that explain some of the black magic required to do my own customs clearing:

One of the first steps is to find the CBSA office that I can submit such a clearing form to.  I can narrow that search down to province, but some of these offices are restricted to specific purposes, and it isn’t obvious which of these offices I should use.  For example the one at Buttonville airport appears to be restricted to handling just the cargo that arrives there.

I wonder if there are any local resellers that import used and cheap textbooks in higher quantities and then resell them locally (taking the customs clearing charge only once per shipment)?