## Political correctness

I saw an article on facebook about some recent idiocy at Queen’s university.

The idiocy isn’t what is being dubbed a racist party, but the fact that a costume party is dubbed racist.

A comment on this (Leon) that I thought summed things up nicely was:

“It is people who criticize a bunch of kids dressing as racists who make incidents of real racism greatly diminished.”

There is an alarming trend of perverting language in the political correct circles that is mystifying

• A kiss without a contract, triple signed and witnessed, is now being called rape, or it’s seeming legal equivalent “sexual assault”.  There are concent posters all over UofT that outline the legalistic contracting required for sexuality in this PC age.  I was too inhibited when I was an undergrad to have had much sexual activity, but I’m glad that I’m not an undergrad now subject to the current guidelines.  It’s definitely not okay to take advantage of somebody who is drunk, but this has been flipped on its head.  Sex after consentual codrunkenness now appears to be sexual assult in some places.
• Failing to use the “correct” gendered pronoun is now “hate speech”, and is perceived as, or at least mislabelled as, explicit violence.  I’m a firm believer that people should have complete freedom to engage in hate speech or discrimination of any sort.  Let people dig themselves their own social graves instead of trying to legislate speech.
• Costume parties, even at halloween, are now being mislabelled racist.  Attempting to point that out at some PC universities resulted in so much PC backlash that resignations followed.

I keep hearing about instance after instance of such events.  It seems like most of the people who are pushing the political correctness agenda really desperately need dictionaries.  Just because you can label two things as identical, doesn’t mean that they are.  A perfect example of this is the use of “sexual assault” now instead of rape.  The two are now identified as identical, even though sexual assault is a much broader term that includes groping.

There was lots in the recent US election media circus about how Trump’s bragging of pussy grabbing and aggressive kissing, acts that were facilitated by stardom.  One of the debate moderators explicitly called that sexual assault.  I don’t like the phrase sexual assault, because it is ambiguous, and has connotations of rape, while not necessarily being rape.  It seems to be a phrase designed to have the emotional impact of rape, while being something lesser.

Whether or not that Trump was bragging about sexual assault is probably dependent on state law.  Ambiguous language identifies unequal events with the same weight, and seems to be a characteristic of political correct speech and activism.  For example, calling pussy grabbing rape would be an obvious example of the misuse of language.  That’s why PC correct speech uses sexual assault instead.  A side effect of such PC correct speech is that actual rape, a horribly abusive event, is trivialized.  The irony in the Trump case was that the media could have focused on actual rape.  For example, Trump and his pedophile buddy Jeffrey Epstein, are codefendents in an actual rape case (which I understand has now unfortunately been dropped due to technicalities).  Characteristic of many of the charges laid against Epstein, this one is also of a child, in this case a 13 year old.

Of his buddy Epstein Trump said

“I’ve known Jeff for fifteen years. Terrific guy. He’s a lot of fun to be with. It is even said that he likes beautiful women as much as I do, and many of them are on the younger side.”

It remains to see if Trump is a sexual predator on par with Bill Clinton.  My gut feeling why pussy grabbing got so much attention, but Trump’s case with Epstein did not was because Bill is also a good friend of Epstein, and had been down to Epstein’s pedophile island many times.  Raising attention to that would have distracted from Hillary’s campaign (perhaps even raised the issue that she’d also “partied” there, in ways currently unspecified).

I digress.

How can political correctness be combatted?  One way is calling out explicit misuse of language.  Be very careful to use accurate words, and not to conflate things in order to push an agenda.

Because the political correctness movement is anti-intellectual, I suspect that purely linguistic techniques to fighting it are doomed.  Are there active social techniques that would be effective?

I came up with one idea that I amused myself with.  Perhaps it is time to start hosting some explicitly politically incorrect parties, just to push back.  Imagine a Halloween party that you are not allowed into, unless you are offending some minority group.  Suggested costume ideas include Hilter, blackface, transvestites or red-indians.  If you aren’t insulting somebody, then you can’t come in.  If you don’t think that Hilter is offensive enough, perhaps the host would allow you in if you dressed as some other psychopathic killer like Kissinger or Churchill, but that risks turning the party into an political party instead of an anti-PC party.  Costume prize adjudication would be biased against those that are in a visible minority group, so you should get extra points if you are a cis gendered white male.  Bonus points to the hosts of the party should they hold it on a university campus.

## Fresnel angular sum and difference formulas

November 22, 2016 math and physics play No comments , ,

In [1] are some sum and angle difference formulations for the Fresnel formulas given a $$\mu_1 = \mu_2$$ constraint. The proof of these trig Fresnel equations is left to an exercise, and will be derived here.

\label{eqn:fresnelSumAndDifferenceAngleFormulas:20}
\begin{aligned}
\sin(a + b)
&=
\textrm{Im}\lr{ e^{j(a + b)} } \\
&=
\textrm{Im}\lr{
e^{ja} e^{+ jb}
} \\
&=
\textrm{Im}\lr{
(\cos a + j \sin a) (\cos b + j \sin b)
} \\
&=
\sin a \cos b + \cos a \sin b.
\end{aligned}

Allowing for both signs we have

\label{eqn:fresnelSumAndDifferenceAngleFormulas:240}
\begin{aligned}
\sin(a + b) &= \sin a \cos b + \cos a \sin b \\
\sin(a – b) &= \sin a \cos b – \cos a \sin b.
\end{aligned}

The mixed sine and cosine product can be expressed as a sum of sines

\label{eqn:fresnelSumAndDifferenceAngleFormulas:40}
2 \sin a \cos b = \sin(a + b) + \sin(a – b).

With $$2 x = a + b, 2 y = a – b$$, or $$a = x + y, b = x – y$$, we find

