Blog 1

Random Talk on Random Thoughts

Export PDF to SVG

| Comments |

I’ve drawn a figure in $\rm \LaTeX$ using the TikZ. However, MathJax has no support for TikZ commands. Therefore, I have to generate an SVG figure from $\rm \LaTeX$ if I need to post it on Octopress.

I had followed the example on $\rm \TeX$–$\rm \LaTeX$ StackExchange. It worked for PNG and JPG files, but not SVG files. Since the quality of SVG files is the best, I would like to include use SVG.

Adding Integrals Over Partitions

| Comments |

In the error list of FitzPatrick’s Advanced Calculus, it’s said that on p. 479, ln. 14–21, “it doesn’t seem that $\vect{P}_k$ can be chosen as indicated…” I spent some time to understand what $\vect{P}^*_k$ was.

It took me an hour to see what’s wrong with $\vect{P}_k$. It’s much easier to understand the words using figures.

Fixing Broken URLs in the Catetory List

| Comments |

(Added on AUG 20, 2014)

Since the update of Octopress source code, this post won’t make sense anymore. I can’t find a way to use MathJax in category list entries anymore because category in plugins/category_generator.rb and plugins/category_list_tag.rb have both been changed to lower case. I don’t know how to track the Ruby code to revert it.

Stop Using Git Like Subversion

| Comments |

I saw a sentence like “Git does SVN better than SVN does” long ago, but I couldn’t remember where I saw it. Searching the sentence with double quotes, I found Ben Scheirman’s one which asked Git users not to use it just like SVN, but to explore more powerful commands for branching.

Reasons for using branches:

  • Working with multiple features
  • Sharing with others
  • Merging others work conveniently

Enlarging a Rectangle Inside Another

| Comments |

$\vect{I}$ is a generalized rectangle in $\R^n$ with edges of length $l_i$. $\vect{J} \subseteq \vect{I}$ is the main character here. If the edges of $\vect{J}$ is allowed to coincide with those of $\vect{I}$, then the problem is trivial.

How about finding $\vect{J} \subseteq \interior \vect{I}$ such that $\volume \vect{I} - \volume \vect{J} < \varepsilon$?

Archimedean Sequence of Partitions of a Square

| Comments |

Suppose $f: \vect{I} \to \R^2$, where $\vect{I} = [0,1] \times [0,1]$,

\[ f(x,y) = \begin{cases} 0 &\text{if } (x,y) \in \vect{I} \land y \ge x\\ 1 &\text{if } (x,y) \in \vect{I} \land y < x \end{cases} \]

$P_k := \{0,1/k,\dots,1\}, \vect{P}_k := (P_k,P_k)$ .

It’s said that $\mathcal{U}(f,\vect{P}_k) - \mathcal{L}(f,\vect{P}_k) < 2/k$ .

However, at first, I don’t understand why there are fewer than $2k$ squares which contribute to the difference between $\mathcal{U}(f,\vect{P}_k)$ and $\mathcal{L}(f,\vect{P}_k)$. I wrongly think that only the $k$ diagonal squares make such a contribution. Actually, $\forall\,i = 1,\dots,k - 1, [i / k,(i + 1) / k] \times [(i - 1) / k,i / k]$ also causes the difference between those two Darboux sums because

\[ \begin{aligned} \inf\,\{f(\vect{x}) \mid \vect{x} \in [i / k,(i + 1) / k] \times [(i - 1) / k,i / k]\} &= f(i / k,i / k) = 0 \text{ and}\\ \sup\,\{f(\vect{x}) \mid \vect{x} \in [i / k,(i + 1) / k] \times [(i - 1) / k,i / k]\} &= 1. \end{aligned} \]

Definition of Content 0 Sets

| Comments |

Motivation

I saw a minor difference the definition of Jordan content 0 sets between two books.

Some basic definitions

I make this list for my reference only. If I’m asked the true meaning of some geometric concepts, such as boundary, by someone seriously, then I can quickly refer to this list in order to remind myself what ideas should be introduced.

