Blog The life and ramblings of just another data scientist.

Understanding the Reflection Coefficient

Today I hope to answer a rather complex question: What does the Reflection Coefficient mean exactly, how do we measure it, and what can we do with it once we do. For example if we have a reflection coefficient of \(0.5 \angle 30^{\circ}\) at at some point in a feedline what does that mean and how can we use it?

There is a lot to unpack in such a short question, there are many things the reflection coefficient can tell us on its own, and quite a few more things it can tell us when we know a few other variables.

In simplest english terms it means that the reflected wave is half the peak voltage of the forward wave, and that at any moment the reflected wave is 30 degrees ahead in its phase compared to the forward wave. So if measured on an oscilloscope comparing the waves would look something like this.

Keep in mind the waves on an oscilloscope would both be moving to the right on the display at the same speed, so they will always have the same orientation relative to each other. Meanwhile the actual waves in the feedline are moving in opposite directions so their peaks are constantly moving away from each other. Consequently this is why the phase relationship between the two waves will vary depending on the position you measure it at.

Here is what the actual waves would look like in the feedline where the x-axis here would be the position on the feedline (not to be confused with the above image that you would see on an oscilloscope).

So imagining the above image is voltage we see the green wave moving in one direction on the feedline and the blue wave moving in the opposite direction. The redline is the actual voltage at the respective point on the feedline as it changes with time. The situation here is what you would see if the far end of the feedline where the antenna should be had either an open connection or was short circuited. The red wave we see is what we call a Standing Wave. So what we are really doing when we measure the reflection coefficient is we measure the red wave in the above image at a particular point in the feedline for voltage, then do the same for current, and by comparing the two

Now let's talk a little about how knowing the reflection coefficient is useful and how you can calculate it.

Calculating \(\Gamma\)

As was already pointed out the reflection coefficient tells you the signal that is reflected relative to the forward signal. So per the example I gave at the begining you would say:

$$ \Gamma = 0.5 \angle 30^{\circ} $$

The above is in polar form but its good to remember this is little more than a complex number closely related to phasors (both voltage and current phasors). In complex form we have:

$$ \Gamma = 0.43 + 0.25 i\mkern1mu $$

Now the first thing it can tell us other than the relationship between forward and reverse voltage signals is it can also tell us the relationship between forward and reverse current signals. The relationship being the same but of opposite sign.

$$ \Gamma = -\frac{I_{refl}}{I_{fwd}} = \frac{V_{refl}}{V_{fwd}} $$

Where \(I\) and \(V\) are their respective current and voltage phasors. Remember a phasor represents the amplitude and phase of the signal relative to some reference point, usually whatever we consider ground. So from this it tells us that in our example the reflected current signal will have an amplitude of 0.5 relative to the forward current and a phase of 210 degrees, or -150 degrees whichever you'd like.

Calculating SWR from \(\Gamma\)

The other thing we can calculate directly from the reflection coefficient is the SWR, which is no longer a complex value, it's a dimensionless ratio. We lose a bit of information (the complex part) in doing this conversion but it is often a useful number used in tuning radio systems. I will explain exactly how SWR is helpful in a minute but first let's show how to calculate it.

$$ SWR = \frac{1 + \mid \Gamma \mid}{1 - \mid \Gamma \mid} $$

So again taking the initial example we would have the following SWR:

$$ SWR = \frac{1 + 0.5}{1 - 0.5} $$

$$ SWR = \frac{1.5}{0.5} $$

$$ SWR = \frac{3}{1} $$

So we would say here we have an SWR of \(3:1\) . SWR basically tells us how bad of a mismatch we have without worrying about if the mismatch is resistive or reactive. In a perfectly matched system there would be no reflected wave so your SWR is always 1:1 and thus shows us a perfect impedance match. Similarly the worst possible match we could have would be an open circuit or a short circuit, both of which would produce an infinite SWR.