\label{eqn:fresnelSumAndDifferenceAngleFormulas:60}
\begin{aligned}
2 \sin(x + y) \cos (x – y) &= \sin( 2 x ) + \sin( 2 y ) \\
2 \sin(x – y) \cos (x + y) &= \sin( 2 x ) – \sin( 2 y ).
\end{aligned}

Returning to the problem. When $$\mu_1 = \mu_2$$ the Fresnel equations were found to be

\label{eqn:fresnelSumAndDifferenceAngleFormulas:100}
\begin{aligned}
r^{\textrm{TE}} &= \frac { n_1 \cos\theta_i – n_2 \cos\theta_t } { n_1 \cos\theta_i + n_2 \cos\theta_t } \\
r^{\textrm{TM}} &= \frac{n_2 \cos\theta_i – n_1 \cos\theta_t }{ n_2 \cos\theta_i + n_1 \cos\theta_t } \\
t^{\textrm{TE}} &= \frac{ 2 n_1 \cos\theta_i } { n_1 \cos\theta_i + n_2 \cos\theta_t } \\
t^{\textrm{TM}} &= \frac{2 n_1 \cos\theta_i }{ n_2 \cos\theta_i + n_1 \cos\theta_t }.
\end{aligned}

Using Snell’s law, one of $$n_1, n_2$$ can be eliminated, for example

\label{eqn:fresnelSumAndDifferenceAngleFormulas:120}
n_1 = n_2 \frac{\sin \theta_t}{\sin\theta_i}.

Inserting this and proceeding with the application of the trig identities above, we have

\label{eqn:fresnelSumAndDifferenceAngleFormulas:160}
\begin{aligned}
r^{\textrm{TE}}
&= \frac { n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_i – n_2 \cos\theta_t } { n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_i + n_2 \cos\theta_t } \\
&=
\frac {
\sin\theta_t \cos\theta_i – \cos\theta_t \sin\theta_i
} {
\sin\theta_t \cos\theta_i + \cos\theta_t \sin\theta_i
} \\
&=
\frac {
\sin( \theta_t – \theta_i )
} {
\sin( \theta_t + \theta_i )
}
\end{aligned}

\label{eqn:fresnelSumAndDifferenceAngleFormulas:180}
\begin{aligned}
r^{\textrm{TM}}
&= \frac{n_2 \cos\theta_i – n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_t }{ n_2 \cos\theta_i + n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_t } \\
&= \frac{
\sin\theta_i \cos\theta_i – \sin\theta_t \cos\theta_t
}{
\sin\theta_i \cos\theta_i + \sin\theta_t \cos\theta_t
} \\
&= \frac{\inv{2} \sin(2 \theta_i) – \inv{2} \sin(2 \theta_t) }{ \inv{2} \sin(2 \theta_i) + \inv{2} \sin(2 \theta_t) } \\
&= \frac
{\sin(\theta_i – \theta_t)\cos(\theta_i + \theta_t) }
{\sin(\theta_i + \theta_t)\cos(\theta_i – \theta_t) } \\
&=
\frac
{\tan(\theta_i -\theta_t)}
{\tan(\theta_i +\theta_t)}
\end{aligned}

\label{eqn:fresnelSumAndDifferenceAngleFormulas:200}
\begin{aligned}
t^{\textrm{TE}}
&= \frac{ 2 n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_i } { n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_i + n_2 \cos\theta_t } \\
&= \frac{ 2 \sin\theta_t \cos\theta_i } { \sin\theta_t \cos\theta_i + \cos\theta_t \sin\theta_i } \\
&= \frac{ 2 \sin\theta_t \cos\theta_i }
{ \sin(\theta_i + \theta_t) }
\end{aligned}

\label{eqn:fresnelSumAndDifferenceAngleFormulas:220}
\begin{aligned}
t^{\textrm{TM}}
&= \frac{2 n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_i }{ n_2 \cos\theta_i + n_2 \frac{\sin\theta_t}{\sin\theta_i} \cos\theta_t } \\
&= \frac{2 \sin\theta_t \cos\theta_i }{ \sin\theta_i \cos\theta_i + \sin\theta_t \cos\theta_t } \\
&= \frac{2 \sin\theta_t \cos\theta_i }
{ \inv{2} \sin(2 \theta_i) + \inv{2} \sin(2 \theta_t) } \\
&= \frac{2 \sin\theta_t \cos\theta_i }
{ \sin(\theta_i + \theta_t) \cos(\theta_i – \theta_t) }
\end{aligned}

# References

[1] E. Hecht. Optics. 1998.

## Normal transmission and reflection through two interfaces

November 21, 2016 math and physics play No comments , , , ,

### Motivation

In class an outline of normal transmission through a slab was presented. Let’s go through the details.

### Normal incidence

The geometry of a two interface configuration is sketched in fig. 1.

fig. 1. Two interface transmission.

Given a normal incident ray with magnitude $$A$$, the respective forward and backwards rays in each the mediums can be written as

[I]

1. \label{eqn:twoInterfaceNormal:20}
\begin{aligned}
A e^{-j k_1 z} \\
A r e^{j k_1 z} \\
\end{aligned}
2. \label{eqn:twoInterfaceNormal:40}
C e^{-j k_2 z} \\
D e^{j k_2 z} \\
3. \label{eqn:twoInterfaceNormal:60}
A t e^{-j k_3 (z-d)}

Matching at $$z = 0$$ gives
\label{eqn:twoInterfaceNormal:80}
\begin{aligned}
A t_{12} + r_{21} D &= C \\
A r &= A r_{12} + D t_{21},
\end{aligned}

whereas matching at $$z = d$$ gives

\label{eqn:twoInterfaceNormal:100}
\begin{aligned}
A t &= C e^{-j k_2 d} t_{23} \\
D e^{j k_2 d} &= C e^{-j k_2 d} r_{23}
\end{aligned}