My Git Command List (2)

| Comments |

Situation (TL;DR)

Since I tried to import my old WordPress posts to this blog without affecting source branch, I created a new branch called wpcom-importer branch, on which rake deploy was successfully run. However, some of my old WordPress posts contain some unusual characters, which triggered an encoding problem in Chuang’s WordPress XML to Octopress importer. Looking at rake’s error message, I feel that I’ve put the converted posts from WordPress’s XML on the right branch.

Thus, I drafted my new posts on source branch, but not on wpcom-importer branch. I then switched to wpcom-importer and deleted some unwanted parts of XML file. However, I couldn’t switch back to source branch to do another commit. As a result, I used git stash to solve the problem.

After finishing the draft, I committed the change, switched to wpcom-importer and “merged” the last change on source branch for rake preview. The reason for not running the preview command on source branch is to avoid huge changes in public folder. I’ve learnt to do the “merge” from a post published by Jason Rudolph.

Being unfamiliar with kramdown syntax for displayed math equations1, I had made some mistakes in the source code for my previous post while writing the draft on source branch.


(Last edited on JUN 19,2014)

From the network graph, I realized my mistake in understanding merging in Git. I shouldn’t manually commit the same changes on different branch, but to commit it once only on a branch and merge the commit on another branch, if the two diverging branches have no conflict.

I continued writing <posts>. Unfortunately, I had mistakenly committed the changes on wpcom-importer, instead of source branch. I would like to

  1. Remove the commit, but keep the changes in the files.
  2. “Move” the changed file from wpcom-importer to source branch.
  3. Commit the changes on source branch.
  4. Merge the changes from source branch into wpcom-importer.

I issued the following commands to do so.

$ git reflog                   # For checking purpose
$ git reset --soft HEAD^       # Revert to the previous commit
$ git log -3                   # For checking purpose
$ git status                   # `<post>' should be in `... not staged for commit'
$ less <post>                  # For checking purpose
$ git reset HEAD <post>        # Unstage `<post>' for commit
$ git checkout source          # Go to the correct place for the commit
$ git add <post>               # Add back `<post>' to `source' branch
$ git commit -am "<msg>"       # Do the commit on the correct branch
$ git checkout wpcom-importer  # Go back to another branch for merging
$ git merge source             # Merge the changes back

The little list

Stashing and Grabbing

“Stash” means going to another branch with uncommitted changes in the staging area here.

This list written in Chinese is a quick summary of Git commands. I learnt the use of git stash commands from there.

$ git stash                      # save the uncommitted changes
$ git stash list                 # show a list of stashes
$ git stash show                 # inspect a list of stashes
$ git stash pop                  # apply and discard the topmost stash
$ git stash apply                # apply but don't discard the topmost stash
$ git checkout source -- <file>  # copy the file from other branch

In the last “merge” command, -- avoids an ambiguity since source can be either the name of a branch or a folder in this case. In addition, this command doesn’t affect the commit history.

More about rewinding things

Rewinding to previous versions on the same branch

Here’s more commands about reseting the working tree to previous versions.

$ git reset --soft HEAD^   # Revert to the previous commit without changing the files
$ git reset --hard HEAD~2  # Take a further step back from `HEAD' and discard all changes in the files in the disappeared commits

Difference between resetting and reverting things

In the manual of git reset, I saw a link togit revert, and couldn’t understand the difference between those two command from there.

If you want to undo a commit other than the latest on a branch, git-revert(1) is your friend.

A page in Stack Overflow is really my friend. (URL) git revert won’t overwrite the commit history, so it’s suitable for published changes, while git reset can rewrite history.

Undoing merges

See Undo a merge or pull and the following section in the manual of git reset for explanations.

Undoing conflicted merges

The SCM will say:

Automatic merge failed; fix conflicts and then commit the result.

Thus, the problematic merge hasn’t been committed. Simply running git reset --hard will solve the problem.

Undoing successful automatic merges