Now its important to note it only tells us about what the impedance match is at the point in the circuit we measure. With a 1:1 SWR or a reflection coefficient of 0 telling us that whatever feedline and antenna is on the load end of the meter as a whole is the same impedance as the feedline and transmitter system on the source side of the meter. By itself it tells us nothing about if the antenna is well matched or well tuned, or the efficiency of the system, or even what the SWR might be at any other point in the feedline. To figure out any of that we would either need to measure at multiple points or need some more information about the components in the system.

Typically SWR meters, and therefore indirectly the reflection coefficient, is useful if it is measured at the point where a transmitter connects to a long feedline which ultimately feeds some load (usually an antenna). A large mismatch at this point will cause any power a transmitter creates intended for the antenna to be reflected back into the transmitter at its outgoing port rather than making it onto the feedline. This causes that energy to be dissipated by the transmitter and ultimately will heat up the transmitter and in some cases can fry it. So it is important to have an SWR that is relatively low for the safety of the transmitter.

Relationship of Load and Source Impedance

From this point on I want to be clear on some terminology I am about to use. If I say "load impedance" I will be talking about the total impedance of the system from the point the reflection coefficient was measured all the way to the far end of the transmission line. This means we are talking about the impedance of that whole half of the system, usually a transmission line, antenna, and maybe even a tuner. It does not refer to just what is connected at the end of the transmission line itself (usually the antenna), we will get to that later. Similarly when I say "source impedance" I will also be talking about the whole system on the transmitting side of where the reflection coefficient was measured.

So with that said the other thing the reflection coefficient tells us is the relationship between the load impedance and the source impedance. The equation for that is as follows:

$$ \Gamma = \frac{Z_L - Z_S}{Z_L + Z_S} $$

Therefore if we have a transmitter that connects directly to our meter and the transmitter has a \(50\Omega\) antenna port on it then we know the source impedance is \(50\Omega\) and can then calculate the impedance of our load. So again going back to the initial example if given the situation I just explained we would calculate the load impedance as follows:

$$ \Gamma = \frac{Z_L - 50}{Z_L + 50} $$

$$ Z_L = \frac{-50 \cdot (\Gamma + 1)}{\Gamma - 1} $$

Note that if \(\Gamma\) is one the equation is undefined, but that would mean the load impedance is infinite, an open circuit.

$$ Z_L = \frac{-50 \cdot (0.43 + 0.25 i\mkern1mu + 1)}{0.43 + 0.25 i\mkern1mu - 1} $$

$$ Z_L = \frac{-50 \cdot (1.43 + 0.25 i\mkern1mu)}{-0.57 + 0.25 i\mkern1mu} $$

$$ Z_L = \frac{-71.5 - 12.5 i\mkern1mu}{-0.57 + 0.25 i\mkern1mu} $$

$$ Z_L \approx 97.1347 + 64.5328 i\mkern1mu $$

$$ Z_L \approx 116.6174610 \angle -146.401367^{\circ} $$

Relationship of Feedline Length and Phase

If we know the position on the feedline that we measured the signal relative to the far end of the load, where the antenna normally is, then we can calculate a few other meaningful things. Keep in mind in the real world the speed at which an electrical signal travels through the feedline is close to the speed of light but not quite. Each feedline is a bit different and we would look at a datasheet for our particular feedline to get what is called the Velocity Factor. This is a percentage or ratio that tells us the percentage of the speed of light a wave will propagate through the feedline. So we would calculate the actual speed of our waves as follows.

$$ c = C \cdot V_f $$

Because of this not only will the wave move slower through the feedline but it will also have a shorter wavelength than what it would when propagating through a vacuum. Let's look at the equation for wavelength real quick.

$$ \lambda = \frac{c}{f} $$

Where c is the speed of the wave through the medium as we calculated above and f is the frequency, giving us \(\lambda\) as our wavelength.

When talking about a reflection coefficient we are talking about the reflected wave relative to the forward wave. So we can consider the forward wave as our reference wave and take that as our phase reference point. We know that the reflected wave needs to travel from the point being measured to the far end of the load side and then back again, so it travels a total of twice the distance of the load side. Therefore we can calculate the phase shift with the following equation.

$$ \phi = { \frac{2 \cdot l_L}{\lambda} } \cdot 360^{\circ} $$