We have four linear equations in four unknowns $$r, t, C, D$$, but only care about solving for $$r, t$$. Let’s write $$\gamma = e^{ j k_2 d }, C’ = C/A, D’ = D/A$$, for

\label{eqn:twoInterfaceNormal:120}
\begin{aligned}
t_{12} + r_{21} D’ &= C’ \\
r &= r_{12} + D’ t_{21} \\
t \gamma &= C’ t_{23} \\
D’ \gamma^2 &= C’ r_{23}
\end{aligned}

Solving for $$C’, D’$$ we get

\label{eqn:twoInterfaceNormal:140}
\begin{aligned}
D’ \lr{ \gamma^2 – r_{21} r_{23} } &= t_{12} r_{23} \\
C’ \lr{ \gamma^2 – r_{21} r_{23} } &= t_{12} \gamma^2,
\end{aligned}

so

\label{eqn:twoInterfaceNormal:160}
\begin{aligned}
r &= r_{12} + \frac{t_{12} t_{21} r_{23} }{\gamma^2 – r_{21} r_{23} } \\
t &= t_{23} \frac{ t_{12} \gamma }{\gamma^2 – r_{21} r_{23} }.
\end{aligned}

With $$\phi = -j k_2 d$$, or $$\gamma = e^{-j\phi}$$, we have

\label{eqn:twoInterfaceNormal:180}
\boxed{
\begin{aligned}
r &= r_{12} + \frac{t_{12} t_{21} r_{23} e^{2 j \phi} }{1 – r_{21} r_{23} e^{2 j \phi}} \\
t &= \frac{ t_{12} t_{23} e^{j\phi}}{1 – r_{21} r_{23} e^{2 j \phi}}.
\end{aligned}
}

### A slab

When the materials in region I, and III are equal, then $$r_{12} = r_{32}$$. For a TE mode, we have

\label{eqn:twoInterfaceNormal:200}
r_{12}
=
\frac{\mu_2 k_{1z} – \mu_1 k_{2z}}{\mu_2 k_{1z} + \mu_1 k_{2z}}
= -r_{21}.

so the reflection and transmission coefficients are

\label{eqn:twoInterfaceNormal:220}
\begin{aligned}
r^{\textrm{TE}} &= r_{12} \lr{ 1 – \frac{t_{12} t_{21} e^{2 j \phi} }{1 – r_{21}^2 e^{2 j \phi}} } \\
t^{\textrm{TE}} &= \frac{ t_{12} t_{21} e^{j\phi}}{1 – r_{21}^2 e^{2 j \phi}}.
\end{aligned}

It’s possible to produce a matched condition for which $$r_{12} = r_{21} = 0$$, by selecting

\label{eqn:twoInterfaceNormal:240}
\begin{aligned}
0
&= \mu_2 k_{1z} – \mu_1 k_{2z} \\
&= \mu_1 \mu_2 \lr{ \inv{\mu_1} k_{1z} – \inv{\mu_2} k_{2z} } \\
&= \mu_1 \mu_2 \omega \lr{ \frac{1}{v_1 \mu_1} \theta_1 – \frac{1}{v_2 \mu_2} \theta_2 },
\end{aligned}

or

\label{eqn:twoInterfaceNormal:260}
\inv{\eta_1} \cos\theta_1 = \inv{\eta_2} \cos\theta_2,

so the matching condition for normal incidence is just

\label{eqn:twoInterfaceNormal:280}
\eta_1 = \eta_2.

Given this matched condition, the transmission coefficient for the 1,2 interface is

\label{eqn:twoInterfaceNormal:300}
\begin{aligned}
t_{12}
&= \frac{2 \mu_2 k_{1z}}{\mu_2 k_{1z} + \mu_1 k_{2z}} \\
&= \frac{2 \mu_2 k_{1z}}{2 \mu_2 k_{1z} } \\
&= 1,
\end{aligned}

so the matching condition yields
\label{eqn:twoInterfaceNormal:320}
\begin{aligned}
t
&=
t_{12} t_{21} e^{j\phi} \\
&=
e^{j\phi} \\
&=
e^{-j k_2 d}.
\end{aligned}

Normal transmission through a matched slab only introduces a phase delay.

## ECE1228H Electromagnetic Theory. Lecture 10: Fresnel relations. Taught by Prof. M. Mojahedi

November 20, 2016 math and physics play No comments , , , ,

### Motivation

In class, an overview of the Fresnel relations for a TE mode electric field were presented. Here’s a fleshing out of the details is presented, as well as the equivalent for the TM mode.

### Single interface TE mode.

The Fresnel reflection geometry for an electric field $$\BE$$ parallel to the interface (TE mode) is sketched in fig. 1.

fig. 1. Electric field TE mode Fresnel geometry.

\label{eqn:emtLecture10:20}
\boldsymbol{\mathcal{E}}_i = \Be_2 E_i e^{j \omega t – j \Bk_{i} \cdot \Bx },

with an assumption that this field maintains it’s polarization in both its reflected and transmitted components, so that

\label{eqn:emtLecture10:40}
\boldsymbol{\mathcal{E}}_r = \Be_2 r E_i e^{j \omega t – j \Bk_{r} \cdot \Bx },

and
\label{eqn:emtLecture10:60}
\boldsymbol{\mathcal{E}}_t = \Be_2 t E_i e^{j \omega t – j \Bk_{t} \cdot \Bx },

Measuring the angles $$\theta_i, \theta_r, \theta_t$$ from the normal, with $$i = \Be_3 \Be_1$$ the wave vectors are

\label{eqn:emtLecture10:620}
\begin{aligned}
\Bk_{i} &= \Be_3 k_1 e^{i\theta_i} = k_1\lr{ \Be_3 \cos\theta_i + \Be_1\sin\theta_i } \\
\Bk_{r} &= -\Be_3 k_1 e^{-i\theta_r} = k_1 \lr{ -\Be_3 \cos\theta_r + \Be_1 \sin\theta_r } \\
\Bk_{t} &= \Be_3 k_2 e^{i\theta_t} = k_2 \lr{ \Be_3 \cos\theta_t + \Be_1 \sin\theta_t }
\end{aligned}

