Sekai ๐ŸŒ ๐Ÿ—บ

Sekai (ไธ–็•Œ) is the kanji for “the world”. That’s a great word because of the scale that it designates.

Line Equation in Intercept Form

LaTeX code for a TikZ figure

This is a first draft of a TikZ picture illustraing this classical formula to be used for math help channels.

Adding \caption{for the picture} without “Figure 1:” requires \usepackage{caption} and wrapping with \begin{figure}. It also possible to use the primitive TeX command \par, but it would be complicated to use that with standalone. In the previous post, the SVG picture from the LaTeX table in an article has too much useless whitespace around the table. I don’t bother to learn other packages, as I need time for other more important stuff.

[Read More]
LaTeX 

LaTeX Multirow Multicol Table Coloring

Inspiration

Number of two-digit numbers not containing the digit ‘8’.

Code

  • The standalone class can’t be used with \caption.
  • *{8}{c} means 8 c.
  • >{\columncolor{cyan}}c gives the column color. It \usepackage[table]{xcolor}.
  • \rowcolor{cyan} overrides the column colors.
  • \cellcolor{white} overrides the above two commands. It has to be carried out one-by-one without any fancy package.
  • \multicolumn{n}{<alignment>}{content} defines a multi-column cell.
  • \multirow{n}{*}{content} defines a multi-row cell. It \usepackage{multirow}. It can’t contain \multicolumn.
  • \cline{i-j} draws a horizontal line above the row from column i to column j.
  • No fancy way of coloring multirow cells without fancy packages.
  • \multirow{-9} at the last row creates a cell spanning nine rows from bottom to above, so that its content won’t be covered by colors of former rows.
  • \rotatebox[origin=[clr]]{angle}{content}: rotate content by angle anticlockwise with [clr] as the rotation center.
\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage[table]{xcolor}
\usepackage{tikz}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Sample \LaTeX{} multirow table}
\vspace*{1ex}
\label{multiprogram}
\begin{tabular}{|c|c|*{8}{c}>{\columncolor{cyan}}cc|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{}} & \multicolumn{10}{c|}{unit digit} \\\cline{3-12}
\multicolumn{2}{|c|}{} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\\hline
& 1 & &  &  &  &  &  &  &  &  &  \\
& 2 & &  &  &  &  &  &  &  &  &  \\
& 3 & &  &  &  &  &  &  &  &  &  \\
& 4 & &  &  &  &  &  &  &  &  &  \\
& 5 & &  &  &  &  &  &  &  &  &  \\
& 6 & &  &  &  &  &  &  &  &  &  \\
& 7 & &  &  &  &  &  &  &  &  &  \\
\rowcolor{cyan} \cellcolor{white}
& 8 & &  &  &  &  &  &  &  &  &  \\
\multirow{-9}{*}{\rotatebox[origin=c]{90}{tens digit}}
& 9 & &  &  &  &  &  &  &  &  &  \\\hline
\end{tabular}
\end{table}
\end{document}

Result:

[Read More]
LaTeX  table 

Upgrade Font Awesome in Beautiful Hugo Theme

Technical adjustment to Font Awesome's official guide

Background

Beautiful Hugo comes with Font Awesome icons. However, it seems that it’s no longer maintained.

Goal

To upgrade Font Awesome to the current stable version (6.1.1).

Problem

The official guide for self-hosting Font Awesome Web Fonts + CSS suggests users to place the following files

filepath role
/fontawesome/webfonts/ Free Web Fonts
/fontawesome/css/all.min.css CSS file for using Free Web Fonts

into somewhere in my theme. The left column of the diagram features the folder assets/.

[Read More]

Second Homothety between Nine-Point Circle and Circumcircle

Proof of Euler line by h(G, โˆ’1/2)

Motivation

I saw someone illustrating his/her solution with a “superior triangle”.

original picture

This reminds me the homothety about the centroid of factor โˆ’1/2.

homothety about centroid

The above picture \usetikzlibrary{calc} for computing coordinates from those of existing points. (A)!.25!(B) means $(A)+.25[(B)-(A)]$.