Where \(l_L\) is the length from the point being measured to the far end of the load, \(\lambda\) is the adjusted wavelength from earlier, and \(\phi\) is the difference in phase shift of the reflected wave relative to the forward wave. Also the curly brackets is a mathematical notation saying to take the fractional part (drop the whole number and just keep the decimal). As you can see by varying the length of the transmission line on the far side of the load we can vary the phase as we wish and thus modify our reflection coefficient to some extent.

Measuring \(\Gamma\)

One very important thing to point out here, because this is where a lot of people get things wrong. Since we are measuring a single point in the feedline we are measuring the sum of the actual forward and reverse waves at that point and we can't measure the two waves directly, all we know is how the voltage and current is changing at that one point in the line. So to say we are measuring the reflected wave at all is a bit of a lie, we are really just measuring the voltage and current values at a single point and then reconstructing the forward and reverse waves from that. While this may confuse your current understanding this is very important because this is where almost everyone goes wrong on understanding these concepts. But keep in mind just because we cant measure them directly, the two waves are still there. The following is a schematic showing a circuit called a Directional Coupler, this is how we would measure the forward and reverse waves at a point in the feedline.

Notice from the above schematic all we are really doing is Sampling the forward current with \(X_1\) and sampling the forward voltage with \(X_2\) and then biasing the forward signal by the reflected and vice versa. This is how we reconstruct forward and reverse signals when all we know is the voltage and current at a single point.

Imagine we have a perfectly matched system where the characteristic impedance of the feedline is the same as the load and source impedance. What we would see is only a single forward moving wave, no reflected wave at all. Also, if you recall a resistor always has its current in phase with its voltage, this holds true in a matched feedline as well since all the components are real resistance with no reactance. So we would expect the forward voltage wave and the forward current wave to both be in phase without any reflected wave to interfere with them. Looking back at the above schematic we see that the \(X_2\) transformer would sample the forward voltage, which would cause the FWD output to cycle through positive and negative while the other terminal would want to swing the opposite, when fwd is high the other terminal will try to go negative, however its biased by the refl power, so we have to consider that as well. Since current is in phase and the \(X_1\) transformer is similarly going to swing inphase with the fwd port but since its connected to the opposite terminal of \(X_1\) it will essentially cancel out and the reflected port will stay at ground. However if the phase of the current and voltage were not the same then the circuit would respond very differently and we would see a signal out of the reflected port. So really the circuit is measuring the phase difference between voltage and current and using this to reconstruct the forward and reverse waves.

As an example here is what the voltage and phase relationship would look like in a feedline with an open circuit at the antenna end:

As we know impedance in its polar form has an amplitude and a phase component just like our reflection coefficient does. The phase component of an impedance value basically just tells you if you apply a voltage signal across the device how much the voltage and current signals will be out of phase with each other. A resistor always has an impedance that is equal to its resistance and has no imaginary component, and also has a phase of 0 degrees. This agrees with what I said earlier regarding a resistors voltage and current always being inphase with each other. We also know that a capacitor and the inductor always has its current 90 degrees out of phase with its voltage.

We just learned from the above schematic that the voltage-current relationship is in fact equivalent to the forward-reflected wave relationship. One can be used to determine the other and vice versa. Therefore we know that the impedance of the antenna can not just affect the amplitude of the wave it reflects back, but can also dictate its phase.

Feedline as an Impedance Transformer

We mentioned earlier how the reflection coefficient can be calculated by simply knowing the total impedance on one side of the point being measured vs that on the other side. I also pointed out how the load impedance in that calculation described the entire system on the load side including the feedline and wasn't necessarily the same as the load at the terminating end of the feedline, usually an antenna. Since we now know that the impedance of the antenna dictates not just the amplitude of the wave reflected, but also its phase, and we also know that the length of the feedline itself can shift the phase as well, it should be obvious that we can view a transmission line as an impedance transformer where the impedance of the antenna is transformed into a different impedance based on the length of the transmission line.

In essence we can tweak the load end of the transmission line by making it longer up to one wavelength and as such adjust our reflected wave's phase to whatever value we want, thus allowing us to change the reflection coefficient we see which is equivalent to changing the load side's impedance.