So the time harmonic electric fields are

\label{eqn:emtLecture10:640}
\begin{aligned}
\BE_i &= \Be_2 E_i \exp\lr{ – j k_1 \lr{ z\cos\theta_i + x \sin\theta_i} } \\
\BE_r &= \Be_2 r E_i \exp\lr{ – j k_1 \lr{ -z \cos\theta_r + x \sin\theta_r}} \\
\BE_t &= \Be_2 t E_i \exp\lr{ – j k_2 \lr{ z \cos\theta_t + x \sin\theta_t}}.
\end{aligned}

\label{eqn:emtLecture10:900}
\begin{aligned}
\BH
&= \inv{-j \omega \mu } \spacegrad \cross \BE \\
&= \inv{-j \omega \mu } \spacegrad \cross \Be_2 e^{-j \Bk \cdot \Bx} \\
&= \inv{j \omega \mu } \Be_2 \cross \spacegrad e^{-j \Bk \cdot \Bx} \\
&= -\inv{\omega \mu } \Be_2 \cross \Bk e^{-j \Bk \cdot \Bx} \\
&= \inv{\omega \mu } \Bk \cross \BE
\end{aligned}

We have

\label{eqn:emtLecture10:920}
\begin{aligned}
\kcap_{i} \cross \Be_2 &= -\Be_1 \cos\theta_i + \Be_3\sin\theta_i \\
\kcap_{r} \cross \Be_2 &= \Be_1 \cos\theta_r + \Be_3 \sin\theta_r \\
\kcap_{t} \cross \Be_2 &= -\Be_1 \cos\theta_t + \Be_3 \sin\theta_t,
\end{aligned}

Note that
\label{eqn:emtLecture10:1500}
\begin{aligned}
\frac{k}{\omega \mu}
&=
\frac{k}{k v \mu} \\
&=
\frac{\sqrt{\mu\epsilon}}{\mu} \\
&=\sqrt
{
\frac{\epsilon}{\mu}
} \\
&=
\inv{\eta}.
\end{aligned}

so
\label{eqn:emtLecture10:940}
\begin{aligned}
\BH_{i} &= \frac{ E_i}{\eta_1} \lr{ -\Be_1 \cos\theta_i + \Be_3\sin\theta_i } \exp\lr{ – j k_1 \lr{ z\cos\theta_i + x \sin\theta_i} } \\
\BH_{r} &= \frac{ r E_i}{\eta_1} \lr{ \Be_1 \cos\theta_r + \Be_3 \sin\theta_r } \exp\lr{ – j k_1 \lr{ -z \cos\theta_r + x \sin\theta_r}} \\
\BH_{t} &= \frac{ t E_i}{\eta_2} \lr{ -\Be_1 \cos\theta_t + \Be_3 \sin\theta_t } \exp\lr{ – j k_2 \lr{ z \cos\theta_t + x \sin\theta_t}}.
\end{aligned}

The boundary conditions at $$z = 0$$ with $$\ncap = \Be_3$$ are

\label{eqn:emtLecture10:960}
\begin{aligned}
\ncap \cross \BH_1 &= \ncap \cross \BH_2 \\
\ncap \cdot \BB_1 &= \ncap \cdot \BB_2 \\
\ncap \cross \BE_1 &= \ncap \cross \BE_2 \\
\ncap \cdot \BD_1 &= \ncap \cdot \BD_2,
\end{aligned}

At $$x = 0$$, this is

\label{eqn:emtLecture10:1060}
\begin{aligned}
-\frac{1}{\eta_1} \cos\theta_i + \frac{r }{\eta_1} \cos\theta_r &= -\frac{t }{\eta_2} \cos\theta_t \\
k_1 \sin\theta_i + k_1 r \sin\theta_r &= k_2 t \sin\theta_t \\
1 + r &= t
\end{aligned}

When $$t = 0$$ the latter two equations give Shell’s first law

\label{eqn:emtLecture10:1080}
\boxed{
\sin\theta_i = \sin\theta_r.
}

Assuming this holds for all $$r, t$$ we have

\label{eqn:emtLecture10:1120}
k_1 \sin\theta_i (1 + r ) = k_2 t \sin\theta_t,

which is Snell’s second law in disguise
\label{eqn:emtLecture10:1140}
k_1 \sin\theta_i = k_2 \sin\theta_t.

With
\label{eqn:emtLecture10:1540}
\begin{aligned}
k
&= \frac{\omega}{v} \\
&= \frac{\omega}{c} \frac{c}{v} \\
&= \frac{\omega}{c} n,
\end{aligned}

so \ref{eqn:emtLecture10:1140} takes the form

\label{eqn:emtLecture10:1560}
\boxed{
n_1 \sin\theta_i = n_2 \sin\theta_t.
}

With
\label{eqn:emtLecture10:1200}
\begin{aligned}
k_{1z} &= k_1 \cos\theta_i \\
k_{2z} &= k_2 \cos\theta_t,
\end{aligned}

we can solve for $$r, t$$ by inverting

\label{eqn:emtLecture10:1180}
\begin{bmatrix}
\mu_2 k_{1z} & \mu_1 k_{2z} \\
-1 & 1 \\
\end{bmatrix}
\begin{bmatrix}
r \\
t
\end{bmatrix}
=
\begin{bmatrix}
\mu_2 k_{1z} \\
1
\end{bmatrix},

which gives

