x2→ Code: x*x,Doc: $x^2$OpenGL計算ライブラリ実装の経験から脇田建 ‒ 東京工業大学 Ken Wakita ‒ Tokyo Tech
Let’s make a program that computes
p2
Wikipedia says:
A square root of a is y such that y2 = a.
Wikipedia says:
A square root of a is y such that y2 = a.
Ok, fine! Newton-Raphson method over y2 = a.Let’s see, how this idea is put into a working code.
So far so goodbut …
but 1: my x
2 � a = 0 gone?
but 2 (redundancy): the same math formula appears in the doc and the code.
but 3 (complexity): I hate to write this math formula.
まとめ
• Python万歳,SymPy万歳,Jupyter万歳
• 数式処理便利,もっと活用しましょう
• なんてことで,まとめたいわけじゃなくって,
まとまらないのだけど• ひとつのプログラミング言語で文書を含めたすべてを記述する試みに無理がある.Jupyter (Code + Markdown + LaTeX)的な文芸的プログラミングはひとつの突破口かもしれない.
• 今回は,数学というドメインを扱ったから,数式処理システムが輝いた.数式のドメイン:数式の構成,Symbolicな計算,コードとドキュメントの生成
• 二つの意味でのコードの再利用性
• 記号処理[数式] → 数式’ による「記号処理」の再利用性 (c.f. NewtonRaphson)
• 数式 → Python, 数式 → LaTeX による「数式」の再利用性
• 数式だけでなく,世の中のありとあらゆるドメインがドメイン固有の「言語」を要している.ドメインに特化した知識の表現,ドメイン上での計算,ドメイン固有の知識 → コード,ドキュメントの変換が求められている.
• 要するに DSL は重要だというあたりまえの落ちなの?