Using SVN with Git

Once I learned Git I never wanted to go back to the days of svn. The only problem is that SVN is used almost in every linux shop I worked for. Luckily there is git-svn. With git-svn I can just import an svn repositories and use git to browse, branch, merge etc.

My typical workflow:

1) Import the repository into git.

2) Get a branch to hack on

3) Keep up with svn commits:

This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it.

This works similarly to svn update or git pull except that it preserves linear history with git rebase instead of git merge for ease of dcommitting with git svn.

This accepts all options that git svn fetch and git rebase accept. However, –fetch-all only fetches from the current [svn-remote], and not all [svn-remote] definitions.

Like git rebase; this requires that the working tree be clean and have no uncommitted changes.

4) Commit changes back to svn

sin(n) = -1 where n is an integer in radians

I saw a fun math problem on reddit the other day.

find a number n, so that sin(n)=-1, where n is an integer in radians; so sin(270 degrees) doesn’t count. Obviously it will never be exactly -1 but close enough for the difference to be lost in rounding.

\sin(\frac{3\pi}{2} + 2\pi \cdot n) = -1
I need the argument of sin function to be as close to an integer as possible. Call this integer m.
\frac{3\pi}{2}+2\pi \cdot n \approx m
Solving for \pi leads to:
\pi \approx \frac{p}{q} \approx \frac{2m}{4n+3}

If I have a rational approximation to \pi with an even numerator I can divide it by two get my m. I also have to make sure that the denominator is in the form of 4n+3.
It’s possible to use continued fractions to approximate real numbers. Here’s a continued fraction sequence for pi: https://oeis.org/A001203

The first rational approximation I learned in elementary school is 22/7 which is perfect.

> (sin 11)
-.9999902065507035

For the others I’ll have to evaluate the continued fraction to get my approximation of a simple fraction.

> (eval-terms (list 3 7 15 1 292 1))
104348/33215

> (sin (/ 104348 2))
-.9999999999848337

> (eval-terms (list 3 7 15 1 292 1 1 1 2 1 3 1 14 2 1))
245850922/78256779

> (sin (/ 245850922 2))
-.99999999999999999532
Looks like a good candidate was found.

This is the code to evaluate a continued fraction coefficients. It’s very convenient that scheme has a native rational data type.