Difference » Hummus and Magnets
Difference
by Christian Plesner Hansen Posted on October 14, 2012
This is my second post in a series about Babbage's mechanical calculating engines. The first post
was about why it was so important in the early 1800s to be able to produce accurate arithmetic
tables and ended with what I'll be generous and call a cliffhanger: that Babbage's difference
engine was a groundbreaking solution to that problem. In this post I'll explain how the difference
engine works, how to “code” it and how to interpret what you get back.
これはバベジの機械式計算機械に関する二番目の投稿です。初回の投稿では 1800年代初めにおいて正確な数表
を生成できるようにすることがいかに重要であったかについて、そしてバベジの階差機関はその問題に対する
graoundbreaking solution であったことを述べました。今回の投稿では階差機関がどのように動作するか、
どのように“code”するか。そして得られたものをどのように解釈するかについて説明します
Before we get to the engine itself there's a bit of math to explain the basic principles it works
by. To give you a taste of the engine itself before that here is a small JavaScript emulator1 that
performs a simple calculation. It's tiny compared to the real engine but works by the same
principles just on a smaller scale.
エンジンそのものを理解する前に、それが動作する基本原理を説明するためのちょっとした数学的知識に
ついて述べます。engine そのものの雰囲気を感じてもらうために単純な計算を実行する JavaScript による
小さなエミュレーターを用意しました。これは本物の階差機関に比べればとても小規模なものですが、
単に縮小されているだけで同じ原理で動作します。
Try stepping it a few times. The model is actually quite straightforward and the computations you
can use it for are based on some basic mathematical principles. You can treat it as an exercise
before reading the rest if you like: try to work out what it's calculating, how it does it, and how
you can make it calculate other things. Of course you can also just read on an I'll tell you.
何度か試してみてください。このエミュレーターで使っているモデルは actually quite starightforward で、
エミュレーターで可能な計算はいくつかの基本的な数学的原理に基づいています。エミュレーターをこの投稿
の残りを読む前の exercise としても構いません。何を計算しているのか、どのように計算しているのか、
どのようにすればほかの計算をさせられるのか試してみてください。もちろん読むだけでも構いません。
Differences
差分
The difference engine is a very simple device in principle. It's an adding machine, that's all it
is[2]. Part of what makes it such an impressive accomplishment is that it took a difficult problem,
calculating complex functions, and solved it using a simple enough approach that it could be
implemented mechanically using contemporary technology.[3]
階差機関は非常に単純な原理で動作するデバイスです。加算を行う機械である。それですべてです [2]。
それを強烈な印象を与える業績 (impressive accomplishment) にしている原因の一部は、難しい問題を取り上
げて複雑な関数を計算し、当時の技術 (contenmorary technology) を使って mechanically に実装できるくら
い単純なアプローチによってその問題を解決したというものです [3] 。さて、では加算だけを使って複雑な計
算をするにはどのようにすればよいのでしょうか? 大抵の人はその答えがわからないでしょうから、簡単な多項
式から始めてみることにしましょう。
Consider this simple polynomial, the square function:
二乗関数という、単純な多項式を考えてみましょう
f(x) = x^2
The first few values are
その最初のいくつかの値はこうです
\begin{tabular}{lcl} f(0) & = & 0 \\ f(1) & = & 1 \\ f(2) & = & 4 \\ f(3) & = & 9 \\ & \vdots & \end{tabular}
The difference engine is based on a technique called divided differences. Divided differences is
similar to differentiation but simpler and it's based on simple arithmetic. It works as follows.
You take the values of your polynomial at a fixed interval, here we'll use the first four values
from before:
階差機関は divided differences (差分商) と呼ばれる技法に基づいています。divided differences は
differentiation (微分) に似ていますがもっと単純で、簡単な演算がベースになっています。手順は固定され
た interval で多項式の値をとっていくというもので、ここでは先の多項式から最初の四つを使ってみましょう:
差分商(divided difference)
Derivative - Wikipedia, the free encyclopedia
\begin{tabular}{l} 0 \\ \\ 1 \\ \\ 4 \\ \\ 9 \end{tabular}
Then you find the distance between each successive pair of them:
\begin{tabular}{l|l} 0 \\ & 1 \\ 1 \\ & 3 \\ 4 \\ & 5 \\ 9 \end{tabular}
These are the first differences. Then you find the distance between the first differences the same way:
これが first differences (第1階差数列) です。そしてさらにこの第1階差数列に対して同様のことを行います。
\begin{tabular}{l|l|l} 0 \\ & 1 \\ 1 && 2\\ & 3 \\ 4 && 2\\ & 5 \\ 9 \end{tabular}
These are the second differences. And one last time to get the third differences:
これが second differences (第2階差数列) です。最後に third differences (第3階差数列)を求めます。
\begin{tabular}{l|l|l|l} 0 \\ & 1 \\ 1 && 2\\ & 3 && 0\\ 4 && 2\\ & 5 \\ 9 \end{tabular}
You can see the similarity to differentiation: it's a polynomial of degree 2 so the first
differences increase linearly just like the first derivative, the second differences are constant
just like the second derivative, and so on. We don't actually need the third differences, they'll
all be 0 anyway, so I'll leave those out below.
ここに微分 (differentiation) と同様のものを見つけることができます。多項式が二次のものなので、
first differnces は first derivative (第1次導関数) のように linearly に増加していきます。
second diffrences (第2階差数列) は second derivative (第2次導関数)と同様に定数となります。
以下も同じ様に続くのですが、third differences からはすべてが 0になるので実際には不要です。
What's neat is that once you have these values you can extend the table using nothing but addition.
You know the difference between the first derivatives is fixed, 2, so you can get the next first
derivative by adding 2 to the previous one. And you know the difference between the function values
is the first differences so you can get the next value just by adding the next first difference to
the previous function value. Okay maybe it's easier to explain with a concrete example:
これが素晴らしいのは、一度これらの値を求めれば加算だけで table を拡張できるということです。最初の二
つの導関数の差が 2で固定されていることがわかっているのですから、直前のものに 2を加えることで next
first derivative を求められます。そして関数の値と値の差が第1階差数列であることがわかっているのです
から、一つ前の関数の値に next first difference を加えてやるだけで next value が得られます。具体的な
例を使って説明したほうがたぶん簡単でしょう。
\begin{tabular}{l|l|l} 0 \\ & 1 \\ 1 && 2\\ & 3 \\ 4 && 2 \\ & 5 \\ 9 \end{tabular} \quad\to\quad \begin{tabular}{l|l|l} 0 \\ & 1 \\ 1 && 2\\ & 3 \\ 4 && 2 \\ & 5 & \tiny{+0} \\ 9 && \bf{2} \end{tabular} \quad\to\quad \begin{tabular}{l|l|l} 0 \\ & 1 \\ 1 && 2\\ & 3 \\ 4 && 2 \\ & 5 \\ 9 & \tiny{+2} & \bf{2} \\ & \bf{7} \\ \end{tabular} \quad\to\quad \begin{tabular}{l|l|l} 0 \\ & 1 \\ 1 && 2\\ & 3 \\ 4 && 2 \\ & 5 \\ 9 && \bf{2} \\ \tiny{+7} & \bf{7} \\ \bf{16} \\ \end{tabular}
Notice that we don't need the full table at this point, we only need that for calculating the
initial values. All we need to generate more values is the last of each of the differences:
ここではtable まるごとではなく、initial vlues を計算するのに必要なだけあれば十分なことに注意してく
ださい。より多くの値を生成するのに必要となるのはそれぞれの階差数列の最後のものだけです。
\begin{tabular}{l|l|l} \multicolumn{1}{r}{}&&2 \\ & 7 & \tiny{+0}\\ 16 &\tiny{+2}& 2 \\ \tiny{+9} & 9 \\ \bf{25} \\ \end{tabular} \quad\to\quad \begin{tabular}{l|l|l} \multicolumn{1}{r}{}&&2 \\ & 9 & \tiny{+0}\\ 25 &\tiny{+2}& 2 \\ \tiny{+11} & 11 \\ \bf{36} \\ \end{tabular} \quad\to\quad \begin{tabular}{l|l|l} \multicolumn{1}{r}{}&&2 \\ & 11 & \tiny{+0}\\ 36 &\tiny{+2}& 2 \\ \tiny{+13} & 13 \\ \bf{49} \\ \end{tabular} \quad\to\quad\dots
This provably works for any polynomial. To generate a sequence of values for a polynomial of degree
n all you need is n+1 initial values; from the values you calculate the table of differences using
subtraction, and from there on you can calculate as many successive values as you like using just
addition. You don't even need to know the closed form of the polynomial as long as you can evaluate
the initial values at fixed intervals.
このやり方はおそらくどんな多項式に対してもうまくいきます。n次の多項式に対する値の並び(sequence of
values) を生成するのに必要となるのは n+1 個の初期値です。その初期値から引き算を使って差分のテーブル
を計算し、それから好きなだけの長さの successive values を足し算で計算します。多項式の closed form に
ついて知る必要はありません。
This is the basic principle of the difference engine, and what it's named after. The engine has 8
integer registers called columns that can each hold a 31-digit integer value which represent the
current value of the function and the first to the seventh difference. By cranking the handle those
values are added together from right to left. Here is a another mini-emulator, this one calculating
the square function using the differences we just calculated:
これが階差機関の基本原理であり、その名前の由来でもあります。階差機関は8個の整数レジスターを持ってい
ます。それはカラムと呼ばれ、それぞれが31桁の整数値を保持できました。これらは関数の current value と、
第1差分から第7差分 (first to the seventh difference) までとを表わしています。ハンドルを cranking す
ることでレジスター群の値は右から左へ合算されます。これがもうひとつの mini-emulator で、これはわたし
たちが計算した階差数列を使って square function を計算します。
You can see the values are being added together from right to left and the current function value in
the leftmost column is printed for each emulated crank on the handle. Printing was also a part of
the original difference engine. A common source of errors in mathematical tables was typesetting so
to avoid that step the engine would automatically stamp its output in a soft material that could be
used directly for printing, as well as print a log on paper.
右から左へと値が加算されていくことやハンドル上の各 enumlated crank のそれぞれに対して最も左のカラムの
current function が印字されることが見て取れます。印刷もオリジナルの階差機関の一部でした。mathematical
table 中のエラーの一般的な原因は typesetting (活字組み、植字)でしたから、階差機関はそのステップを排除
して出力を紙にログを出力するように直接印字するのにも使える soft material で自動印字しました。
Being able to evaluate an integer polynomial is just the beginning though. First of all, integers
aren't enough, we need to be able to evaluate real-valued functions. Secondly, so far we've only
seen positive values, we also need negatives. Finally, polynomials can be useful in themselves but
we're really more interested in more complex functions like logarithms and trigonometric or
astronomical functions. But with a few tricks the difference engine can handle all those things.
しかしながら整数多項式を評価できるようになったのは出発点に過ぎません。第一に整数だけでは充分ではなく、
real-valued functions を評価できるようにする必要があります。第二に、正の数しか扱っていませんが負の数
も必要です。最後に、多項式は便利なものではあるのですが、現実には対数関数や三角関数、あるいは
astronominal な関数のようなもっとも複雑な関数を必要としています。ただし、ちょっとしたトリックを使う
ことで階差機関はこれらの関数をすべて扱えるようになりました。
Precision
精度
First off: how do we use this to evaluate real-valued functions? You use fixed-point decimal numbers.
For instance, say we want to plot the square function from before but this time in steps of 0.25:
はじめに。real-valued function を評価するにはどのようにすればよいでしょうか? あなたは固定小数点
(fixed-point) の十進数を使っています。たとえば、square function のplotをしたいとしましょう。
ただし time in steps of 0.25 で
\begin{tabular}{lcl|l|l} f(0) & = & 0 \\ &&& 0.0625 \\ f(0.25) & = & 0.0625 && 0.125 \\ &&& 0.1875 \\ f(0.5) & = & 0.25 \end{tabular}
These are fractional numbers but if you multiply them by 105 we're back to integers
端数がありますが、105を乗じることによって整数に戻します。
\begin{tabular}{lcl|l|l} 10000 f(0) & = & 0 \\ &&& 625 \\ 10000 f(0.25) & = & 625 && 1250 \\ &&& 1875 \\ 10000 f(0.5) & = & 2500 \\ \end{tabular}
Now we're back to something the engine can calculate:
これで階差機関で計算できるような形に戻りました。
I've added a line between the digits to mark where the decimal point goes. It also gets added to
the output (I don't believe the original engine did this). But the decimal point is purely a
matter of interpretation by the operator, the adding mechanism is not aware of it, it's operating
purely on 6-digit integer values.
小数点がある場所を markするために桁の間にある行の加算を行いました。また、出力のための加算もできま
した (わたしはオリジナルの階差機関がこれをしていたとは信じられません)。しかし小数点は純粋に演算子
によって解釈されるものなので、加算機構では小数かどうかを気にする必要はありません。
純粋に6桁の整数値として処理します。
In this case we were lucky because there was a relatively small factor of 10 we could multiply
onto the values to get integers without losing precision. That's unlikely to be the case in general.
If you can't use this trick you multiply the values with as large a factor of 10 as you have
precision for and just bite the bullet, round the scaled values to the nearest integers and lose
some accuracy. That's not necessarily as bad as it sounds. The original design had 31 digit
precision in base 10 which corresponds to roughly 103 bits, well beyond the already quite large
64-bit integers on most modern machines. So you can afford to scale the values up quite a bit
before rounding. We'll see an example in a bit of how long it takes for errors to accumulate.
このケースでは幸運にも比較的小さな10というfactor であったので、精度を失わずに乗算による値の整数化が
できました。しかしこのような幸運に恵まれないことのほうが一般的です。もし必要な精度にするために値に
factor 10 を乗じるというこの trick を使えない場合には正確さを多少犠牲にして scaled value を nearest
integers へ丸めます。オリジナルのデザインでは十進で31桁の精度を持っていて、これはおおよそ103ビット分
にあたり modern machines の大部分で使われている64ビット整数よりもかなり大きなものです。このため、丸
めの前に十分なビットを scale の値として与えることが可能です。errors to accumlate のためにどのくらい
の長さのビットを使うかにその例を見ることができます。オリジナルの設計では十進数で31桁の精度を持ってい
ましたがこれはおおよそ103ビットに相当し、modern machines の大部分で使われている 64ビット整数よりもか
なり大きなものです。
Negative values
負の値
To represent negative values we use the exact same trick as with binary numbers, just in base 10: tens
complement. A negative number d is represented as 10n - d where n is the number of decimal digits, so
-1 is represented by 999…999 and so forth. The adding mechanism itself has no concept of negative
values, just like with twos complement the correct behavior just falls out of how overflow works. It's
up to the operator or printer to interpret the output correctly as signed or unsigned values.
負の数を表現するのに、二進数の場合とまったく同じトリックを十進数に対して用います。つまり、十の補数を使
います。ある負数は 10^n - d として表現されます。ここで、n は decimal digits の数で、たとえば -1 は
999…999 のようになります。加算機構そのものは負の数という concept はなくて、二の補数の correct behavior
のようにそれは演算子やプリンターが符号つきの値の出力と符号なしの値の出力を正しく解釈することに依存して
います。
Here is an example of a function that starts off positive, peaks, and then descends into the negative numbers.
ここで例示したのは positive から始まり peak があり、それから negative numbers に向かって descends
する関数の例です。
You'll notice that the numbers in the columns are all positive but the ones that represent negative
values are printed as negative. As with the decimal point that's a hack I added in the printer
which makes it print smaller integer values as positive and larger ones as negative. But it's
purely a matter of interpretation, the calculating part of the engine is oblivious.
カラムにある数値はすべて正の数であるのに、負の数は負として印字されていることに気がつくでしょう。小数
点がついているかのようにするために、小さな整数値を正として、大きな整数値を負であるとして出力させる
hack をプリンターに追加しました。しかしこれは純粋に解釈の問題(matter)であり、階差機関の caluclating
part の問題であることは明らかです。
Polynomial approximation
多項式による近似
Okay, now we're getting close to the goal: being able to produce accurate arithmetic
tables of general functions.
さてゴールが近づいてきました。一般的な関数に対する正確な arithmetic table の生成を可能にしましょう。
In my previous post the main example of how important mathematical tables were was how astronomical
tables were used by mariners to navigate by lunar distance. I don't actually know the math
underlying those astronomical tables so here I'll use an example I do understand: trigonometric
functions. On the right here is a table of trigonometric functions from 1785. It gives 7 digits of
the values of 8 different trignonmetric functions, sin, cos, tan, etc., for each arcminute between
0° and 45°. There's 60 arcminutes to one degree so that's 2700 values for each function, 21,600
values in total. The author of this table, Charles Hutton, said about this edition in a later one
that it had so many errors that is was basically useless:
前回の post での mathematical tables がいかに重要であるかの main example は、lunar distance による
navigate のために astronomical tables が mariners によってどのように使われているかといったものでし
た。そのような astronomical tables に依存してる数学をわたしは実際には知らないので、ここでは自分が
理解している三角関数を例に使います。右側にあるのは1785年に作られた三角関数のtable です。(sin, cos,
tanなど) 8個の異なる三角関数の 0°から45°での7桁の値が記載されています。1°は60 arcminutes なのでそ
れぞれの関数に(60x45で) 2700個の値があり、その総計は 21,600個になります。このt able の作者 Charles
Hutton はこの edition について後に、エラーがとてもたくさんあったので基本的には役に立たなかったと述
べています。
Finding, as well from the report of others, as from my own experience, that those editions
[...] were so very incorrectly printed, the errors being multiplied beyond all tolerable
bounds, and no dependence to be placed on them for any thing of real practice [...]
For this last part about how to calculate complex functions I'll show how to replicate one column,
sin, of this table.
この引用部の最後の部分、複雑な関数をどのように計算するかについて、table の sin 関数のカラムをどの
ように replicate するかで説明します。
Since we know how to evaluate polynomials the solution that first springs to mind is to approximate
the function we want to calculate using a polynomial. Taylor polynomials were well known at this
time so that's an obvious approach. Taylor's theorem says that for an infinitely differentiable
function f (which sin is),
Taylor の polynominals は当時からよく知られていましたから、
多項式を使った計算で関数を近似するのには妥当なアプローチです。
Taylor の theorem (定理) では無限微分可能な関数 f (sin 関数もそうです)について
以下の等式が成り立つとしています。
f(x) = \sum_{k=0}^{\infty}\frac{f^{(k)}(a)}{k!}(x-a)^k
where f^{(k)} means f differentiated n times and a is any point on the function. Since the engine
only has 8 columns and we need n+1 columns for a polynomial of degree n we have to limit ourselves to
at most the first 7 terms. And in fact, since I want to demonstrate this with the emulator in a
little bit and 8 columns of 31 digits takes up an enormous amount of space we'll limit ourselves
even more in this example to 4 columns of 13 digits. This means that we'll use only the first 3 terms
of the Taylor polynomial. For sin those are:
ここで f^{(k)} は f を n 回微分したものを表していて、a はその関数における任意の点です。階差機関は
高々 8カラムだけしか保持できないのですが、n次の多項式のためには n+1 個のカラムが必要です。多くても
最初の七項に制限しなければなりません。実際にはわたしたちはこれを little bit なエミュレーターで
demonstrate したいのと、8 columns of 31 digits は非常に大きなスペースを必要とすることから、この例では
4 columns of 13 digits に制限します。これはつまり、Taylor polynomial の最初の三項だけを使うということ
です。sin 関数に対しては次のようになります(すべての偶数項は 0になります)
\sin(x) \approx x - \frac{x^3}{3!}
(Conveniently all the even degree terms are 0). This approximates sin quite well around 0 so we'll
use that as the basis for generating the table.
この式は 0の近傍でsinをとてもよく近似するので table を生成するための basis として使うことにします。
To calculate the differences we first need to produce n+1 values at fixed intervals. The generated
table should have an entry per arcminute so we'll start at 0′and do steps of 1′:
階差を計算するためにはまず、fixed interval を持った n+1 個の values を生成する必要があります。生成
された table は arcminuite ごとにエントリーを持つとよいので、ここでは0' から始めて1'刻みにします。
x sin(x)
0′ 0
1′ 2.909 10^-4
2′ 5.818 10^-4
3′ 8.727 10^-4
Then we need to find the nth differences:
それからn番目の階差数列を見つけ出す必要があります。
x sin(x) Δ1 Δ2 Δ3
0′ 0 2.909 10^-4 -2.461 10^-11 -2.461 10^-11
1′ 2.909 10^-4 2.909 10^-4 -4.923 10^-11
2′ 5.818 10^-4 2.909 10^-4
3′ 8.727 10^-4
All of this is a matter of evaluating a polynomial so that's not super hard to do by hand with as
many decimals as you need, as long as you only need a few of them. From this table we take the
last of each of the differences and that'll be the starting point for the calculation:
all of this が多項式評価の matter なので、必要な分の dicimals だけ手作業で行うことは特別難しいことで
はありません。この table から各数列の最後を取り出し、それを計算のスタート地点とします。
0.000872664515235
0.000290888130722
-0.000000000049228
-0.000000000024614
At this point we need to decide how much accuracy we want, that is, where we want the fixed decimal
point to be. We have 13 digits which gives us room enough to multiply by 1013 before rounding.
That gives us these integer values:
ここでどのくらいの正確さ (accuracy) を必要としているのか、つまり、どこに小数点を置くのかを決定しな
ければなりません。わたしたちには 13桁分の容量がありますから、丸めを行う前に 10^13 を乗ずるのに十分
な余裕があります。結果として以下のような整数値が得られます。
8726645152
2908881307
-492
-246
And now we're ready to get tabulating:
さてこれで作表 (tabulating) の準備が整いました。
If you follow along with the original table you can see that it generates exactly the
same values. The values generated by the engine continue to match the table values
until 1° 1′, 57 values in, where the table says 0.0177432 and the engine produces
0.0177433, and after that it continues to produce matching values up until 1° 53′,
more than 100 values in.
original table を追いかけていくと、まったく同じ値を生成できていることがわかるでしょう。
階差機関によって生成された値は table のそれに 1° 1′まで一致し続けています。
57番目のその値は table では 0.0177432 ですが engineが生成した値は 0.0177433 です。
その後はまた 1° 53′まで一致した値が百個を超えて生成され続けます。
Not bad right? And remember, this is a simplified emulator that can only calculate the third degree
approximation where the original could go up to the seventh, and only with 13 digits of precision
where the original had 31. Not bad right? And remember,
これが単純化されたエミュレーターであることを思い出してください。オリジナルが seventh degree
apprixmation まで可能なのに対してこのエミュレーターは third degree approximation までしか計算できま
せん。また、オリジナルは31桁までの精度があるのにエミュレーターでは13桁までです。
So what's the source of the deviation? There's two: the approximating polynomial and
the accumulating error of the engine. Let's first look at the polynomials.
ではこの誤差の原因 (source of the deviation) はなんなのでしょうか? それは近似多項式と、階差機関の
計算誤差 (accumulating error) の二つです。まずは多項式の方から見てみましょう。
The first plot on the right is of how quickly the approximating polynomials of
different degrees deviate from the true sine function. At 1° the approximations are
still well within 0.01 billionth of the correct value. Like I said, near 0 these
polynomials approximate sin really well.
右側にあるプロットの最初のものは、異なる次数の近似多項式がどのくらい quickly に sin 関数の真の値から
離れていくのかを示したものです。1°における近似は正しい値との差がまだ 0.01 billonth (一千億分の一)の
中に収まっています。先に述べたように、0の近傍での sin の近似多項式はとても優れているのです。
This suggests that the main source of inaccuracy is the engine itself, the precision we had to
discard when fixing the decimal point, and as you can see in the second graph, it is. The engine
loses precision faster than the polynomial by a large factor. This makes sense because the
inaccuracy accumulates for every step.
このことは不正確さの主原因が階差機関そのものであり、小数点を固定するときに破棄しなければならない精度
が原因であることを示唆しています。このことは二番目のグラフで確認できます。階差機関は large factor を
使った多項式よりも早く精度を失っています。各ステップで不正確な accumulates をしているのでこれには意
味があります。
Luckily in this case the polynomial deviates slowly enough we can use it to calculate new
almost-accurate initial values at fixed intervals, for instance for each degree, and reset the
machine to those. However, eventually the polynomial itself will deviate too much and at that point
we can use the fact that the Taylor polynomial has an a parameter that specifies the point around
which we're approximating. So say the polynomial that approximates around 0° becomes too inaccurate
at 6° we can derive a Taylor polynomial around 6° and use that to continue the calculation. Indeed,
since the polynomial approximates equally well on both sides of the point we might as well
approximate around 9° and use it for all values between 6° and 12°.
このケースでは幸運にも多項式の devuates (逸脱)は、新しい almost-accurate な初期値をたとえば角度ごと
のような fixed intervals で計算するためだとか machine をリセットするための計算のに使うのには十分緩や
かです。しかしながら結局は多項式そのものが逸脱しすぎてしまい、その時点でわたしたちが近似している周辺
のポイントを specify しているパラメーターを Taylor polynominal が持っているという事実を使うことにな
ります。ですからこの 0° 付近で近似する多項式は 6° では不正確になりすぎることがいえます。それでも 6°
付近での Taylor polynomial を derive できますから、計算を継続するにはそれを使います。さらに言うと、
この多項式は the point での both sides で等しく近似するので、9°付近での近似式は6°から12°の間の値すべ
てに対して使えるのです。
Sin is a relatively easy function to approximate in this way, a function such as log is harder but
the same basic principles apply to harder functions. It's a matter of how often you need to reset to
get rid of the accumulating errors and how long the same approximating polynomial remains accurate.
sin 関数は相対的に言えばこの方式での近似が容易な方です。log のような関数はこの方法での近似がもっと難
しいのですが、そういった関数にも同じ basic principles を適用します。重要なのは計算誤差を取り除くため
にどのくらいの頻度でリセットする必要があるのかということと、同じ近似多項式がどのくらいの間正確に計算
し続けるのかということです。
One of the weak points of the engine is that even though it requires less manual work than producing
a table completely manually, there's still a fair amount of manual analysis and computation to be
done. That's not a killer in itself though. Even if it took just as much work to operate, which it
surely wouldn't have, just having a different way to create these tables would have been immensely
valuable since two different approaches are likely to produce different errors and hence can be used
to cross-check each other. But as this illustrates, even if the engine had been built it was
definitely not a matter of just plugging in a few values and then going to lunch, using it involved a
fair amount of work.[4]
解析機関の弱点のひとつが、完全に手作業で数表を作成するよりは少ないもののそれでも手作業を要求する部分が
あって、非常に多くの manual analisys とそれを完了するための計算が存在しているということです。とはいえ
それは致命的なものではありません。たとえ (it surely would't have な) 実行するのに多大な手間を要するもの
であったとしても、table を作成する異なる方法があるということは非常に価値があるのです。なぜなら異なる二
つのやり方は異なるエラーを生成する傾向があるので、お互いをクロスチェックのために使うことができるからで
す。しかし今回 illustrate したようにたとえ解析機関が完成していたとしても、
it was definitely not a matter of just plugging in a few values and then going to lunch,
using it involved a fair amount of work.[4]
The revolution that didn't happen
起こらなかった革命
Here's a video of the only difference engine ever built which was completed in 2002.
これは2002年に組み立てられた階差機関のビデオです
Babbage tried to build it and ultimately gave up for a number of reasons including family problems,
financial problems, problems working with his engineer, and his gradual change of focus to the
analytical engine. Despite what you often hear the technology did exist to build it; the modern
one was built from his designs and only with technology that would have been available back then.
バベジは解析機関の製作に挑みましたが、最終的にはいくつかの理由で断念しました。家族の問題、財務上の問題、
雇ったエンジニアとの作業の問題、彼自身の解析機関への focus という大きな変化などなど。当時の技術が解析
機関の製作には不十分であったいうことはよく耳にしますが、the modern one は彼の設計と当時可能であった技
術だけを用いて実際に組み立てられているのです。
It also appears that Babbage's interests and those of the English government who paid for the whole
thing were just too far apart. Babbage was interested in the machine itself whereas his sponsors
just wanted accurate tables, whatever way Babbage could produce them. It's a shame really. It seems
from what I've read that the difference engine was a failure not of vision or technology but of
product management. The technology was so promising that if a successful prototype had been built
and he'd delivered the tables the English government wanted it's not unlikely that they would have
continued to fund research in more advanced engines. The ground would have been fertile for
mechanical calculation on a larger scale by the mid 1800s. Obviously that wouldn't have meant a
mechanical iPad in every home by 1900 but it would certainly have been a better outcome than what
happened, that the designs went in the drawer.
このことはまた、バベジの興味と英国政府のそれとの乖離をもつまびらかにしています。バベジは機械そのも
のに興味があったのに対して、スポンサー(英国政府)は正確な数表があればよかったのです。バベジがどのよ
うな方法でそれを作るのかには関係ありませんでした。これは実に恥ずべきことです。わたしが読んだところ
では、階差機関が失敗したのは vision のせいでも技術のせいでもなく、product management のためであった
ように思えます。当時の技術はもし successful prototype が製作されていたならば、バベジは数表をそれを
欲していながらも more advanced な engine の研究に対する出資の継続を渋っていた英国政府に対して
delivered していたであろうことを promising していました。その ground は1800年代半ばまでに large scale
の mechanical calculation には fertile (肥沃な、豊かな)ものとなっていました。1900年までにすべての家
庭に機械仕掛けのiPad (mechanical iPad) があるという事態は起こらなかったでしょうが、(the designs went
to in the drawer な) 実際に起きたことよりももっと良い outcome があったのは確実でしょう。
Ultimately Babbage moved on to the analytical engine, the first ever programmable computer. My next
post will be about that and in particular the first ever software programs which were written for it.
最終的にはバベジは史上最初のプログラム可能なコンピューター、解析機関へと移行しました。次回はその解析
機関と解析機関のために書かれた最初のソフトウェアプログラムについて触れます。
Sources
For more information about the difference engine a quick introduction is given in the first part of
Menabrea's Sketch of the Analytical Engine from 1842. A more detailed description, including of the
underlying mechanics of the engine, can be found in Lardner's Babbage's Calculating Engine from the
July 1834 edition of the Edinburgh Review.
Notes
1: While the emulator performs the same type of calculations as the difference engine it actually
looks nothing like it. I made a point to give the emulator a mechanical feel but it's inspired
more by the Curta calculator, the mechanical calculator I know best, not the difference engine.
Note also that I have only tested it on the browsers I have easy access to, Chrome, Firefox,
Opera, and Safari on mac. If it doesn't work on your platform the code lives on github and
patches are welcome.
2: Ada Lovelace in her famous notes about it is almost contemptuous of how simple it is compared
to the analytical engine:
The Difference Engine can in reality [...] do nothing but add; and any other process [...] can
be performed by it only just to the extent in which it is possibly, by judicious mathematical
arrangement and artifices, to reduce them to a series of additions.
3: Incidentally, much of the underlying math was developed before Babbage by J. H. Müller.
4: I wonder if it's possible to automate some of the manual work involved in operating the engine
using the engine itself, like calculating initial values.
Divided differences - Wikipedia, the free encyclopedia
差分商(divided difference)
差分法 - Wikipedia
2 テイラー展開から三角関数の諸公式