16 ms·
Richard Feynman’s Integral Trick (2018)
- prof-dr-ir 5y agoHow do we see that f(1) = 0 in the example? That claim is equivalent to: int_0^pi ln[1 - cos(x)] dx = - pi ln[2] Is this easy?
- cryvate1284 5y agoBecause the integral is then over ln(1) and the log of 1 is 0.
- prof-dr-ir 5y agoNo, that is saying that f(0) = 0 which is correct but not what I asked about (nor what was stated in the article). Incidentally, your correct observation is in contradiction with f(a) = 2 pi log(|a|) since the latter only holds for |a| >= 1. This is because f(a) is not a smooth function.
- contravariant 5y agoYeah I can't immediately spot something that would make it easy. It's much easier to prove that the difference between the integral of log(a^2 - 2 a cos(x) + 1) and 2 pi log(a) goes to 0 when a goes to infinity.
- evouga 5y agoAs far as I can tell, it's not trivial, but can be derived by repeatedly exploiting symmetries of the trig functions and properties of logarithms. One observation is that by symmetry int_0^pi ln[1 - cos(x)] dx = int 0^pi ln[1 + cos(x)] dx and so the calculation is equivalent to 1/2 int_0^pi ln[ sin(x)^2 ] dx = 2 int_0^pi/2 ln[ sin(x) ] dx. Now we can use a similar trick again: int_0^pi/2 ln[ sin(x) ] dx = int_0^pi/2 ln[ cos(x) ] dx so 4 int_0^pi/2 ln[ sin(x) ] dx = 2 int_0^pi/2 ln[ sin(x) cos(x) ] = 2 int_0^pi/2 ln[1/2] dx + 2 int_0^pi/2 ln[sin(2x)] dx = - pi ln[2] + int_0^pi ln[sin(u)] du (using substitution u = 2x) = -pi ln[2] + 2 int_0^pi/2 ln[ sin(x) ] dx and so the original integral is -pi ln[2].
- kinkrtyavimoodh 5y agoI think it's not obvious but it reduces to a relatively 'common' integral. 1 - cos(x) can be written as 2*cos^2(x/2) Take the logarithm and you get 2ln (cos(x/2)), which is relatively common and the solution is https://www.quora.com/How-do-I-integrate-log-cos-x-from-0-to-pi-2 https://www.quora.com/How-do-I-integrate-log-cos-x-from-0-to...
- dynm 5y agoThis is fantastic. I’ve tried several times to understand this idea over the years, with no success. This clearly expressed the idea in only a few minutes. One question: It mentions that Wolfram alpha will fail on integrals that this trick can work for. Is that just because it will time out (we need more compute) or is the trick difficult to automate?
- nimish 5y agoA little bit of both. I don't think WA uses the full Risch algo, but even then, enough pattern matching rules https://rulebasedintegration.org/ https://rulebasedintegration.org/ beats it in perf. Differentiation under the integral sign only works for certain well behaved functions and isn't easy to automate since you now need to figure out where to parametrize and you don't have good structure theorems to help you. IMO contour integration is a more powerful and easier to intuit technique.
- kzrdude 5y agoAmazing website. I love that I could just click ahead and find the .pdf transcripts of the tests ran.
- Kranar 5y agoUnlike differentiation, indefinite integration is undecidable even for elementary functions so there will always be some limit to what an algorithm can compute.
- sillysaurusx 5y agoOne thing I've often wondered: Is there a reason to learn all of these methods in the modern era, when Wolfram Alpha or Mathematica can apply hundreds of methods automatically? It's good to understand things conceptually. But once I got the concept of integrals as the area under a curve, it felt like a lot of grunt work to learn so many tactics for solving them. But most of my focus has been on computers rather than pure mathematics. For pure math, it probably makes more sense to learn as many different methods as possible.
- brennanpeterson 5y agoMostly agreed, but I did like the last sentence: sometimes it is easier to solve the general problem than the specific one. That is a useful trick to keep in mind all the time. The point of course, is not to learn to solve integrals, but to learn a transferrable piece off mental jiujitsu.
- muench 5y agoIt seems yes there is a reason if you need integrals. From TFA: "You can also try having Wolfram Alpha compute it, and it will time out. We will need to be more creative."
- whatshisface 5y agoMathematica/Maple/Sagemath don't have a freemium timeout mechanic and can solve a lot more. Truth be told I think that integration techniques are much less broadly crucial for everyone to learn than they used to be, although you need to have some clue of what's going on because you need to be able to guide yourself towards posing problems in such a way that the integrals that can be solved.
- dragonwriter 5y ago> Mathematica/Maple/Sagemath don't have a freemium timeout mechanic and can solve a lot more. Mathematica/Maple don't have freemium timeouts because they are not free; Sagemath, OTOH, is a good point.
- rtomanek 5y agohttps://outline.com/XZ93MY https://outline.com/XZ93MY
- motohagiography 5y agoIf you don't have the background to get this, here's a quick tutorial on integrals https://cognicull.com/en/1dc797za https://cognicull.com/en/1dc797za , and it would be cool if cognicull included this Feynman's method in their ontology.
- wly_cdgr 5y agoReally cool site, thanks
- SamBam 5y agoA very interesting way to show information and to aid learning. I haven't explored it much, but I do feel like this could be great, but isn't quite fleshed out yet. I think the tree is very difficult to navigate without being able to see what each bubble represents before clicking on it. Also, since the site contains so much content, it would be nice if it could remember what you have understood (and maybe still show it grayed out, instead of the permanent-seeming deletion of nodes).
- motohagiography 5y agoInterestingly, they have precisely that functionality, where you can "prune" nodes as you learn them, and scrolling down the page gives very good articles on each topic. It was an HN post a while ago and I revisit it to look up refreshers on math concepts in articles like this Feynman one.
- SamBam 5y agoRight, I saw that, I was just nit-picking the "prune" UX. I'd far prefer to gray things out, not delete them for what seems to be for good.
- foolfoolz 5y agoi’m so relieved i don’t have to do math like this anymore
- Synaesthesia 5y agoI think that when you're doing it for recreation or to practise problem solving it's probably a lot nicer than at school.
- fjert 5y agoI've forgotten how to do most of it and when I look at it now it's hard to believe I was ever able to.
- renewiltord 5y agoI recall learning this for an entrance exam and it was a right proper nightmare. Fifteen years ago and still terrifies me.
- strictnein 5y agoSame. I was honestly getting anxious looking through all of that.
- mywittyname 5y agoThis reminds me of how much I struggled with integral calc in college. My textbook (Stewart) had a table of integrals containing 120 forms that you'd need to solve the problems in the book, and looking through them, the calculations seem so insurmountable. Like, https://www.wolframalpha.com/input/?i=integrate+u%5En+sqrt%28a+%2B+bu%29+du https://www.wolframalpha.com/input/?i=integrate+u%5En+sqrt%2... I looked at that and realize that I'd have no future as a physicist and switched to CS.
- scrozart 5y agoIME, Stewart is pretty opaque. The intro section is a great refresher of things you'll need, but the remaining text is pretty muddy. I found an old Thomas Finney book that was much clearer, as was Richard Delaware's YouTube series.
- runawaybottle 5y agoSame textbook. The amount auxiliary material I needed to watch off YouTube to grok it was very real. I had one of those impenetrable profs that only explained calc in the most theoretical terms.
- BearOso 5y agoI think the teachers who choose Stewart books don’t necessarily know how to teach down very well, so that would probably be reflected in their lectures, too. In multi-variable calculus I had a Stewart book and the professor put me to sleep. I spent a lot more time figuring it out on my own than I should have. I was too naive to do so, but if anyone out there is in a class and the official suggested book doesn’t help you, ask the Internet for a respected alternative.
- joshka 5y agoI had good teachers and Stewart and did pretty well (2001-ish, not sure how that translates, just one counter point - sorta)
- siraben 5y ago
- ofrzeta 5y agoIn Germany there's a proverb: "Differenzieren ist Handwerk, Integrieren ist Kunst" - differentiation is craft, integration is an art.
- lapetitejort 5y agoBest exemplified by x^x. Differentiation is tricky but doable. Integration is impossible.
- AnimalMuppet 5y agoDepends on your definition of "impossible" ;-) In high school, I transformed x^x into e^(x log x), expanded that into the Taylor series, and integrated term by term. I got a "solution", but it wasn't closed form - it was an infinite series. And, for a given error limit, it probably converged more slowly than a decent numerical integration. So, not worth much. But I "solved" it...
- dhosek 5y agoIn English too. I remember my high school calc teacher saying this (except IIRC it was differentiation is science, not craft).
- maxnoe 5y agoRelevant xkcd: https://xkcd.com/2117/ https://xkcd.com/2117/
- Agingcoder 5y agoWhile the technique is powerful, it may also not work : there are conditions to check to be allowed to differentiate under the integral sign.
- siraben 5y agoA lot of undergraduate math programs in the US start with unnecessarily hard calculus classes "weed-outs" which is unfortunate, since it discourages students who might have pursued mathematics otherwise. I can say from personal experience that Calculus II was my worst math grade, I fared much better in rigorous and challenging classes like real analysis or differential topology. To do well in elementary calculus one has to seemingly practice integration techniques in various permutations for hours, and honestly for what future purpose I cannot say. EDIT: I finally understood calculus after taking introduction to real analysis, and it was amazing because for the first time all the hand-waving disappeared and could be replaced with rock-solid arguments and increasing levels of abstraction (starting from the very definition of what the real numbers are). This is also important because functions can get very pathological[0][1][2] [0] https://en.wikipedia.org/wiki/Weierstrass_function https://en.wikipedia.org/wiki/Weierstrass_function (continuous everywhere but differentiable nowhere) [1] https://en.wikipedia.org/wiki/Cantor_function https://en.wikipedia.org/wiki/Cantor_function (derivative is zero almost everywhere but f(x) goes from 0 to 1) [2] https://en.wikipedia.org/wiki/Thomae's_function https://en.wikipedia.org/wiki/Thomae's_function (continuous at irrationals but discontinuous on rationals)
- cameldrv 5y agoMy college roommate called this "Blue Collar Mathematics."
- djmips 5y agoWhat in particular was being referred to as blue collar and what's the analogy?
- ptmcc 5y agoI quite like math, but I hated the college-level calc series. I had to struggle to just pull of a B average, even though I thoroughly understood the concepts. I went on to apply calculus and diff eqs in higher level classes quite successfully, where the rote memorization isn't the point. But those weed-out classes test a bunch of arcane mechanics and memorized formulas and transformations in the most intentionally obtuse exam questions possible. If you don't know the "one weird trick" you're kind of screwed. Math weed-out classes are a lot like the tech interview problem, but for STEM majors.
- paulpauper 5y agoIt worked for this one because we knew the answer beforehand and the best approach. Its not like we can generalize this. Change some of the terms and poof unsolvable
- kccqzy 5y agoThat's true in general for all integrals. Method A solves this formidable looking integral nicely and simply. Make one small change, method A completely fails and now you'd need method B to solve it, which is not at all related to method A.
- ChuckMcM 5y agoFunny story, I was a huge fan boi of Feynman's and read everything I could about him. I used this technique to integrate the "extra credit" problem on my freshman final, which I turned in with about 20 minutes to spare, and the professor accused me of cheating by knowing the answer ahead of time. When I showed him the steps and explained the origins he allowed that perhaps I hadn't cheated, but was disappointed I had used a technique that wasn't taught in class so that was somewhat unfair to the other students. Not my best professor.
- bongoman37 5y agoHow is knowing the answer 'cheating' by any stretch of that word?
- ChuckMcM 5y agoThe assertion was that I had somehow acquired the answers to the test before I took the test. The evidence for that, flimsy as it was, was that I finished the test "too quickly to have done the work." Getting the answers before the test was the alleged cheating.
- regularfry 5y agoWhat was frustrating to me, in the days before this sort of thing was all over YouTube, was reading that Feynman had a magical technique in biographies and so on, but not being able to find any reference to what the damn trick was.
- acchow 5y ago> When I showed him the steps and explained the origins Did you not put the steps on the paper you submitted?
- ChuckMcM 5y agoNot enough apparently. But to be fair, as a freshman in a college calculus class that was essentially reviewing what I had already done in high school I was kind of an asshole. I skipped a lot of his classes and often did the formulaic questions in my head and just wrote down the answer. I don't recommend this approach.
- marosgrego 5y agoActually, this method was already used by Leibniz, although it was not that common at Feynman's time. https://en.wikipedia.org/wiki/Leibniz_integral_rule https://en.wikipedia.org/wiki/Leibniz_integral_rule
- alisonkisk 5y agoYes, that's the first sentence of the main article body. > Today’s article is going to discuss an obscure but powerful integration technique most commonly known as differentiation under the integral sign, but occasionally referred to as “Feynman’s technique” due to his popularization of this technique in his book, and properly known as the Leibniz Integral Rule.
- jacobwilliamroy 5y agoWhat's the difference between "an arbitrary constant" and "a variable"?
- analog31 5y agoThe definition is arbitary. And it varies. ;-) Both are symbols. The difference is kind of subjective, and has to do with how you treat the symbol. Do you just carry it through your derivation, or are you interested in what happens when you feed it specific values? But I believe your objection is valid. And to be honest I got all the way through a college math major by just treating everything as symbol manipulation. Caring about numerical values was for my other major, physics.
- Koshkin 5y agoIn programmer's terms, an (arbitrary) constant is a parameter. (A variable is, well, a variable.)
- dang 5y agoPast related threads: Differentiation Under Integral Sign (2015) [pdf] - https://news.ycombinator.com/item?id=26123750 https://news.ycombinator.com/item?id=26123750 - Feb 2021 (59 comments) Feynman's Integral Trick - https://news.ycombinator.com/item?id=26040353 https://news.ycombinator.com/item?id=26040353 - Feb 2021 (6 comments) Richard Feynman's Integral Trick - https://news.ycombinator.com/item?id=21055728 https://news.ycombinator.com/item?id=21055728 - Sept 2019 (8 comments) Richard Feynman's Integral Trick - https://news.ycombinator.com/item?id=17558752 https://news.ycombinator.com/item?id=17558752 - July 2018 (35 comments)
- Trung0246 5y agoI don't really understand the part from how did the author jumps from -pi*(1+a^2)/(1-a^2) to df/da = 2pi/a. Anyone knows how the author did it?
- quibono 5y agoNotice that it is actually df/da = (pi/a) - (1/a) (1-a^2)/(1+a^2) int_0^pi (1 - (1-a^2) / (1 + a^2 + 2 a cosx) dx. It is that right integral that is equal to -pi (1+a^2)/(1-a^2). So when you add you get: pi/a - 1/a (1-a^2)/(1+a^2) * (-pi (1+a^2)/(1-a^2)) = pi /a - (-pi/a) = 2 pi/a
- gglon 5y agoIn Mathematica 12.3: Integrate[Log[1 - 2 a Cos[x] + a^2], {x, 0, Pi}, Assumptions -> Abs[a] >= 1 && a \[Element] Reals] gives the correct answer -\[Pi] Log[1/a^2]
- gobrewers14 5y agoThe first integral can be solved replacing the integrand with a series of sort. Notice that the expression inside the logarithm has zeros at $\alpha = e^{\pm ix}$ So we can rewrite the function we're integrating as $log((\alpha - e^{ix})(\alpha - e^{-ix}))$ which is just $2log(\alpha) + log(1 - \frac{e^{ix}}{\alpha}) + log(1 - \frac{e^{-ix}}{\alpha})$ Using $log(1 - x) = -\sum_{n=1}^{\infty} \frac{x^n}{n}$ We get $2log(\alpha) - \sum\frac{e^{inx}}{n\alpha^{n}}-\sum\frac{e^{-inx}}{n\alpha^{n}}$ which is just $2log(\alpha) -2\sum \frac{cos(nx)}{n\alpha^n}$ The integral of the second half of this involves a $sin(nx)$ term which will evaluate to zero for all values of \alpha at 0 and \pi. Leaving just the integral of $2log(\alpha)$ which is just $2\pi log(\alpha)$
- arcadi7 5y agothe funny thing is that the calculation in this article misses the point, especially in the Feynman context. First, beyond all trickery, the log(alpha) answer might suggest that something bad happens at alpha=0 . What makes this integral interesting is that it is equal to zero identically for alpha<1 . The reason, of course, is that this integral is not randomly chosen -- it represents the two-dimensional coulomb potential (log(r)) of the sphere (circle) of radius 1 at distance alpha from the center. By when point alpha is inside the circle , the potential is constant (or zero -- no force) . When alpha is outside, the potential is log(r) as if all the mass of a circle is at its center. The expression under the log in the integral is just (square of ) the distance between the point alpha and point on a unit circle. beyond tricks -- the physical reason for the singular behavior of this integral is gauss theorem for coulomb potential . so no magic.
- maest 5y agoA think I've been wondering is why is integration harder than differentiation. The latter can be done almost mechanically, as long as your primitive functions are "nice", but the former often requires cleverness like what's show in the article. I mean, sure, we have simpler rules for dfferentiation, but _why_? I sometimes wonder if it's differentiation is P and integration is NP (for the restricted case of functions where the primitives are "nice")
- dmurray 5y ago> I sometimes wonder if it's differentiation is P and integration is NP (for the restricted case of functions where the primitives are "nice") It's something pretty close to this. Almost all mathematical expressions can't be integrated (up to the reader to formalise the definitions here). That is not quite the same claim as saying that the best method for solving an arbitrary integral is trial and error by systematically differentiating other expressions until you find the antiderivative.
- joppy 5y agoDifferentiation is a function that takes a function and spits out a different one. (This may fail at points, but wherever the function is smooth enough, you get a corresponding point on the derivative). It is relatively simple to define, if somewhat laborious to make precise (real analysis etc). The most straightforward definition of indefinite integration on the other hand is “the inverse of differentiation”. Like a lot of functions, inverses are much more complicated. Even in the case of matrix-vector multiplication, the inverse function (the inverse matrix) has an expression in terms of determinants in the original entries of the matrix - much more complicated than the original problem. So I think that it’s the more simple theme of: even if the function is easy to describe, its inverse may be extremely complicated.
- Kranar 5y agoYou could always say integration is a function that takes a function and spits out another one, and differentiation is the inverse of integration. There's no intrinsic reason why an inverse is anymore difficult or why the derivative is the "base" and integration is the inverse. The more abstract reason differentiation is easier than integration is that because differentiation is a local operation, given a family of functions differentiation will be closed within that family. That is the derivative of an elementary function is an elementary function, the derivative of a rational function is a rational function, the derivative of a function f is a function f' that is within the same family of f and will share almost all of the same properties as f. Integration on the other hand does not have this property, and in fact it's very difficult to find family of functions that are closed under integration. The integral of a rational function may not be rational, the integral of an elementary function may not be elementary. Integration is a global operation whose solution may require the construction of a new family of functions whose properties are entirely unlike the function being integrated. It's like how squaring a number is usually closed within that number system, but taking the square root of a number could require creating entirely new number systems, whether it's real numbers or complex numbers (at which point the square root is closed). With integration, the issue is that it never ends up being closed, you can use integration on a family of functions to jump out of that family and construct entirely new families of functions seemingly without end. In a way, differentiation produces functions whose properties are a subset of the original function, but integration produces functions whose properties expand upon the original function.
- koningrobot 5y agoInteresting example they chose there. It requires no fewer than three deus ex machinas: apply this trick, then apply this very particular substitution, then find another substitution. If you encountered this integral in the wild without knowing whether/how it can be solved, yes you might have tried the trick, but you wouldn't realize that it had gotten you anywhere. Would you continue on and find the just-so substitutions, or would you backtrack and try something else? It's great that we have the tricks we have, but at the same time most nontrivial integrals are just impenetrable regardless. Any demonstration of integration techniques you find will be on an integrand that is amenable to these techniques, and will only show the straight path to the solution, not the process of finding that path. I hate integrals!