\label{eqn:emtLecture10:1220}
\begin{bmatrix}
r \\
t
\end{bmatrix}
=
\begin{bmatrix}
1 & -\mu_1 k_{2z} \\
1 & \mu_2 k_{1z}
\end{bmatrix}
\begin{bmatrix}
\mu_2 k_{1z} \\
1
\end{bmatrix},

or
\label{eqn:emtLecture10:1240}
\boxed{
\begin{aligned}
r &= \frac{\mu_2 k_{1z} – \mu_1 k_{2z}}{\mu_2 k_{1z} + \mu_1 k_{2z}} \\
t &= \frac{2 \mu_2 k_{1z}}{\mu_2 k_{1z} + \mu_1 k_{2z}}
\end{aligned}
}

There are many ways that this can be written. Dividing both the numerator and denominator by $$\mu_1 \mu_2 \omega/c$$, and noting that $$k = \omega n/c$$, we have

\label{eqn:emtLecture10:1680}
\begin{aligned}
r &= \frac
{ \frac{n_1}{\mu_1} \cos\theta_i – \frac{n_2}{\mu_2} \cos\theta_t }
{ \frac{n_1}{\mu_1} \cos\theta_i + \frac{n_2}{\mu_2} \cos\theta_t } \\
t &=
\frac{ 2 \frac{n_1}{\mu_1} \cos\theta_i }
{ \frac{n_1}{\mu_1} \cos\theta_i + \frac{n_2}{\mu_2} \cos\theta_t },
\end{aligned}

which checks against (4.32,4.33) in [1].

### Single interface TM mode.

For completeness, now consider the TM mode.

Faraday’s law also can provide the electric field from the magnetic

\label{eqn:emtLecture10:1280}
\begin{aligned}
\kcap \cross \BH
&= \eta \kcap \cross \lr{ \kcap \cross \BE } \\
&= -\eta \kcap \cdot \lr{ \kcap \wedge \BE } \\
&= -\eta \lr{ \BE – \kcap \lr{ \kcap \cdot \BE } } \\
&= -\eta \BE.
\end{aligned}

so

\label{eqn:emtLecture10:1300}
\BE = \eta \BH \cross \kcap.

So the magnetic and electric fields are

\label{eqn:emtLecture10:1520}
\label{eqn:emtLecture10:1320}
\begin{aligned}
\BH_i &= \Be_2 \frac{E_i}{\eta_1} \exp\lr{ – j k_1 \lr{ z\cos\theta_i + x \sin\theta_i} } \\
\BH_r &= \Be_2 r \frac{E_i}{\eta_1} \exp\lr{ – j k_1 \lr{ -z \cos\theta_r + x \sin\theta_r}} \\
\BH_t &= \Be_2 t \frac{E_i}{\eta_2} \exp\lr{ – j k_2 \lr{ z \cos\theta_t + x \sin\theta_t}}
\end{aligned}

\label{eqn:emtLecture10:1340}
\begin{aligned}
\BE_{i} &= -E_i \lr{ -\Be_1 \cos\theta_i + \Be_3\sin\theta_i } \exp\lr{ – j k_1 \lr{ z\cos\theta_i + x \sin\theta_i} } \\
\BE_{r} &= -r E_i \lr{ \Be_1 \cos\theta_r + \Be_3 \sin\theta_r } \exp\lr{ – j k_1 \lr{ -z \cos\theta_r + x \sin\theta_r}} \\
\BE_{t} &= -t E_i \lr{ -\Be_1 \cos\theta_t + \Be_3 \sin\theta_t } \exp\lr{ – j k_2 \lr{ z \cos\theta_t + x \sin\theta_t}}.
\end{aligned}

Imposing the constraints \ref{eqn:emtLecture10:960}, at $$x = z = 0$$ we have

\label{eqn:emtLecture10:1440}
\begin{aligned}
\inv{\eta_1}\lr{1 + r} &= \frac{t}{\eta_2} \\
\cos\theta_i – r \cos\theta_r &= t \cos\theta_t \\
\epsilon_1 \lr{ \sin\theta_i + r \sin\theta_r} &= t \epsilon_2 \sin\theta_t
\end{aligned}.

At $$t = 0$$, the first and third of these give $$\theta_i = \theta_r$$. Assuming this incident and reflection angle equality holds for all values of $$t$$, we have

\label{eqn:emtLecture10:1580}
\begin{aligned}
\sin\theta_i(1 + r) &= t \frac{\epsilon_2}{\epsilon_1} \sin\theta_t \\
\sin\theta_i \frac{\eta_1}{\eta_2} t &=
\end{aligned}

or
\label{eqn:emtLecture10:1600}
\epsilon_1 \eta_1 \sin\theta_i = \epsilon_2 \eta_2 \sin\theta_t.

This is also Snell’s second law \ref{eqn:emtLecture10:1560} in disguise, which can be seen by

\label{eqn:emtLecture10:1620}
\begin{aligned}
\epsilon_1 \eta_1
&=
\epsilon_1 \sqrt{\frac{\mu_1}{\epsilon_1}} \\
&=
\sqrt{\epsilon_1 \mu_1} \\
&=
\inv{v} \\
&=
\frac{n}{c}.
\end{aligned}

The remaining equations in matrix form are

\label{eqn:emtLecture10:1460}
\begin{bmatrix}
\cos\theta_i & \cos\theta_t \\
-1 & \frac{\eta_1}{\eta_2}
\end{bmatrix}
\begin{bmatrix}
r \\
t
\end{bmatrix}
=
\begin{bmatrix}
\cos\theta_i \\
1
\end{bmatrix},