\begin{tikzpicture}[scale=2]
\coordinate (D) at (-0.7,1);
\coordinate (E) at (-1,0);
\coordinate (F) at (1,0);
\coordinate (A) at ($(E)!.5!(F)$);
\coordinate (B) at ($(F)!.5!(D)$);
\coordinate (C) at ($(D)!.5!(E)$);
\coordinate (G) at ($(D)!.5!(E)!1/3!(F)$);

\draw (A) -- (B) -- (C) -- cycle;
\draw (D) -- (E) -- (F) -- cycle;
\begin{scriptsize}
\fill (G) circle (0.5pt) node [left=2pt,anchor=north]{$G$};
\end{scriptsize}
\draw[->,-latex,dashed] (D) -- (A);
\draw[->,-latex,dashed] (E) -- (B);
\draw[->,-latex,dashed] (F) -- (C);
\end{tikzpicture}

Previous post

From the homothety between the nine-point circle and circumcircle about orthocenter with a factor of 2, we see that the nine-point center is the mid-point of orthocenter and circumcenter.

[Read More]

Basic Symmetries in Nine-Point Circle

Personal reading report

Motivation

Someone on Discord asked about the existence of the nine-point circle. It’s well-known that that can be proved by homothety.

Little reminder about homothety

Homothety preserves angles (and thus parallel lines). Homothetic polygons are similar, so the ratio of the corresponding sides is the same. Considering the radii of a circle under a homothety, we see that a homothety maps a circle to another circle.

Notation

  • H: orthocenter
  • G: centroid
  • O: circumcenter
  • ฯ‰: circumcircle
  • HA: feet of altitude with respect to A.
  • MA: midpoint of side a.
  • EA: Euler point with respect to A. (i.e. midpoint of A and H)

Problem

The second proof for nine-point circle on AoPS starts with a proved fact that the reflection of H about a and MA lie on ฯ‰.

[Read More]

Dvisvgm's Issue With Fill Pattern

Goal

Generate SVG file for TikZ graphics.

Method

  1. TeX โ†’ PDF with PDFLaTeX
  2. PDF โ†’ SVG with dvisvgm -P filename

Example: I generated a PGF plot from the source code on my personal template.

working SVG
working PDF
Git Bash for PDF
Git Bash for SVG

Problem

When I applied this method to the following TeX code in my previous post, dvisvgm -P returns a blank SVG.

\documentclass[tikz,border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=center,legend style={at={(0.7,0.7)},anchor=south west}]
\addplot [domain=-3:3, thick, smooth, yellow] { 1/sqrt(2*pi)*exp(-x^2/2) };
\addlegendentry{$y = \frac{1}{\sqrt{2\pi}} e^{-x^2/2}$};
\addplot [dashed, yellow] coordinates {(1.5,0) (1.5,0.14)};
\addlegendentry{99th percentile};
\addplot[domain=-3:1.5, pattern=north east lines,draw=none, fill opacity=0.3]
  { 1/sqrt(2*pi)*exp(-x^2/2) } \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}

This code passes the compiler.

[Read More]
LaTeX  dvisvgm  SVG 

To Be Improved Normal Curve

First function plot with pattern fill

Adaptations for standalone documents:

  • \usetikzlibrary{pattern} before \begin{document}
  • \pgfplotsset{compat=1.6}
\begin{tikzpicture}
\begin{axis} [axis lines=center,legend style={at={(0.7,0.7)},anchor=south west}]
\addplot [domain=-3:3, thick, smooth, yellow] { 1/sqrt(2*pi)*exp(-x^2/2) };
\addlegendentry{$y = \tfrac{1}{\sqrt{2\pi}} e^{-x^2/2}$};
\addplot [dashed, yellow] coordinates {(1.5,0) (1.5,0.14)};
\addlegendentry{99th percentile};
\addplot[domain=-3:1.5, pattern=north east lines,draw=none, fill opacity=0.3]
{ 1/sqrt(2*pi)*exp(-x^2/2) } \closedcycle;
\end{axis}
\end{tikzpicture}

tikz function shaded region

LaTeX 

Trigonometric Functions by Unit Circle

For secondary school students, I define cosine and sine as the x and y-components of the point A (cos ฮธ, sin ฮธ) on the unit circle xยฒ + yยฒ = 1, and the tangent function as the quotient of sine over cosine.