Going back to our original example if the reflected wave is 30 degrees out of phase lets see what would happen if we brought it inphase to 0 degrees. To do that lets calculate the length change of the feedline we would need, we will assume we are working with a wavelength of one meter.

$$ \phi = { \frac{2 \cdot l_L}{\lambda} } \cdot 360^{\circ} $$

$$ -30^{\circ} = \frac{2 \cdot l_L}{1} \cdot 360^{\circ} $$

$$ \frac{-30^{\circ}}{360^{\circ}} = 2 \cdot l_L $$

$$ \frac{-30^{\circ}}{2 \cdot 360^{\circ}} = l_L $$

$$ \frac{-1}{24} = l_L $$

So we know that if we subtract \(\frac{1}{24}\) of a meter off we will get the desired effect, or of course we could add \(\frac{23}{24}\) of a meter and get the same effect. This would change our reflection coefficient to:

$$ \Gamma = 0.5 \angle 0^{\circ} $$

or

$$ \Gamma = 0.5 + 0 i\mkern1mu $$

What is interesting is, as I said, this also changes what the load impedance looks like (the feedline plus antenna). Where before the impedance appeared mostly resistive with a small reactive component it now looks indistinguishable to our meter as a purely resistive load impedance, albeit still a mismatched one though. If we take our impedance equation from earlier and calculate it for our new reflection coefficient we can see exactly what that would be.

$$ Z_L = \frac{-50 \cdot (\Gamma + 1)}{\Gamma - 1} $$

$$ Z_L = \frac{-50 \cdot (0.5 + 1)}{0.5 - 1} $$

$$ Z_L = \frac{-50 \cdot 1.5}{-0.5} $$

$$ Z_L = \frac{-75}{-0.5} $$

$$ Z_L = 150 $$

So we effectively changed the old impedance of the load side from \(116.61 \angle -146.40^{\circ} \Omega\) to just \(150 \Omega\) , pretty neat.

Similarly we can look at this slightly differently. We can say if we know the feedline's length, and the complex impedance of the antenna, then what would be the impedance we see if we measure the antenna through the feedline. For that the equation is as follows:

$$ Z_L =  Z_0 \cdot \frac{Z_{ANT} + Z_0 \cdot \tan(\frac{2\pi}{\lambda} \cdot l) i\mkern1mu}{Z_0 + Z_{ANT} \cdot \tan(\frac{2\pi}{\lambda} \cdot l) i\mkern1mu} $$

Where \(Z_L\) is the impedance measured through the feedline, \(Z_0\) is the characteristic impedance of the feedline, \(l\) is the length of the feedline, \(\lambda\) is the wavelength of the signal in the feedline, and \(Z_{ANT}\) is the impedance of the antenna at the far end of the feedline, or some other load.

Rotations in N dimensions

Several years ago I was writing a Machine Learning paper that required me to do rotations in an arbitrary number of dimensions. As such I had an entire section of the paper devoted to explaining how that was done before moving on to the actual algorithm. Here I extracted the portion where I explain N-dimensional rotations, basically rotations in 4-dimensional space or higher, and created its own PDF out of it. I hope this will be of use to some of you to help explain the process. Its a bit math-heavy but I am, as always, happy to answer any questions.

    / [pdf]

Nodal Analysis Tutorial

Nodal Analysis is a technique for circuit analysis where each node (A point where two or more components are connected) is interpreted individually. This analysis can be used to determine the voltage, or any other variable, at any point in the circuit, sometimes as a function of time. It is based on the fact that at any node all the current that enters the node will be equal to all the current leaving that same node. By doing this we are able to reduce each node to an equation, and then, the entire circuit to a set of simultaneous equations.

Identifying nodes

First you need to learn how to identify nodes in a circuit. A node is simply the junction where two or more components are connected by wire. The following diagram shows a circuit where the nodes are circled in red:

Analyzing a node

The next step is to represent each node in your circuit as an equation. If you are doing an analysis in the time domain then this is usually represented as voltage as a function of time \(V(t)\). This can also be done in the frequency domain using Phasors. For this example we will work in the time domain. Let's use the same circuit as the one above:

First we need to assign arbitrary directions for the current flow in and out of each component on the circuit. It doesn't need to match the direction the actual current flows because if we reverse it then the values we get for the current through that component will just come out to be negative. What is important is that if current goes in one side of a component it goes out the other side. Other than that it's completely arbitrary. So lets pick some random directions for the current flow in our diagram:

You probably also noticed the ground point. This is also arbitrary, you can pick any node in the circuit as your ground. Mathematically you represent whatever node you pick as ground to be 0 volts. Depending on which point you pick as ground it will effect the voltage values you get for the other nodes, but they will all be the same relative to each other.

Lets assume \(I_{1}\) varies with time. Therefore it will be represented as a mathematical function: \(I_{1}(t)\). Now lets look at each node individually and represent them as mathematical functions. In addition let's assign a variable to each node representing that node's voltage.

First let's look at the upper left node labeled \(V_{1}\), the one connecting \(I_{1}\), \(R_{1}\), and \(C_{1}\). It has three paths for current to flow in/out from each of the three components. We know these three currents will add up to zero because all the current coming into the node (positive values) must equal all the current exiting the node (negative values). With this knowledge we can represent the node mathematically.

The current coming in from \(I_{1}\) is easy, since this is a current source that varies with time it is simply \(I_{1}(t)\).

We then need to consider the current coming into the node from \(R_{1}\). Since we know Ohm's Law which states \(I=V/R\) we can represent the current flowing through \(R_{1}\) in these terms. Since \(V_{4}\) is our ground point it will always have a voltage of 0. Therefore the current flowing through \(R_{1}\) is simply:

$$ \frac{0-V_{1}(t)}{R_{1}} $$

Now the current through \(C_{1}\) is a bit more tricky since we need to use differential equations to model a capacitor in the time domain. The differential equation representing the current flowing through a capacitor is:

$$ I=C\frac{,dv}{,dt} $$

Therefore we represent the current through \(C_{1}\) as:

$$ C_{1}\frac{,d}{,dt}(V_{1}(t)-V_{2}(t)) $$

Remembering that the sum of these three currents will equal zero we come up with the equation:

$$ I_{1}(t)+\frac{0-V_{1}(t)}{R_{1}}-C_{1}\frac{,d}{,dt}(V_{1}(t)-V_{2}(t))=0 $$

The final step is to get this into a function representing the node's voltage as a function of time, in other words \(V_{1}(t)\). To do this we just use some calculus and differential math to solve for \(V_{1}(t)\) in the above equation. Teaching calculus is outside the scope of this document so we will leave it to the reader to solve for \(V_{1}(t)\). Once we solve for \(V_{1}\) we get the following:

$$ V_{1}(t)= \frac { ( \int\limits_0^t ( e^{-\frac{t}{C_{1}R_{1}}} ( I_{1}(t)+C_{1} ( \frac{,d}{,dt}V_{2}(t) ) ) ) ,dt )e^{\frac{t}{C_{1}R_{1}}} } {C_{1}} $$

We now know the voltage of this node (\(V_{1}\)) as a function of time. The only problem is that this function also seems to depend on the voltage functions for the other 3 nodes. That's why the next step is to obtain the voltage as a function of time for the other 3 nodes in the same way we did for this node. Once we do that we will have 4 simultaneous equations and we will have what we need to solve for any variable we want.

Lets quickly go through and perform nodal analysis on the other 3 nodes starting with node \(V_{2}\):

$$ C_{1}\frac{,d}{,dt}(V_{1}(t)-V_{2}(t))+\frac{V_{3}(t)-V_{2}(t)}{R_{2}}=0 $$

Solve for \(V_{2}(t)\) to get:

$$ V_{2}(t)=\frac{(\int\limits_0^t (e^{\frac{t}{C_{1}R_{2}}}(C_{1}R_{2}(\frac{,d}{,dt}V_{1}(t))+V_{3}(t))),dt)e^{-\frac{t}{C_{1}R_{2}}}}{C_{1}R_{2}} $$