the inverse of which is
\label{eqn:emtLecture10:1480}
\begin{bmatrix}
r \\
t
\end{bmatrix}
=
\inv{ \frac{\eta_1}{\eta_2} \cos\theta_i + \cos\theta_t }
\begin{bmatrix}
\frac{\eta_1}{\eta_2} & – \cos\theta_t \\
1 & \cos\theta_i
\end{bmatrix}
\begin{bmatrix}
\cos\theta_i \\
1
\end{bmatrix}
=
\inv{ \frac{\eta_1}{\eta_2} \cos\theta_i + \cos\theta_t }
\begin{bmatrix}
\frac{\eta_1}{\eta_2} \cos\theta_i – \cos\theta_t \\
2 \cos\theta_i
\end{bmatrix},

or
\label{eqn:emtLecture10:1640}
\boxed{
\begin{aligned}
r
&=
\frac{\eta_1 \cos\theta_i – \eta_2 \cos\theta_t }{ \eta_1 \cos\theta_i + \eta_2 \cos\theta_t } \\
t &=
\frac{2 \eta_2 \cos\theta_i}{ \eta_1 \cos\theta_i + \eta_2 \cos\theta_t }.
\end{aligned}
}

Multiplication of the numerator and denominator by $$c/\eta_1 \eta_2$$, noting that $$c/\eta = n/\mu$$ gives

\label{eqn:emtLecture10:1700}
\begin{aligned}
r
&=
\frac{\frac{n_2}{\mu_2} \cos\theta_i – \frac{n_1}{\mu_1} \cos\theta_t }{ \frac{n_2}{\mu_2} \cos\theta_i + \frac{n_1}{\mu_1} \cos\theta_t } \\
t &=
\frac{2 \frac{n_1}{\mu_1} \cos\theta_i }{ \frac{n_2}{\mu_2} \cos\theta_i + \frac{n_1}{\mu_1} \cos\theta_t } \\
\end{aligned}

which checks against (4.38,4.39) in [1].

# References

[1] E. Hecht. Optics. 1998.

## A JCL sample, writing IO to a DATASET (mainframe filename)

November 19, 2016 Mainframe 1 comment , , , , ,

The mainframe and it’s scripting language is a weird beast. Here’s a sample of the scripting language

//LZIOTEST JOB
//A EXEC PGM=IOTEST
//SYSOUT DD SYSOUT=*
//*SYSPRINT DD SYSOUT=*
//SYSPRINT DD DSN=PJOOT.OUT6,DISP=(MOD,KEEP,KEEP),
// DCB=(DSORG=PS,LRECL=80,RECFM=FB,BLKSIZE=800)

When I see this, my gut feeling is to ignore it all, since it looks like a comment. The comments are actually the //* lines, so that is equivalent to:

//LZIOTEST JOB
//A EXEC PGM=IOTEST
//SYSOUT DD SYSOUT=*
//SYSPRINT DD DSN=PJOOT.OUT6,DISP=(MOD,KEEP,KEEP),
// DCB=(DSORG=PS,LRECL=80,RECFM=FB,BLKSIZE=800)

If I understand things properly, the commands in this particular JCL are:

• JOB (with parameter value LZIOTEST, that identifies the job output in the spool reader)
• EXEC (with parameter A, which I believe is a step name), and a specification of what to execute for that step (my IOTEST code in this case).
• DD (define an alias for a file (called a DATASET in mainframe-ese)

The SYSPRINT line associates a DDNAME “SYSPRINT” with a file (i.e. a DATASET) named PJOOT.OUT6. Creating a file seems very painful to do, requiring specification of blocksize, filetype (DSORG), record length, record format (Fixed Blocked in this case), and a DISPosition (whether to create/modify/access-shared/…, and what action to take if the JCL script succeeds or fails). Once that file is created it can then accessed by DDNAME in fopen (i.e. fopen( “DD:SYSPRINT”, …).  I have the feeling that REXX, COBOL, AND PL/1 operate on the DDNAME exclusively, and don’t require it to be prefixed with DD: as the Z/OS C/C++ runtime docs for fopen suggest.

Another oddity with JCL is that it appears to have an 80 character line limitation.  For example, the following produces JCL syntax errors.

//SYSPRINT DD DSN=PJOOT.OUT6,DISP=(MOD,KEEP,KEEP),DCB=(DSORG=PS,LRECL=80,RECFM=FB,BLKSIZE=800)

A trailing comma appears to be the required continuation character.  I don’t know if the indenting I used for DCB= matters, but suspect not.

## A wierd way to invoke the compiler

November 18, 2016 C/C++ development and debugging. 2 comments ,

Did you know that you can run the compiler from sources specified in stdin?  Here’s an example:

// m.c
#include <stdio.h>

int main()
{
int x = 3;
printf("%d\n", x);
return 0;
}


You have to specify the language for the code explicitly, since that can’t be inferred from the filename when that file data is coming from stdin:

$cat m.c | clang -g -x c - -o f$ ./f
3


This fact came up in conversation the other day. The result is something that is completely undebuggable, but you can do it! I’m curious if there’s actually a use case for this?

## Kiva, a fun alternative to standard charitable donations.

November 17, 2016 Incoherent ramblings No comments , ,

This year, when I was still at IBM, I had opted out of the IBM Employee Charitable Fund (ECF) and chose to put cash into Kiva microloans instead.  I was tired of just blindly dumping money into some big charity like United Way.  I don’t really have any idea what United Way or any other charity is doing with the money I provide.

At the time I had no idea that I wouldn’t be working at IBM for much longer.  When I left IBM and started working as a contractor for LzLabs in the spring, having made this switch already made it easy for me to continue doing so.  The only change I made I was increase the amount that I was making for my monthly Kiva funds topups.  I’m now an employee of LzLabs Canada (3 of 5 at the time of the incorporation), but since we don’t have an IBM style employee charitable fund, I am still putting funds into Kiva that I used to put into explicit registered charities.

I quite like Kiva as an alternative to standard charity. For one, it isn’t straight up charity, since I can choose to fund people who look like they are trying to improve their condition.  That’s a sustainability difference that I think is very important, and part of the trap of the welfare system.  If you reward welfare recipients by providing it unconditionally as we do, you create the welfare state.  Most of my Kiva loans have specifically targeted individuals who have some sort of business venture that they are trying to improve.  My preference has been for people that want tools or livestock (example: a milk producing cow) that will continue to provide value long after the loan is paid.

Its fun to be able to specifically choose who my funds are going to, and when the loan repayments come in, I can often recycle those repayments directly into a new loan without even waiting for my next top up period.

I don’t think that the default overhead that Kiva wants for each loan is reasonable ($3 on$25), so I lower that significantly each time.  Note that if the loan that you try to fund doesn’t get the backers required, Kiva keeps that overhead donation amount.  When I recycled funds after such an unfunded loan into a new loan, I explicitly set the corresponding Kiva donation amount to zero.

Unfortunately, I don’t think I can get a Canadian charitable tax credit for the sort of permanently recycling Kiva loans that I am doing, but it’s fun enough to see my loan portfolio grow that I don’t care too much about the tiny little tax kickback Uncle Trudeau and Aunt Wynne “give me” in exchange for me financing their spending sprees.

## Transverse gauge

Jackson [1] has an interesting presentation of the transverse gauge. I’d like to walk through the details of this, but first want to translate the preliminaries to SI units (if I had the 3rd edition I’d not have to do this translation step).

### Gauge freedom

The starting point is noting that $$\spacegrad \cdot \BB = 0$$ the magnetic field can be expressed as a curl

\label{eqn:transverseGauge:20}

Faraday’s law now takes the form
\label{eqn:transverseGauge:40}
\begin{aligned}
0
&= \spacegrad \cross \BE + \PD{t}{\BB} \\
&= \spacegrad \cross \BE + \PD{t}{} \lr{ \spacegrad \cross \BA } \\
&= \spacegrad \cross \lr{ \BE + \PD{t}{\BA} }.
\end{aligned}

Because this curl is zero, the interior sum can be expressed as a gradient

\label{eqn:transverseGauge:60}
\BE + \PD{t}{\BA} \equiv -\spacegrad \Phi.

This can now be substituted into the remaining two Maxwell’s equations.

\label{eqn:transverseGauge:80}
\begin{aligned}
\spacegrad \cdot \BD &= \rho_v \\
\spacegrad \cross \BH &= \BJ + \PD{t}{\BD} \\
\end{aligned}

For Gauss’s law, in simple media, we have

\label{eqn:transverseGauge:140}
\begin{aligned}
\rho_v
&=
&=
\end{aligned}

For simple media again, the Ampere-Maxwell equation is

\label{eqn:transverseGauge:100}
\inv{\mu} \spacegrad \cross \lr{ \spacegrad \cross \BA } = \BJ + \epsilon \PD{t}{} \lr{ -\spacegrad \Phi – \PD{t}{\BA} }.

Expanding $$\spacegrad \cross \lr{ \spacegrad \cross \BA } = -\spacegrad^2 \BA + \spacegrad \lr{ \spacegrad \cdot \BA }$$ gives
\label{eqn:transverseGauge:120}

Maxwell’s equations are now reduced to
\label{eqn:transverseGauge:180}
\boxed{
\begin{aligned}
\spacegrad^2 \BA – \spacegrad \lr{ \spacegrad \cdot \BA + \epsilon \mu \PD{t}{\Phi}} – \epsilon \mu \PDSq{t}{\BA} &= -\mu \BJ \\
\end{aligned}
}

There are two obvious constraints that we can impose
\label{eqn:transverseGauge:200}
\spacegrad \cdot \BA – \epsilon \mu \PD{t}{\Phi} = 0,

or
\label{eqn:transverseGauge:220}

The first constraint is the Lorentz gauge, which I’ve played with previously. It happens to be really nice in a relativistic context since, in vacuum with a four-vector potential $$A = (\Phi/c, \BA)$$, that is a requirement that the four-divergence of the four-potential vanishes ($$\partial_\mu A^\mu = 0$$).

### Transverse gauge

Jackson identifies the latter constraint as the transverse gauge, which I’m less familiar with. With this gauge selection, we have

\label{eqn:transverseGauge:260}
\spacegrad^2 \BA – \epsilon \mu \PDSq{t}{\BA} = -\mu \BJ + \epsilon\mu \spacegrad \PD{t}{\Phi}

\label{eqn:transverseGauge:280}

What’s not obvious is the fact that the irrotational (zero curl) contribution due to $$\Phi$$ in \ref{eqn:transverseGauge:260} cancels the corresponding irrotational term from the current. Jackson uses a transverse and longitudinal decomposition of the current, related to the Helmholtz theorem to allude to this.

That decomposition follows from expanding $$\spacegrad^2 J/R$$ in two ways using the delta function $$-4 \pi \delta(\Bx – \Bx’) = \spacegrad^2 1/R$$ representation, as well as directly

\label{eqn:transverseGauge:300}
\begin{aligned}
– 4 \pi \BJ(\Bx)
&=
\int \spacegrad^2 \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’ \\
&=
\int \spacegrad \cdot \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’
+
\int \spacegrad \wedge \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’ \\
&=
\int \BJ(\Bx’) \cdot \spacegrad’ \inv{\Abs{\Bx – \Bx’}} d^3 x’
+
\int \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’
} \\
&=
\int \spacegrad’ \cdot \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’
\int \frac{\spacegrad’ \cdot \BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’

\int \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’
}
\end{aligned}

The first term can be converted to a surface integral

\label{eqn:transverseGauge:320}
\int \spacegrad’ \cdot \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’
=
\int d\BA’ \cdot \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}},

so provided the currents are either localized or $$\Abs{\BJ}/R \rightarrow 0$$ on an infinite sphere, we can make the identification