\begin{tikzpicture}[scale=3]
\coordinate (O) at (0,0);
\coordinate (H) at (0.6,0);
\coordinate (A) at (0.6,0.8);
\coordinate (E) at (1,0);
\coordinate (T) at (1,0.8/0.6);
\draw (O) circle (1);
\draw[->] (-1.3,0) -- (1.3,0) node [right]{$x$};
\draw[->] (0,-1.3) -- (0,1.3) node [above]{$y$};
\begin{scope}[thick]
\draw (O) node [below left] {$O$}
    -- (H) node [below right] {$H$}
    node [below, midway] {$\cos \theta$}
    -- (A) node [below, midway, sloped] {$\sin \theta$}
    node [above=5pt] {$A$}
    -- cycle node [above left, midway] {$1$};
\begin{scope}
    \clip (O) -- (A) -- (H) -- cycle;
    \draw (O) circle (0.1) node[right=7pt, above=5pt, anchor=west] {\small $\theta$};
\end{scope}
\draw (H) rectangle ++(-0.1,0.1);
\draw (E) rectangle ++(-0.1,0.1);
\draw (E) node [below right] {$E$}
    -- (T) node [below, midway, sloped] {$\tan \theta$}
    node [above, right] {$T$}
    -- (A);
\end{scope}
\end{tikzpicture}

sine cosine unit circle

[Read More]
LaTeX 

Matrix Diagonalisation and Change of Basis

Here’s the $\LaTeX$ code of my diagram for matrix diagonalisation to be used on Discord.

Why do matrix diagonalisation on square matrix $P$?

If we can find a diagonal matrix $D$ and a square matrix $Q$ such that $P = QDQ^{-1}$, then we can easily compute $(P + \lambda I)^n$ for any scalar $\lambda$ and integer $n$ because $D^n$ is easy to compute.

\[\begin{tikzcd}
    {{}} & {{}} & \cdots & {} \\
    {{}} & {{}} & \cdots & {{}}
    \arrow["P", from=1-1, to=1-2]
    \arrow["{Q^{-1}}"', from=1-1, to=2-1]
    \arrow["D"', from=2-1, to=2-2]
    \arrow["Q"', from=2-2, to=1-2]
    \arrow["P", from=1-2, to=1-3]
    \arrow["D"', from=2-2, to=2-3]
    \arrow["P", from=1-3, to=1-4]
    \arrow["D"', from=2-3, to=2-4]
    \arrow["Q"', from=2-4, to=1-4]
\end{tikzcd}\]

After viewing the power of the Discord bot $\TeX{}$it, which renders $\LaTeX$ code on Discord, I gave up spending more time on exploring more functionalities of $\KaTeX$ (say, commutative diagrams) because Discord and $\LaTeX$ spread math knowledge much better than a static blog for basic math: the former allows instant feedback from the reader. The later is better for taking notes. To display more complicated graphics, I can compile to PDF first, then use dvisvgm with -P for --pdf. (The small -p selects --page=ranges.)

[Read More]
LaTeX 

LaTeX Code for Linear System

\begin{align} A\mathbf{x} &= \mathbf{b} \\ \begin{pmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} &= \begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix} \\ \begin{bmatrix} \vert & \vert & \vert \\ \mathbf{a}_1 & \mathbf{a}_2 & \mathbf{a}_3 \\ \vert & \vert & \vert \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} &= \mathbf{b} \\ x_1 \mathbf{a}_1 + x_2 \mathbf{a}_2 + x_3 \mathbf{a}_3 &= \mathbf{b} \tag{$\star$} \\ \begin{pmatrix} a_{11} x_1 + a_{12} x_2 + a_{13} x_3 \\ a_{21} x_1 + a_{22} x_2 + a_{23} x_3 \\ a_{31} x_1 + a_{32} x_2 + a_{33} x_3 \end{pmatrix} &= \begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix} \\ x_1 \begin{pmatrix} a_{11} \\ a_{21} \\ a_{31} \end{pmatrix} + x_2 \begin{pmatrix} a_{12} \\ a_{22} \\ a_{32} \end{pmatrix} + x_3 \begin{pmatrix} a_{13} \\ a_{32} \\ a_{33} \end{pmatrix} &= \begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix} \end{align}

Source code:

[Read More]
LaTeX