• Math

    Barcodes and Modular Arithmetic

    Barcodes Here is an example of a UPC-A barcode, taken from Wikipedia: A UPC-A barcode has 12 digits.  The first digit is something that tells how the numbers are generally used – for example, a particular industry might use a certain number for certain kinds of items.  The last twelfth digit is a check digit that can be used to try to tell whether or not the numbers have an error.  This check digit is constructed in a certain way.   UPC-A Barcode Check Digit Calculation The check digit is constructed as follows: We have the first 11 digits: $$ABCDEFGHIJK$$ So let \(L\) be the last twelfth digit.  We sum the…

  • Economics,  Math

    Portfolio Insurance and Black Monday, October 19, 1987

    On the thirtieth anniversary of Black Monday, the stock market crash of October 19th and 20th in 1987, there have been mentions of “portfolio insurance” having possibly exacerbated the crash.   Portfolio insurance, in principle, is exactly what you might expect it to be: if you own a stock, Stock A, you insure it with a put option on Stock A.  Your position becomes equivalent to a call option on Stock A until the put option expires, with the price of this position being the premium of the put option when you bought it. If you are managing a portfolio on behalf of clients, though, and you just need to…

  • Economics

    Value-added Tax and Sales Tax

    (This is mostly a summary of and heavily borrowed from https://en.wikipedia.org/wiki/Value-added_tax, archived). (The first three figures are taken from Wikipedia).   Comparing No Tax, Sales Tax, and VAT Imagine three companies in a value chain that produces and then sells a widget to a consumer. The raw materials producer sells raw materials to the manufacturer for $1.00, earning a gross margin (revenue – Cost Of Goods Sold, COGS) of $1.00. The manufacturer sells its product, the widget, to the retailer for $1.20, earning a gross margin of $0.20. The retailer sells the widget to a non-business consumer (for the customer to use and consume) for $1.50, earning a gross margin…

  • Math

    Testing MathJax-LaTeX

    beforemathjax textbefore https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference Default font size. Different font size. Bold text. bold text. italic text. Italic text. Underlined text. At first, we sample $$f(x)$$ in the \(N\) ($N$ is odd) equidistant points around \(x^*\): \[ f_k = f(x_k),\: x_k = x^*+kh,\: k=-\frac{N-1}{2},\dots,\frac{N-1}{2} \] where \(h\) is some step. Then we interpolate points \((x_k,f_k)\) by polynomial \begin{equation} \label{eq:poly} \tag{1} P_{N-1}(x)=\sum_{j=0}^{N-1}{a_jx^j} \end{equation} Its coefficients \(a_j\) are found as a solution of system of linear equations: \begin{equation} \label{eq:sys} \tag{asdf} \left\{ P_{N-1}(x_k) = f_k\right\},\quad k=-\frac{N-1}{2},\dots,\frac{N-1}{2} \end{equation} \begin{equation} \label{eq:sys2} \tag{asdf2} \{ P_{N-1}(x_k) = f_k\},\quad k=-\frac{N-1}{2},\dots,\frac{N-1}{2} \end{equation} Trying WordPress default latex, no mathjax format inline: inline or not rm \(asdf \rm{rm} jkl \), textrm \(asdf \textrm{rm}…

  • Random

    The Curiously Inscrutable Principles of Trade Mechanics of Europa Universalis 4 (aka another EU4 trade guide)

    Prologue   My goal here is to explain from first principles the fundamentals of trade mechanics in EU4.  This will not attempt to be a comprehensive guide on all aspects of trade, but it does attempt to be a comprehensive guide and tutorial on the mechanics of trade nodes and merchants.  I will try to explain the system from the ground up as well as communicate an intuitive understanding and interpretation.  I will attempt to be rigorous with the mechanics but will be more brush-strokey with tactics, strategy, and modifiers (since modifiers just complicate things and in application are a part of strategy).  My hope is to explain the basics…

  • Math

    Brainteaser: The Monty Hall Problem

    You are on a game show and presented with 3 doors.  Behind one is a car and behind the other 2 are goats.  You want to choose the door with a car behind it, as if you do so, you win the car.  You choose one door.  Then, the host opens one of the other doors, which reveals a goat behind it.  The host gives you a choice to either switch your door to the other one that’s still closed or keep your original choice.  Should you switch doors?     Answer: If your strategy is to stick to your original choice, your probability of choosing the door with the…

  • Math

    Brainteaser: 100 Prisoners in a Line and Extension

    There are 100 prisoners.  An executioner tells them that tomorrow morning, he will line them up so that each of them is facing the back of the head of another prisoner, except for one prisoner at the end of the line.  In other words, prisoner 1 sees the back of the head of prisoner 2 as well as the backs of the heads of prisoners 3-100, prisoner 2 sees the back of the heads of prisoners 3-100, …, prisoner 99 only sees the back of the head of prisoner 100, and prisoner 100 doesn’t see any prisoners in front of him.  The executioner tells them that he will put either…

  • Math

    Brainteaser: Blue Foreheads

    100 people are in a room.   All 100 of them are perfect logicians. They are told that at least one person in the room has blue paint on their forehead. They are told that once you deduce that you have blue paint on your forehead, the next time that the lights are turned off, leave the room.   All 100 people have actually had their foreheads painted blue (but of course, each of them don’t know this at this point – they can only see the other people’s foreheads).  The light is turned off, then on, then off, on, etc.  What happens?     Answer: So each person sees…

  • Math

    Brainteaser: Forehead Numbers

    There are 3 people placed in a room.  They all have perfect logic.  The 3 people are told by a host that a number has been written on each of their foreheads.  Each of the 3 numbers are unique, they are all positive, and they relate to each other such that A + B = C (i.e. one is the sum of the other two).  In the room, each person can only see the other two people’s numbers, as they cannot see their own foreheads.   Suppose you are one of the 3 and you see one person with “20” on their forehead and the other person with “30.”  The…