\label{eqn:transverseGauge:340}
\BJ(\Bx)
=
+
\spacegrad \cross \spacegrad \cross \inv{4 \pi} \int \frac{\BJ(\Bx’)}{\Abs{\Bx – \Bx’}} d^3 x’
\equiv
\BJ_l +
\BJ_t,

where $$\spacegrad \cross \BJ_l = 0$$ (irrotational, or longitudinal), whereas $$\spacegrad \cdot \BJ_t = 0$$ (solenoidal or transverse). The irrotational property is clear from inspection, and the transverse property can be verified readily

\label{eqn:transverseGauge:360}
\begin{aligned}
&=
&=
&=
&= 0.
\end{aligned}

Since

\label{eqn:transverseGauge:380}
\Phi(\Bx, t)
=
\inv{4 \pi \epsilon} \int \frac{\rho_v(\Bx’, t)}{\Abs{\Bx – \Bx’}} d^3 x’,

we have

\label{eqn:transverseGauge:400}
\begin{aligned}
&=
\inv{4 \pi \epsilon} \spacegrad \int \frac{\partial_t \rho_v(\Bx’, t)}{\Abs{\Bx – \Bx’}} d^3 x’ \\
&=
\inv{4 \pi \epsilon} \spacegrad \int \frac{-\spacegrad’ \cdot \BJ}{\Abs{\Bx – \Bx’}} d^3 x’ \\
&=
\frac{\BJ_l}{\epsilon}.
\end{aligned}

This means that the Ampere-Maxwell equation takes the form

\label{eqn:transverseGauge:420}
\spacegrad^2 \BA – \epsilon \mu \PDSq{t}{\BA}
= -\mu \BJ + \mu \BJ_l
= -\mu \BJ_t.

This justifies the transverse in the label transverse gauge.

# References

[1] JD Jackson. Classical Electrodynamics. John Wiley and Sons, 2nd edition, 1975.

## Continuity equation and Ampere’s law

### Q:

Show that without the displacement current $$\PDi{t}{\BD}$$, Maxwell’s equations will not satisfy conservation relations.

### A:

Without the displacement current, Maxwell’s equations are
\label{eqn:continuityDisplacement:20}
\begin{aligned}
\spacegrad \cross \BE( \Br, t ) &= – \PD{t}{\BB}(\Br, t) \\
\spacegrad \cross \BH( \Br, t ) &= \BJ \\
\spacegrad \cdot \BD(\Br, t) &= \rho_{\mathrm{v}}(\Br, t) \\
\spacegrad \cdot \BB(\Br, t) &= 0.
\end{aligned}

Assuming that the continuity equation must hold, we have
\label{eqn:continuityDisplacement:40}
\begin{aligned}
0
&= \spacegrad \cdot \BJ + \PD{t}{\rho_\mathrm{v}} \\
&= \PD{t}{} (\spacegrad \cdot \BD) \\
&\ne 0.
\end{aligned}

This shows that the current in Ampere’s law must be transformed to

\label{eqn:continuityDisplacement:60}
\BJ \rightarrow \BJ + \PD{t}{\BD},

should we wish the continuity equation to be satisfied. With such an addition we have

\label{eqn:continuityDisplacement:80}
\begin{aligned}
0
&= \spacegrad \cdot \BJ + \PD{t}{\rho_\mathrm{v}} \\
\end{aligned}

The first term is zero (assuming sufficient continity of $$\BH$$) and the second two terms cancel when the space and time derivatives of one are commuted.

## Calculating the magnetostatic field from the moment

The vector potential, to first order, for a magnetostatic localized current distribution was found to be

\label{eqn:magneticFieldFromMoment:20}
\BA(\Bx) = \frac{\mu_0}{4 \pi} \frac{\Bm \cross \Bx}{\Abs{\Bx}^3}.

Initially, I tried to calculate the magnetic field from this, but ran into trouble. Here’s a new try.

\label{eqn:magneticFieldFromMoment:40}
\begin{aligned}
\BB
&=
\frac{\mu_0}{4 \pi}
\spacegrad \cross \lr{ \Bm \cross \frac{\Bx}{r^3} } \\
&=
-\frac{\mu_0}{4 \pi}
\spacegrad \cdot \lr{ \Bm \wedge \frac{\Bx}{r^3} } \\
&=
-\frac{\mu_0}{4 \pi}
\lr{
} \\
&=
\frac{\mu_0}{4 \pi}
\lr{
– \lr{ \Bm \cdot \lr{\spacegrad \inv{r^3} }} \Bx
+\Bm \lr{\spacegrad \inv{r^3} } \cdot \Bx
}.
\end{aligned}

Here I’ve used $$\Ba \cross \lr{ \Bb \cross \Bc } = -\Ba \cdot \lr{ \Bb \wedge \Bc }$$, and then expanded that with $$\Ba \cdot \lr{ \Bb \wedge \Bc } = (\Ba \cdot \Bb) \Bc – (\Ba \cdot \Bc) \Bb$$. Since one of these vectors is the gradient, care must be taken to have it operate on the appropriate terms in such an expansion.

Since we have $$\spacegrad \cdot \Bx = 3$$, $$(\Bm \cdot \spacegrad) \Bx = \Bm$$, and $$\spacegrad 1/r^n = -n \Bx/r^{n+2}$$, this reduces to

\label{eqn:magneticFieldFromMoment:60}
\begin{aligned}
\BB
&=
\frac{\mu_0}{4 \pi}
\lr{
– \frac{\Bm}{r^3}
+ 3 \frac{(\Bm \cdot \Bx) \Bx}{r^5} %
+ 3 \Bm \inv{r^3}
-3 \Bm \frac{\Bx}{r^5} \cdot \Bx
} \\
&=
\frac{\mu_0}{4 \pi}
\frac{3 (\Bm \cdot \ncap) \ncap -\Bm}{r^3},
\end{aligned}

which is the desired result.