The last two nodes will be much simpler since they don't connect to the capacitor, therefore we don't need to deal with differential equations. For \(V_{3}\) we get:

$$ -\frac{V_{3}(t)-V_{2}(t)}{R_{2}}+\frac{0-V_{3}(t)}{R_{3}}=0 $$

Solve for \(V_{3}(t)\) and you get:

$$ V_{3}(t)=\frac{R_{3}V_{2}(t)}{R_{3}+R_{2}} $$

For node \(V_{4}\) we already know its value is 0 so we can skip this node all together.

We now have 3 simultaneous equations, one for each node of the circuit (except ground). In the next section we will use them to solve for the voltage at any point as a function of time.

Bringing it all together

The rest of the process should be pretty apparent right now if you're familiar with solving for simultaneous equations. Since this isn't meant to be a math tutorial we won't go into the details on how to solve simultaneous equations.

There are basically two approaches to simultaneous equations. Either substitution, which is more tedious but doesn't require any advanced math, or linear algebra matrices. Generally if you aren't familiar with linear algebra and are doing it by hand you're gonna want to use substitution, which is the same as the process in basic algebra. However if you are familiar with linear algebra and plan to use a calculator to get your answer then matrices are much easier to work with.

The first step is to assign some values to our components (normally this is done for you of course):

$$ C_{1}=\frac{1}{100000} F $$

$$ R_{1}=100 \Omega $$

$$ R_{2}=1000 \Omega $$

$$ R_{3}=10000 \Omega $$

Similarly we need to define the function governing the current source. We will use a simple sinusoidal current source:

$$ I_{1}(t)=sin(t) $$

Since the scope of this tutorial doesn't include calculus we will show the quick way to do this in maple. To solve for multiple simultaneous equations in maple simply use the dsolve command like this:

dsolve({<equation 1>,<equation 2>,...<equation n>},[<unknown 1>, <unknown 2>,...<unknown n>])

Maple will now produce the three independent functions for the 4 nodes. When we plug the values for the components in and solve for the various nodes simultaneously we get the following equations:

$$ V_{1}(t)=100 sin(t)-\frac{100}{111} e^{-\frac{1000}{111}t}(\int\limits_0^t (cos(t)e^{\frac{1000}{111}t}) ,dt) $$

$$ V_{2}(t)=\frac{11000}{111} e^{-\frac{1000}{111}t}(\int\limits_0^t (cos(t)e^{\frac{1000}{111}t}) ,dt) $$

$$ V_{3}(t)=\frac{10000}{111} e^{-\frac{1000}{111}t}(\int\limits_0^t (cos(t)e^{\frac{1000}{111}t}) ,dt) $$

Thats all there is to analyzing a circuit in the time domain!

Frequency Domain Circuit Analysis Tutorial

Some time back I started writing a book in an attempt to help explain how to do circuit analysis by hand. Originally it was going to include both time-domain analysis as well as frequency-domain analysis. The book is incomplete and I never got to cover the time-domain but has several complete examples showing frequency-domain analysis on many common circuits. I’ve gotten some compliments over the years, particularly from HAM radio operators, on how useful the book has been to them. I’d like to share here what I have so far in case anyone might find it useful.

As a side note if anyone would like to revive the project and work with me on expanding and completing the book it would be most welcome. Please feel free to contact me. In the meantime here is the compiled book in its current form. I don’t currently have the latex source code published anywhere but if there is any interest I will happily publish it and open-source it on github.

    / [pdf]

Latex PDF from Markdown

I write a lot of technical documents, and it is important to me that they look nice. In the past I have always resorted to using latex directly. It's an ugly language, hard to maintain, but it has always been the best solution. Microsoft Word completely fails at complex documents, and is tedious and buggy if you want to do anything technical with it. If I have a simpler document without much math or special formatting I've always used Markdown.

Recently however I was able to get the best of both worlds. Using R-script's flavored Markdown it adds a tremendous amount of power to Markdown. The most important feature is the fact that it uses pandoc in order to compile your Markdown text into a latex template which is then used to compile a PDF. This means I get all the power of latex with all the simplicity of Markdown. That alone made it a winner for me, but it also allows you to compile into HTML and a number of other formats which can make it even more useful.

