http://kb.cnblogs.com/page/90166/html
英文原文:Math For Programmers程序員
I've been working for the past 15 months on repairing my rusty math skills, ever since I read a biography of Johnny von Neumann. I've read a huge stack of math books, and I have an even bigger stack of unread math books. And it's starting to come together. 算法
自從我讀了Johnny von Neumann的傳記,我已經爲彌補我糟糕的數學技能花了15個月了。讀了大量的數學書籍,不過呢,彷佛我還有更多沒有讀,固然我會接着作的。編程
Let me tell you about it.
如今我就來告訴你這些。
Conventional Wisdom Doesn't Add Up
告別傳統觀念
First: programmers don't think they need to know math. I hear that so often; I hardly know anyone who disagrees. Even programmers who were math majors tell me they don't really use math all that much! They say it's better to know about design patterns, object-oriented methodologies, software tools, interface design, stuff like that. 設計模式
首先: 程序員不認爲他們須要瞭解數學。我經常聽到這樣的話。我不知道還有沒有不一樣意的,甚至於之前是主修數學的程序員也告訴我,他們真的不是經常使用到數學!他們說更重要的是要去了解設計模式,面向對象原理,軟件工具,界面設計,以及一些其餘相似的東西。api
And you know what? They're absolutely right. You can be a good, solid, professional programmer without knowing much math.
你瞭解嗎?他們徹底正確。你不須要了解不少數學,你就能作個很棒,很專業的程序員。
But hey, you don't really need to know how to program, either. Let's face it: there are a lot of professional programmers out there who realize they're not very good at it, and they still find ways to contribute.
可是呢,同時你也不是真的須要知道如何來編程。咱們要面對的是:有不少專業的程序員,他們認識到他們不是很是擅長數學,但他們仍是尋找方法去提高。
If you're suddenly feeling out of your depth, and everyone appears to be running circles around you, what are your options? Well, you might discover you're good at project management, or people management, or UI design, or technical writing, or system administration, any number of other important things that "programmers" aren't necessarily any good at. You'll start filling those niches (because there's always more work to do), and as soon as you find something you're good at, you'll probably migrate towards doing it full-time. 網絡
若是你忽然以爲本身好爛,周圍的人都遠遠的超過你,你會怎麼想呢?好,你可能會發現本身善於項目管理,或人事管理,或界面設計,或技術寫做,或系統管理,還有許多其餘程序員沒必要去精通的。你會開始堆積那些想法(由於工做永遠幹不完),當你發現一些你能掌握的東西時,你極可能會轉移去全職的作這個工做。
In fact, I don't think you need to know anything, as long as you can stay alive somehow.
實際上,我認爲有些東西你不須要了解,當前你還可以賴以生存的話。
So they're right: you don't need to know math, and you can get by for your entire life just fine without it.
因此他們是對的:你不須要了解數學,而且沒有數學你也能過的很好。
But a few things I've learned recently might surprise you:
可是最近我學到的一些東西可能會讓你感到驚訝:
Math is a lot easier to pick up after you know how to program. In fact, if you're a halfway decent programmer, you'll find it's almost a snap.
在你知道如何編程以後,數學更容易學會。實際上,若是你先學數學,而後半路出家作程序員的話,你會發現編程簡直就是小菜一碟。
They teach math all wrong in school. Way, WAY wrong. If you teach yourself math the right way, you'll learn faster, remember it longer, and it'll be much more valuable to you as a programmer.
學校裏教數學的方式都錯了。僅僅是教學的方法錯了,不是教數學自己錯了。若是你以正確的方式學習數學的話,你會學的更快,記住這點,對你,做爲一個程序員來講頗有價值。
Knowing even a little of the right kinds of math can enable you do write some pretty interesting programs that would otherwise be too hard. In other words, math is something you can pick up a little at a time, whenever you have free time.
哪怕瞭解一點點相關的數學知識,就能讓你寫出可愛有趣的程序,不然會有些小難度。換句話講,數學是能夠慢慢學的,只要你有時間。
Nobody knows all of math, not even the best mathematicians. The field is constantly expanding, as people invent new formalisms to solve their own problems. And with any given math problem, just like in programming, there's more than one way to do it. You can pick the one you like best.
沒人能瞭解全部的數學,就是最棒的數學家也不能。當人們發明新的形式去解決本身的問題時,數學領域就不斷的擴展。和編程同樣,一些給出的數學問題,不止一種方法能夠去解決它。你能夠挑個你最喜歡的方式。
Math is... ummm, please don't tell anyone I said this; I'll never get invited to another party as long as I live. But math, well... I'd better whisper this, so listen up: (it's actually kinda fun.)
數學是......嗯,請別告訴別人我說過這個哈;固然我也不期望誰能邀請我參加這樣的派對,在我還活着的時候。可是,數學其實就是......我仍是小聲的說吧,聽好了:(她其實就是一種樂趣啦!)
The Math You Learned (And Forgot)
你學到的數學(和你忘了的數學) 。
Here's the math I learned in school, as far as I can remember:
這兒是我能記得的在學校學到的數學:
Grade School: Numbers, Counting, Arithmetic, Pre-Algebra ("story problems")
初中:數,數數,算術知識,初級代數("帶問題的小故事") 。
High School: Algebra, Geometry, Advanced Algebra, Trigonometry, Pre-Calculus (conics and limits)
高中:代數,幾何,高等代數,三角學,微積分先修課 (二次曲線論和極限)。
College: Differential and Integral Calculus, Differential Equations, Linear Algebra, Probability and Statistics, Discrete Math
大學:微積分,微分公式,線性代數,機率和統計,離散數學。
How'd they come up with that particular list for high school, anyway? It's more or less the same courses in most U.S. high schools. I think it's very similar in other countries, too, except that their students have finished the list by the time they're nine years old. (Americans really kick butt at monster-truck competitions, though, so it's not a total loss.)
上面那個關於高中數學課程單子上所列的,怎麼來着?美國高中幾乎都是這樣的課程設置。我認爲其餘國家也會很類似的,除了那些在9歲以前就掌握了這些課程的學生。(美國小孩同時卻在熱衷於玩魔鬼卡車競賽,雖然如此,整個來講也算不上什麼大損失。)
Algebra? Sure. No question. You need that. And a basic understanding of Cartesian geometry, too. Those are useful, and you can learn everything you need to know in a few months, give or take. But the rest of them? I think an introduction to the basics might be useful, but spending a whole semester or year on them seems ridiculous.
代數?是的,沒問題。你須要代數,和一些理解解析幾何的知識。那些頗有用,而且在之後幾個月裏,你能學到一切你想要的,十拿九穩的。剩下的呢?我認爲一個基本的介紹可能會有用,可是在這上面花整個學期或一年就顯得很荒謬了。數據結構
I'm guessing the list was designed to prepare students for science and engineering professions. The math courses they teach in and high school don't help ready you for a career in programming, and the simple fact is that the number of programming jobs is rapidly outpacing the demand for all other engineering roles. 閉包
我如今意識到那個書單列表是設計給那些之後要當科學家和工程師的學生的。他們在高中裏所教的數學課程並非爲你的編程生涯作準備的,簡單的事實是,多數的編程工做所須要的數學知識,相比其餘工程師角色增加的更快。
And even if you're planning on being a scientist or an engineer, I've found it's much easier to learn and appreciate geometry and trig after you understand what exactly math is — where it came from, where it's going, what it's for. No need to dive right into memorizing geometric proofs and trigonometric identities. But that's exactly what high schools have you do.
即便你打算當一名科學家或者一名工程師,在你理解了什麼是數學以後——數學從何而來,走向哪裏,爲什麼而生,你會發現學習和欣賞幾何學和三角學變得更容易了。沒必要去記住幾何上的證實和三角恆等式,雖然那確實是高中學校要求你必須去作的。
So the list's no good anymore. Schools are teaching us the wrong math, and they're teaching it the wrong way. It's no wonder programmers think they don't need any math: most of the math we learned isn't helping us.
因此,這樣的書單列表再也不有什麼用了。學校教給咱們的不是最合適的數學,而且方式也不對,難怪程序員認爲他們再也不須要數學:咱們學的大部分數學知識對咱們的工做沒什麼大的幫助。
The Math They Didn't Teach You
他們沒有教給你的那部分數學。
The math computer scientists use regularly, in real life, has very little overlap with the list above. For one thing, most of the math you learn in grade school and high school is continuous: that is, math on the real numbers. For computer scientists, 95% or more of the interesting math is discrete: i.e., math on the integers. app
在現實中,計算機科學家常用的數學,跟上面所列的數學僅有很小的重疊。舉個例子,你在中學裏學的大部分數學是連續性的,也就是說,那是做爲實數的數學。而對於計算機科學家來講,他們所感興趣的95%也許更多的是離散性的,好比,關於整數的數學。
I'm going to talk in a future blog about some key differences between computer science, software engineering, programming, hacking, and other oft-confused disciplines. I got the basic framework for these (upcoming) insights in no small part from Richard Gabriel's Patterns Of Software, so if you absolutely can't wait, go read that. It's a good book.
我打算在之後的博客中再談一些有關計算機科學,軟件工程,編程,搞些有趣的東東,和其餘經常使人犯暈的訓練。我已經從Richard Gabriel的《軟件的模式》這本書中洞察到一個無關鉅細的基本框架。若是你明顯的等不下去的話,去讀吧,是本不錯的書。
For now, though, don't let the term "computer scientist" worry you. It sounds intimidating, but math isn't the exclusive purview of computer scientists; you can learn it all by yourself as a closet hacker, and be just as good (or better) at it than they are. Your background as a programmer will help keep you focused on the practical side of things.
從如今開始,不要再讓"計算機科學家"這個詞困擾到你。它聽上去很可怕,其實數學不是計算機科學家所獨有的領域。你也能做爲一個黑客自學它,而且能作的和他們同樣棒。你做爲一個程序員的背景,將會幫助你保持只關注那些有實踐性的部分。
The math we use for modeling computational problems is, by and large, math on discrete integers. This is a generalization. If you're with me on today's blog, you'll be studying a little more math from now on than you were planning to before today, and you'll discover places where the generalization isn't true. But by then, a short time from now, you'll be confident enough to ignore all this and teach yourself math the way you want to learn it.
咱們用來創建計算模型的,大致上是離散數學,這是廣泛的作法。若是正好今天你在看這篇博客,從如今起你正瞭解到更多的數學,而且你會認識到那樣的廣泛作法是不對的;從如今開始,你將有信心認爲能夠忽略這些,並以你想要的方式自學。
For programmers, the most useful branch of discrete math is probability theory. It's the first thing they should teach you after arithmetic, in grade school. What's probability theory, you ask? Why, it's counting. How many ways are there to make a Full House in poker? Or a Royal Flush? Whenever you think of a question that starts with "how many ways..." or "what are the odds...", it's a probability question. And as it happens (what are the odds?), it all just turns out to be "simple" counting. It starts with flipping a coin and goes from there. It's definitely the first thing they should teach you in grade school after you learn Basic Calculator Usage.
對程序員來講,最有效的離散數學的分支是機率理論。這是你在學校學完基本算術後緊接着的課。你會問,什麼是機率理論呢?你就數啊,看有多少次出現滿堂彩?或者有多少次是同花順。無論你思考什麼問題,若是是以"多少種途徑..."或"有多大概率的...",那就是離散問題。當它發生時,都轉化成"簡單"的計數,拋個硬幣看看...? 毫無疑問,在他們教你基本的計算用法後,他們會教你機率理論。
I still have my discrete math textbook from college. It's a bit heavyweight for a third-grader (maybe), but it does cover a lot of the math we use in "everyday" computer science and computer engineering.
我還保存着大學裏的離散數學課本,可能它只佔了三分之一的課程,可是它卻涵蓋了咱們幾乎天天計算機編程工做大部分所用到的數學。
Oddly enough, my professor didn't tell me what it was for. Or I didn't hear. Or something. So I didn't pay very close attention: just enough to pass the course and forget this hateful topic forever, because I didn't think it had anything to do with programming. That happened in quite a few of my comp sci courses in college, maybe as many as 25% of them. Poor me! I had to figure out what was important on my own, later, the hard way.
也真是夠奇怪的,個人教授從沒告訴我數學是用來幹嘛的,或者我也歷來沒有據說過,種種緣由吧。因此我也從沒有給以足夠的注意,只是考試及格,而後把他們都忘光,由於我不認爲它還和編程有啥關係。事情變化是我在大學學完一些計算機科學的課程以後,也許是25%的課程,可憐啊!我必須弄明白什麼對於本身來講是最重要的,而後再是向深度發展。
I think it would be nice if every math course spent a full week just introducing you to the subject, in the most fun way possible, so you know why the heck you're learning it. Heck, that's probably true for every course.
我想,若是每門數學課都花上整整一週的時間,而只是介紹讓你如何入門的話,那將很是不錯。這是最有意思的一種假設,那麼你知道了你正學習的對象是哪一種怪物了。怪物,大概對每一門課都合適。
Aside from probability and discrete math, there are a few other branches of mathematics that are potentially quite useful to programmers, and they usually don't teach them in school, unless you're a math minor. This list includes:
除了機率和離散數學外,還有很多其餘的數學分支,可能對程序員至關的有用。學校一般不會教你的,除非你的輔修科目是數學,這些數目列表包括:
Statistics, some of which is covered in my discrete math book, but it's really a discipline of its own. A pretty important one, too, but hopefully it needs no introduction.
統計學,其中一些包括在個人離散數學課裏,它的某些訓練只限於它自身,天然也是至關重要的,但想學的話不須要什麼特別的入門。
Algebra and Linear Algebra (i.e., matrices). They should teach Linear Algebra immediately after algebra. It's pretty easy, and it's amazingly useful in all sorts of domains, including machine learning.
代數和線性代數(好比:矩陣),他們會在教完代數後當即教線性代數。這也簡單,但這在至關多的領域很是有用,包括機器學習。
Mathematical Logic. I have a really cool totally unreadable book on the subject by Stephen Kleene, the inventor of the Kleene closure and, as far as I know, Kleenex. Don't read that one. I swear I've tried 20 times, and never made it past chapter 2. If anyone has a recommendation for a better introduction to this field, please post a comment. It's obviously important stuff, though.
數理邏輯,我有至關完整的關於這門學科的書沒有讀,是Stephen Kleene寫的,克林閉包的發明者。我所知道的還有就是Kleenex, 這個就不要讀了,我發誓我已經嘗試了不下20次,卻從沒有讀完第二章。若是哪位牛掰有什麼更好的入門建議的話,能夠給我推薦。顯然,這門學科明顯是很是重要的一部分。
Information Theory and Kolmogorov Complexity. Weird, eh? I bet none of your high schools taught either of those. They're both pretty new. Information theory is (veeery roughly) about data compression, and Kolmogorov Complexity is (also roughly) about algorithmic complexity. I.e., how small you can you make it, how long will it take, how elegant can the program or data structure be, things like that. They're both fun, interesting and useful.
信息理論和柯爾莫戈洛夫複雜性理論,真難以想象,不是麼?我敢打賭沒哪一個高中會教你其中任何一門課程。它們都是新興的學科。信息理論(至關至關至關至關難懂)是關於數據壓縮,柯爾莫戈洛夫複雜性理論(一樣很是難懂)是關於算法複雜度的。也就是說,你要把它壓縮的儘可能小,你所要花費的時間也就變的越長;一樣的,程序或數據結構要變得多優雅,也有一樣的代價。它們都頗有趣,也頗有用。
There are others, of course, and some of the fields overlap. But it just goes to show: the math that you'll find useful is pretty different from the math your school thought would be useful.
固然,也有其餘的一些因素,某些領域是重複的。也拿來講說吧,你所發現有用的那部分數學,不一樣於那些你在學校裏認爲有用的數學。
What about calculus? Everyone teaches it, so it must be important, right?
那微積分呢?每一個人都學它,因此它也必定是重要的,對嗎?
Well, calculus is actually pretty easy. Before I learned it, it sounded like one of the hardest things in the universe, right up there with quantum mechanics. Quantum mechanics is still beyond me, but calculus is nothing. After I realized programmers can learn math quickly, I picked up my Calculus textbook and got through the entire thing in about a month, reading for an hour an evening.
好吧,微積分其實是至關容易的。在我學習它以前,它聽上去好像是世界上最難的一件事,好像和量子力學差很少。量子力學對我來講真的不是那麼容易理解,可是微積分卻不是。在我意識到程序員可以快速的學習數學時,我拿起一些微積分課本用一個月通讀了整本書,一個晚上讀一小時。
Calculus is all about continuums — rates of change, areas under curves, volumes of solids. Useful stuff, but the exact details involve a lot of memorization and a lot of tedium that you don't normally need as a programmer. It's better to know the overall concepts and techniques, and go look up the details when you need them.
微積分都是關於連續統的 -- 變化的比率,曲線的面積,立體的體積,是些有用的東西,可是實際細節卻包含大量的記憶量而且枯燥,做爲一個程序員來講根本不須要這些。更好的方法是從總體上了解那些概念和技術,在必要的時候再去查詢那些細節。
Geometry, trigonometry, differentiation, integration, conic sections, differential equations, and their multidimensional and multivariate versions — these all have important applications. It's just that you don't need to know them right this second. So it probably wasn't a great idea to make you spend years and years doing proofs and exercises with them, was it? If you're going to spend that much time studying math, it ought to be on topics that will remain relevant to you for life.
幾何,三角,微分,積分,圓錐曲線,微分方程,和他們的多維和多元 -- 這些都有重要的應用。不過這時候不須要你去了解它們,這大概不是個好注意,讓你年復一年的去作證實和它們的練習題,不是嗎?若是你打算花大量的時間去學習數學,那也是和你生活相關的部分。
The Right Way To Learn Math
學習數學的正確方法 。
The right way to learn math is breadth-first, not depth-first. You need to survey the space, learn the names of things, figure out what's what.
正確學習數學的方法是廣度優先,而非深度優先。你要考察的是整個數學世界,學習每一個概念的名字,區分出什麼是什麼。
To put this in perspective, think about long division. Raise your hand if you can do long division on paper, right now. Hands? Anyone? I didn't think so.
具體來看,考慮用長除法?若是你能在紙上作長整除,如今就舉起你的手。會有人舉手嗎?至少我不這麼認爲。
I went back and looked at the long-division algorithm they teach in grade school, and damn if it isn't annoyingly complicated. It's deterministic, sure, but you never have to do it by hand, because it's easier to find a calculator, even if you're stuck on a desert island without electricity. You'll still have a calculator in your watch, or your dental filling, or something,
回頭看看在學校裏學過的長除法,要是不讓你以爲煩惱和憤怒纔怪。固然,這是顯然的,但你不必定要本身親自去作,由於很容易用計算器來作。即便你不幸在一座沒有電力的荒無人煙的小島上,你起碼還有個計算器,在你的手錶上,補牙的什麼東東,或其餘什麼上面。
Why do they even teach it to you? Why do we feel vaguely guilty if we can't remember how to do it? It's not as if we need to know it anymore. And besides, if your life were on the line, you know you could perform long division of any arbitrarily large numbers. Imagine you're imprisoned in some slimy 3rd-world dungeon, and the dictator there won't let you out until you've computed 219308862/103503391. How would you do it? Well, easy. You'd start subtracting the denominator from the numerator, keeping a counter, until you couldn't subtract it anymore, and that'd be the remainder. If pressed, you could figure out a way to continue using repeated subtraction to estimate the remainder as decimal number (in this case, 0.1185678219, or so my Emacs M-x calc tells me. Close enough!)
爲何他們還教你這些呢?若是咱們不能記住怎樣去作,爲何會感到含糊心虛呢?好像咱們不須要再次知道它。除此之外,若是你命懸一線,你能夠運用任意大的數來作長除法。想象你被囚禁在第三世界的地牢裏,那兒的獨裁者是不會放你出來的,除非你計算出219308862/103503391。你會怎麼作呢?好吧,很容易,你開始從分子減去分,,直到不能再減只剩餘數爲止。若實在有壓力,你能夠想個辦法,繼續使用反覆減,估算做爲十進制的餘數(這種狀況下,0.1185678219, Emacs M-x calc 告訴個人,夠精確了! )
You could figure it out because you know that division is just repeated subtraction. The intuitive notion of division is deeply ingrained now.
你或許明白,除法就是反覆的減,這樣從直覺上對除法概念的理解就根深蒂固啦!
The right way to learn math is to ignore the actual algorithms and proofs, for the most part, and to start by learning a little bit about all the techniques: their names, what they're useful for, approximately how they're computed, how long they've been around, (sometimes) who invented them, what their limitations are, and what they're related to. Think of it as a Liberal Arts degree in mathematics.
學習數學的正確方法是忽略實際的算法和證實,對於大部分狀況來講,他們的名字,他們的做用,他們計算的大體步驟,(有時是)誰發明了他們,發明了多久了,他們的缺陷是什麼,和他們相關的有什麼,把數學當文科來學。
Why? Because the first step to applying mathematics is problem identification. If you have a problem to solve, and you have no idea where to start, it could take you a long time to figure it out. But if you know it's a differentiation problem, or a convex optimization problem, or a boolean logic problem, then you at least know where to start looking for the solution.
爲何呢?由於第一步反應在數學上的是問題的肯定。若是你有一個問題去解決,而且假設你沒有頭緒如何開始,這將花費你很長的時間來弄明白。但若是你知道這是個變異的問題,或者是一個凸優化問題,或者一個布爾的邏輯問題,而後你起碼能知道從哪着手開始尋找解決方案。
There are lots and lots of mathematical techniques and entire sub-disciplines out there now. If you don't know what combinatorics is, not even the first clue, then you're not very likely to be able to recognize problems for which the solution is found in combinatorics, are you?
如今有許許多多的數學技術和整個的學科分支。若是你不知道組合邏輯是什麼,甚至連聽都沒據說過,那麼你是不可能意識到在組合邏輯中能夠找到的答案解決的是什麼問題,難道不是麼?
But that's actually great news, because it's easier to read about the field and learn the names of everything than it is to learn the actual algorithms and methods for modeling and computing the results. In school they teach you the Chain Rule, and you can memorize the formula and apply it on exams, but how many students really know what it "means"? So they're not going to be able to know to apply the formula when they run across a chain-rule problem in the wild. Ironically, it's easier to know what it is than to memorize and apply the formula. The chain rule is just how to take the derivative of "chained" functions — meaning, function x() calls function g(), and you want the derivative of x(g()). Well, programmers know all about functions; we use them every day, so it's much easier to imagine the problem now than it was back in school.
但那實在是個大新聞,由於閱讀這些領域,學習實際算法,建模和計算結果的方法,記住這些名字都是容易的。在學校裏他們教你鏈式法則。你也能回憶起他們並能運用在考試題上,但有多少學生能真正的瞭解他們到底意味着什麼呢? 因此當他們遇到變種的鏈式問題時,他們就不懂得如何運用公式了。讓人感到諷刺的是,瞭解這是什麼比記住如何運用公式更爲容易。鏈式法則僅僅是如何對鏈式函數求導的意思,函數 x() 引用函數 g() , 你要求導 x(g()) 。好了,程序員知道全部這些函數相關的,咱們天天都使用它們,因此如今比過去在學校更容易想象到問題所在。
Which is why I think they're teaching math wrong. They're doing it wrong in several ways. They're focusing on specializations that aren't proving empirically to be useful to most high-school graduates, and they're teaching those specializations backwards. You should learn how to count, and how to program, before you learn how to take derivatives and perform integration.
這就是爲何我認爲他們以錯誤的方式在教數學。老師們向大多數高中畢業生專門教授的內容,不是靠經驗來證實數學是如何如何有用的,而偏偏是相反。在你學習如何求導和作積分以前,你應該學習如何計數,怎樣編程。
I think the best way to start learning math is to spend 15 to 30 minutes a day surfing in Wikipedia. It's filled with articles about thousands of little branches of mathematics. You start with pretty much any article that seems interesting (e.g. String theory, say, or the Fourier transform, or Tensors, anything that strikes your fancy.) Start reading. If there's something you don't understand, click the link and read about it. Do this recursively until you get bored or tired.
我認爲學習數學最好的方法是天天花15到30分鐘逛維基百科,那上面有數千數學分支的相關文章,能夠從一些你感興趣的文章着手(好比弦理論,或者傅立葉變換,或者張量理論,就是能衝擊你想象力的東西) 閱讀。若是有什麼你不理解的,就去了解那些連接,如此這般直到你累到不行爲止。
Doing this will give you amazing perspective on mathematics, after a few months. You'll start seeing patterns — for instance, it seems that just about every branch of mathematics that involves a single variable has a more complicated multivariate version, and the multivariate version is almost always represented by matrices of linear equations. At least for applied math. So Linear Algebra will gradually bump its way up your list, until you feel compelled to learn how it actually works, and you'll download a PDF or buy a book, and you'll figure out enough to make you happy for a while.
幾個月後,這麼作會縱向擴展你的數學知識面。你會發現一些模式,比如數學的每一個分支看上去都包括了一個有着複雜的多元的變量,而後線性代數將會慢慢爬滿你的書單列表,直到你強迫本身學會它其實是怎樣工做的,你要下載個電子書或買本書,直到你能從中找到樂趣。
With the Wikipedia approach, you'll also quickly find your way to the Foundations of Mathematics, the Rome to which all math roads lead. Math is almost always about formalizing our "common sense" about some domain, so that we can deduce and/or prove new things about that domain. Metamathematics is the fascinating study of what the limits are on math itself: the intrinsic capabilities of our formal models, proofs, axiomatic systems, and representations of rules, information, and computation.
憑藉着維基百科,你也能快速的找到一條瞭解數學基本原理的途徑,條條大道通羅馬。在某些領域,數學幾乎老是形式化咱們的"常識",因此咱們能減小或證實那些領域裏的新事物。對數學自己的研究就是無止境並且使人着迷的,構造形式模型本質的能力,證實,自明的系統,規則表示,信息和計算。
One great thing that soon falls by the wayside is notation. Mathematical notation is the biggest turn-off to outsiders. Even if you're familiar with summations, integrals, polynomials, exponents, etc., if you see a thick nest of them your inclination is probably to skip right over that sucker as one atomic operation.
數學符號很重要,但卻容易讓人放棄。對於門外漢來講,數據符號是巨大的障礙。即便你熟悉累加,積分,多項式,指數等等,若是你看到堆徹的異常複雜的符號時,你就把它實現的功能當成一個原子操做好了,不要深究太多。
However, by surveying math, trying to figure out what problems people have been trying to solve (and which of these might actually prove useful to you someday), you'll start seeing patterns in the notation, and it'll stop being so alien-looking. For instance, a summation sign (capital-sigma) or product sign (capital-pi) will look scary at first, even if you know the basics. But if you're a programmer, you'll soon realize it's just a loop: one that sums values, one that multiplies them. Integration is just a summation over a continuous section of a curve, so that won't stay scary for very long, either.
無論怎樣,認真去了解數學,嘗試着理解人們正在試圖解決的問題(那些已被證實了的問題某天也許會對你有實際用途),你會在符號中看到模式,你也再也不排斥它們。好比,累加符號(大寫符號-西格馬)或者π(大寫符號-pi,連乘符號)起初看上去讓人內心沒底,即便你瞭解了它們的基本原理。但若是你是個程序員,你會認識到他僅僅是個循環:一個累加值,一個累乘,積分是一段連續曲線的相加,因此那不會讓你鬱悶過久。
Once you're comfortable with the many branches of math, and the many different forms of notation, you're well on your way to knowing a lot of useful math. Because it won't be scary anymore, and next time you see a math problem, it'll jump right out at you. "Hey," you'll think, "I recognize that. That's a multiplication sign!"
一旦你習慣了數學的許多分支,和許多不一樣格式的符號,你就走在了知道不少有用數學知識的路上。由於你再也不懼怕,你將會發現問題,其實它們會自動跳到你面前。「嗨,」你會思索,「我瞭解這個,這是乘法符號!」
And then you should pull out the calculator. It might be a very fancy calculator such as R, Matlab, Mathematica, or a even C library for support vector machines. But almost all useful math is heavily automatable, so you might as well get some automated servants to help you with it.
這樣你就能扔掉計算器了。有一個充滿想象的計算器好比R, Matlab, Mathematica, 甚或是支持向量機的C語言庫,但幾乎全部有用的數學都是重型自動機,因此你可以讓一切都變的自動化。
When Are Exercises Useful?
練習有啥用處呢?
After a year of doing part-time hobbyist catch-up math, you're going to be able to do a lot more math in your head, even if you never touch a pencil to a paper. For instance, you'll see polynomials all the time, so eventually you'll pick up on the arithmetic of polynomials by osmosis. Same with logarithms, roots, transcendentals, and other fundamental mathematical representations that appear nearly everywhere.
在作了幾年的業餘數學愛好者以後,你能夠在腦海裏作不少數學題,即便你從沒碰過筆和紙。好比,你會一直看到多項式,因此你會耳濡目染的作起多項式的運算。一樣的,對數,根,超越數,和其餘處處出現的基本數學原理。
I'm still getting a feel for how many exercises I want to work through by hand. I'm finding that I like to be able to follow explanations (proofs) using a kind of "plausibility test" — for instance, if I see someone dividing two polynomials, I kinda know what form the result should take, and if their result looks more or less right, then I'll take their word for it. But if I see the explanation doing something that I've never heard of, or that seems wrong or impossible, then I'll dig in some more.
對於我要親手作多少練習題,我有一種直覺。我用一種「真實性測試」跟隨證實步驟。好比,我看到有人除以兩個多項式,我大概知道結果是什麼,若是它們的結果看上去差很少是對的,我就相信他們了。但若是我看到的那個證實我聽都沒據說過,亦或看上去是錯的或者不可能的,我就要挖掘更多的東西了。
That's a lot like reading programming-language source code, isn't it? You don't need to hand-simulate the entire program state as you read someone's code; if you know what approximate shape the computation will take, you can simply check that their result makes sense. E.g. if the result should be a list, and they're returning a scalar, maybe you should dig in a little more. But normally you can scan source code almost at the speed you'd read English text (sometimes just as fast), and you'll feel confident that you understand the overall shape and that you'll probably spot any truly egregious errors.
這很像讀程序源代碼,不是麼?當你讀某人的代碼,你不須要手動模擬整個程序狀態;若是你知道計算過程大體會發生什麼情形,你就能推斷出結果。舉個例子,若是結果應該是個列表,但返回的是一個標量,可能你就會更深刻地研究。但正常狀況下,你幾乎是以你閱讀英文文本的速度(有時僅僅是速度上)掃描源代碼,而且你確信理解了整個結構,但與此同時,你也許會發現令你震驚的錯誤。
I think that's how mathematically-inclined people (mathematicians and hobbyists) read math papers, or any old papers containing a lot of math. They do the same sort of sanity checks you'd do when reading code, but no more, unless they're intent on shooting the author down.
我認爲數學愛好者(數學家和真正的數學迷)也是這樣閱讀數學論文的。和你讀代碼時同樣,他們也會作一樣的檢查,除非他們不想把做者的觀點駁倒。
With that said, I still occasionally do math exercises. If something comes up again and again (like algebra and linear algebra), then I'll start doing some exercises to make sure I really understand it.
照那樣說,我會偶爾作作數學練習。若是某些問題(好比代數和線性代數)一次又一次的出現,我就作些練習去確認我是否真正的理解它了。
But I'd stress this: don't let exercises put you off the math. If an exercise (or even a particular article or chapter) is starting to bore you, move on. Jump around as much as you need to. Let your intuition guide you. You'll learn much, much faster doing it that way, and your confidence will grow almost every day.
但我要強調這點:不要讓練習使你分心。若是一個練習(甚或是一篇特別的文章或章節)開始讓你煩惱,那就暫時丟一邊繼續前進,該奔跑就堅定奔跑。讓你的直覺引導你。你會學到更多,更快,你的信心也會隨之增加。
How Will This Help Me?
這些怎樣才能幫到我?
Well, it might not — not right away. Certainly it will improve your logical reasoning ability; it's a bit like doing exercise at the gym, and your overall mental fitness will get better if you're pushing yourself a little every day.
也許不能--不能馬上奏效。但確實能幫助提升你的邏輯推理能力;比如是在健身房進行鍛鍊,若是你天天都作一點的話,你的身體素質確定會獲得提升。
For me, I've noticed that a few domains I've always been interested in (including artificial intelligence, machine learning, natural language processing, and pattern recognition) use a lot of math. And as I've dug in more deeply, I've found that the math they use is no more difficult than the sum total of the math I learned in high school; it's just different math, for the most part. It's not harder. And learning it is enabling me to code (or use in my own code) neural networks, genetic algorithms, bayesian classifiers, clustering algorithms, image matching, and other nifty things that will result in cool applications I can show off to my friends.
對我來講,我已經注意到一些我感興趣的領域(包括人工智能,機器學習,天然語言處理和模式識別)大量用到數學。對於我研究的更深的領域,我發現它們所用的數學並不比我在中學學到的更難;多半是不一樣的數學,而不是更難了。而且學習數學使我能寫(或者是在我本身的代碼裏使用)神經網絡,基因算法,貝頁斯分類器,集羣算法,圖像識別,和其餘時髦的東西,能產生很酷的應用,我能夠向個人朋友炫耀。
And I've gradually gotten to the point where I no longer break out in a cold sweat when someone presents me with an article containing math notation: n-choose-k, differentials, matrices, determinants, infinite series, etc. The notation is actually there to make it easier, but (like programming-language syntax) notation is always a bit tricky and daunting on first contact. Nowadays I can follow it better, and it no longer makes me feel like a plebian when I don't know it. Because I know I can figure it out.
我逐漸意識到這點,當別人給我看一篇包含數學公式的文章時,我再也不忽然冒出一身冷汗:組合,微分,真值表,定列式,無限系列等等。那些數學公式如今變得容易相處了,但(像編程語言的語法)剛開始接觸的時候多少仍是讓人以爲複雜。如今我能更好的理解了,即便遇到不懂的地方,也再也不感到本身是個不懂數學的人了。由於我知道本身是可以弄明白的。
And that's a good thing.
那很好。
And I'll keep getting better at this. I have lots of years left, and lots of books, and articles. Sometimes I'll spend a whole weekend reading a math book, and sometimes I'll go for weeks without thinking about it even once. But like any hobby, if you simply trust that it will be interesting, and that it'll get easier with time, you can apply it as often or as little as you like and still get value out of it.
我會繼續加油作的更好滴。我還有很多活頭,有好多書和文章要讀。有時我會花整個週末來讀數學書,有時會數週都再也不思考它。和其餘興趣同樣,若是你相信它是有趣的,能經過它更容易的消磨時光,你就會時不時地去作,並從中獲益。
Math every day. What a great idea that turned out to be!
好好學習,每天數學!
原文標題:Math For Programmers
原文來源:http://steve-yegge.blogspot.com/2006/03/math-for-programmers.html