Use ORIG_HEAD instead of HEAD for the tip of the branch before the merge. (i.e. git reset --hard ORIG_HEAD)

Using git-diff for merging commits

(Added on JUN 20, 2014)

A shortcoming of “..”

To forsee possible conflicts in git merge, one may run git diff <branch1>..<branch2> to see the differences between two diverged branches. However, the diff hunk doesn’t show the additions and deletions on each branch. A - in the diff hunk can be caused by either

  1. Addition of contents in <branch1>; or
  2. Deletion of contents in <branch2>.

Running git merge <branch1> on <branch2> gives different results in different cases.

  1. The line starting with - in the diff hunk will be inserted into <branch2>.
  2. The line starting with - in the diff hunk won’t be inserted into <branch1>.

In order to predict whether there will be a conflict, one needs to know the changes done on each branch. Therefore, one needs to compare the tip of each branch with their common ancestors.

Let me illustrate this by two examples.

Example 1

One has a file like this.

Parent of the two branches
1
2
3
line 1
line 2
line 3

Then it diverged into two branches.

Branch 1 (line 1 deleted)
1
2
line 2
line 3
Branch 2 (line 2 deleted)
1
2
line 1
line 3

Running git diff <branch1>..<branch2>, one gets

+line 1
-line 2
 line 3
Example 2

One has a file like this.

Parent of the two branches
1
line 3

Then it diverged into two branches.

Branch 1 (line 2 inserted)
1
2
line 2
line 3
Branch 2 (line 1 inserted)
1
2
line 1
line 3

Running git diff <branch1>..<branch2>, one gets

+line 1
-line 2
 line 3

Observation: The diff hunks in the two examples are the same, even though their common ancestors and changes in files are different.

Overcoming the shortcoming

From the above sub-section, it’s clear that one needs to compare the tip of each branch with the common ancestor of the two branches. To see how <branch1> has been modified, git diff <branch2>...<branch1> can be used to compare the tip of <branch1> with the common ancestor of <branch1> and <branch2>.


  1. The official kramdown syntax documentation. (URL

Injectivity of Stable Mappings

| Comments |

Two weeks ago, I revised calculus and read the proof of the Inverse Function Theorem in the calculus textbook that I was reading.1 The Nonlinear Stablity Theorem is first applied to a continuously differentiable function $\vect{F}: \mathcal{O} \to \R^n$, where $\mathcal{O}$ is an open subset of $\R^n$ and contains a point $\vect{x}_*$ at which $\det \vect{DF}(\vect{x}_*) \ne 0$, to construct a neighbourhood $U$ of $\vect{x}_*$ and find $c > 0$ such that $\norm{\vect{F}(\vect{u})-\vect{F}(\vect{v})} \ge c \norm{\vect{u} - \vect{v}}\quad\forall\,\vect{u},\vect{v} \in U$.

It’s said that if $V := \vect{F}(U)$, then $\vect{F}: U \to V$ is bijective. The surjectivity is obvious, but I wasn’t smart enough to see the injectivity immediately. After a week, I realised that I overlooked the discussion about invertible linear operators on $\F^n$ that preceeded the introduction to the idea of stable mapping. In fact, $\forall\,\vect{u},\vect{v} \in U,\vect{F}(\vect{u}) = \vect{F}(\vect{v}) \iff \norm{\vect{F}(\vect{u}) - \vect{F}(\vect{v})} = 0$.

Then $\norm{\vect{u} - \vect{v}} \le \norm{\vect{F}(\vect{u}) - \vect{F}(\vect{v})} / c = 0 \iff \vect{u} = \vect{v}$.


  1. FitzPatrick’s Advanced Calculus 

An Unreported Mistake in "Advanced Calculus"

| Comments |

After setting up Octopress for several weeks, I can finally begin to write some math. The errors of FitzPatrick’s Advanced Calculus can be found at Walla Walla University.

Two weeks ago, I found a mistake in the book that wasn’t in the error list. In p. 430, ln. -3, the ‘<’ sign should actually be a ‘≤’, since it’s given that .