It also has one other very sweet added bonus if you don't mind coding in R-Script: you can put R-script code directly into your markdown in order to produce charts or other output programmatically. R-script is a heavily math oriented programming language so it can be extremely powerful when writing math papers.

Getting Started

If you want to get started using R-flavored Markdown to compile into latex and PDF I have provided my templates on GitHub. I also have another GitHub repository where I provide a complete example of a markdown document and makefile that will compile it into a PDF. Really simple to figure it out, just clone the repository and start editing it. Make sure, of course, that you have R-script installed and all the prerequisites you might need. Finally I also have a third GitHub repository with even more templates and examples. Some of the examples go in depth on showing how you can use r-script inside the Markdown to generate plots and graphs or other data. Worth a look there are templates for CVs/resumes, articles, powerpoint presentations, syllabus, etc.

R-flavored Markdown files use the extension "Rmd" and use all the conventional Markdown syntax with some additions. All you need to do is add some front-matter to the begining of the Markdown file which provides some hints to the latex template to do some formatting. The front-matter looks like the following, taken directly from the example I linked. The rest of the content of the file is just the Markdown, very simple. You can see the full file with front-matter and Markdown as used in this example by clicking the link.

output:
  pdf_document:
    citation_package: natbib
    keep_tex: true
    fig_caption: true
    latex_engine: pdflatex
    template: templates/syncleus-white.tex

# Required properties
title: "Conditional Probabilities and Bayes Theorem"
abstract: "A simple explanation of conditional probabilities."
author:
  name: Jeffrey Phillips Freeman
  affiliation: Syncleus
  correspondence: jeffrey.freeman@syncleus.com

# Optional Properties
other-authors:
- name: John Doe
  affiliation: NoTech
tags: Statistics, Math
start-date: "April 6, 2017"
date: "`r format(Sys.time(), '%B %d, %Y')`"
draft: "`r format(Sys.time(), '%B %d, %Y')`"
revision: 1.1
tocdepth: 5
title-color: 0,0,90
# No indentation
indent: 0pt
parskip: 3mm
# Standard Anglo-american indentation
#indent: 15pt
#parskip: 0mm
archive: Pseudoscience Journal of America
geometry: left=2cm, right=2cm, top=2.25cm, bottom=2.25cm, headheight=13.6pt, letterpaper
bibliography: ./probabilities.bib
biblio-style: plainnat
biblio-title: References

Below you will see the output of the compiled pdf using this example, different temples can give different layouts and formatting.

    / [pdf]

In the above examples you can see how the date properties are generated dynamically as the current date using R-script. This gives you just a small taste of how you can use R-script directly inside the Markdown files. Most of the properties above are self explanatory but let me provide a few descriptions for clarity all the same.

  • title - The title of the document.
  • abstract - A few sentences describing the document used int he abstract box once rendered.
  • author - Information about the author
  • other-authors - Optional supplemental authors.
  • tags - optional list of keywords.
  • start-date - Date the author began working on the paper. This is used int he copyright information.
  • date - Date the paper was released, this is used int he copyright information.
  • draft - Optional text which will appear in a Draft watermark on the paper. If this property is left out then no draft watermark will be added.
  • revision - The revision version number of the paper displayed int he upper right corner.
  • tocdepth - The maximum depth displayed int he table of contents for nested sections.
  • title-color - 3 comma separated integers from 0 to 255 representing the RGB color of the title text.
  • indent - The size of the paragraph indentation.
  • parskip - The vertical distance between paragraphs.
  • archive - The name of the journal or archive the paper is to be published in.
  • geometry - Optional parameters that overrides the latex geometry, useful for setting custom margins.
  • bibliography - location of the natbib or bibtext bibliography file.
  • biblio-style - Optional override for the bibliography style.
  • biblio-title - The title used for the bibliography section.

Thats really all there is to it. One last thing, I made sure the properties I picked for my template match those expected in a middleman blog written in markdown. This adds some convenience that the same source file can be compiled by either Middleman or R-script.