Factorials! Stirling s formula



Similar documents
Question 3: How do you find the relative extrema of a function?

CPS 220 Theory of Computation REGULAR LANGUAGES. Regular expressions

5 2 index. e e. Prime numbers. Prime factors and factor trees. Powers. worked example 10. base. power

New Basis Functions. Section 8. Complex Fourier Series

5.4 Exponential Functions: Differentiation and Integration TOOTLIFTST:

by John Donald, Lecturer, School of Accounting, Economics and Finance, Deakin University, Australia

Section 7.4: Exponential Growth and Decay

SPECIAL VOWEL SOUNDS

Mathematics. Mathematics 3. hsn.uk.net. Higher HSN23000

The example is taken from Sect. 1.2 of Vol. 1 of the CPN book.

Lecture 3: Diffusion: Fick s first law

Econ 371: Answer Key for Problem Set 1 (Chapter 12-13)

A Note on Approximating. the Normal Distribution Function

QUANTITATIVE METHODS CLASSES WEEK SEVEN

AP Calculus AB 2008 Scoring Guidelines

Version 1.0. General Certificate of Education (A-level) January Mathematics MPC3. (Specification 6360) Pure Core 3. Final.

Basis risk. When speaking about forward or futures contracts, basis risk is the market

Repulsive Force

(Analytic Formula for the European Normal Black Scholes Formula)

ME 612 Metal Forming and Theory of Plasticity. 6. Strain

Remember you can apply online. It s quick and easy. Go to Title. Forename(s) Surname. Sex. Male Date of birth D

Traffic Flow Analysis (2)

Parallel and Distributed Programming. Performance Metrics

Problem Set 6 Solutions

Financial Mathematics

Adverse Selection and Moral Hazard in a Model With 2 States of the World

Category 7: Employee Commuting

C H A P T E R 1 Writing Reports with SAS

Chapter 10 Function of a Matrix

Foreign Exchange Markets and Exchange Rates

AP Calculus Multiple-Choice Question Collection connect to college success

Lecture 20: Emitter Follower and Differential Amplifiers

HOMEWORK FOR UNIT 5-1: FORCE AND MOTION

Cloud and Big Data Summer School, Stockholm, Aug., 2015 Jeffrey D. Ullman

FACULTY SALARIES FALL NKU CUPA Data Compared To Published National Data

Introduction to Finite Element Modeling

CHAPTER 4c. ROOTS OF EQUATIONS

Intermediate Macroeconomic Theory / Macroeconomic Analysis (ECON 3560/5040) Final Exam (Answers)

Lecture notes: 160B revised 9/28/06 Lecture 1: Exchange Rates and the Foreign Exchange Market FT chapter 13

Fundamentals: NATURE OF HEAT, TEMPERATURE, AND ENERGY

Usability Test of UCRS e-learning DVD

Magic Message Maker Amaze your customers with this Gift of Caring communication piece

Van der Waals Forces Between Atoms

Higher. Exponentials and Logarithms 160

Noise Power Ratio (NPR) A 65-Year Old Telephone System Specification Finds New Life in Modern Wireless Applications.

Long run: Law of one price Purchasing Power Parity. Short run: Market for foreign exchange Factors affecting the market for foreign exchange

LAB 3: VELOCITY AND ACCELERATION GRAPHS

CPU. Rasterization. Per Vertex Operations & Primitive Assembly. Polynomial Evaluator. Frame Buffer. Per Fragment. Display List.

Projections - 3D Viewing. Overview Lecture 4. Projection - 3D viewing. Projections. Projections Parallel Perspective

Why An Event App... Before You Start... Try A Few Apps... Event Management Features... Generate Revenue... Vendors & Questions to Ask...

Performance Evaluation

Sharp bounds for Sándor mean in terms of arithmetic, geometric and harmonic means

Important Information Call Through... 8 Internet Telephony... 6 two PBX systems Internet Calls... 3 Internet Telephony... 2

Outside Cut 1 of fabric Cut 1 of interfacing

Who uses our services? We have a growing customer base. with institutions all around the globe.

Upper Bounding the Price of Anarchy in Atomic Splittable Selfish Routing

In the previous two chapters, we clarified what it means for a problem to be decidable or undecidable.

[ ] These are the motor parameters that are needed: Motor voltage constant. J total (lb-in-sec^2)

MAXIMAL CHAINS IN THE TURING DEGREES

ESCI 241 Meteorology Lesson 6 Humidity

81-1-ISD Economic Considerations of Heat Transfer on Sheet Metal Duct

union scholars program APPLICATION DEADLINE: FEBRUARY 28 YOU CAN CHANGE THE WORLD... AND EARN MONEY FOR COLLEGE AT THE SAME TIME!

Sci.Int.(Lahore),26(1), ,2014 ISSN ; CODEN: SINTE 8 131

Fetch. Decode. Execute. Memory. PC update

CIRCUITS AND ELECTRONICS. Basic Circuit Analysis Method (KVL and KCL method)

Expert-Mediated Search

YOUR MATARIKI KETE PRIMARY EDITION. Learn about Matariki. How do you find it in the sky and why is it important?

Free ACA SOLUTION (IRS 1094&1095 Reporting)

June Enprise Rent. Enprise Author: Document Version: Product: Product Version: SAP Version:

Job shop scheduling with unit processing times

Precise Memory Leak Detection for Java Software Using Container Profiling

Physics 106 Lecture 12. Oscillations II. Recap: SHM using phasors (uniform circular motion) music structural and mechanical engineering waves

Integrals of Rational Functions

STATEMENT OF INSOLVENCY PRACTICE 3.2

k e e n - n o t e s Annual Meeting, Saturday 7/13/2013 roxana fire Station 10: 00 am February 2013 Keen-Wik Association

The price of liquidity in constant leverage strategies. Marcos Escobar, Andreas Kiechle, Luis Seco and Rudi Zagst

A Theoretical Model of Public Response to the Homeland Security Advisory System

Analyzing the Economic Efficiency of ebaylike Online Reputation Reporting Mechanisms

Planning and Managing Copper Cable Maintenance through Cost- Benefit Modeling

QUALITY OF DYING AND DEATH QUESTIONNAIRE FOR NURSES VERSION 3.2A

Gold versus stock investment: An econometric analysis

Constraint-Based Analysis of Gene Deletion in a Metabolic Network

Budget Optimization in Search-Based Advertising Auctions

The Constrained Ski-Rental Problem and its Application to Online Cloud Cost Optimization

Continuity Cloud Virtual Firewall Guide

Type Inference and Optimisation for an Impure World.

Entity-Relationship Model

Incomplete 2-Port Vector Network Analyzer Calibration Methods

Production Costing (Chapter 8 of W&W)

Using SAS s PROC GPLOT to plot data and lines

The Neolithic transition, a major episode in human history, is

Estimating Powers with Base Close to Unity and Large Exponents

Current and Resistance

E X C H A N G E R U L E S A N D C L E A R I N G R U L E S O F N A S D A Q O M X D E R I V A T I V E S M A R K E T S

CAFA DIVERSITY JURISDICTION

Introduction. Appendix D Mathematical Induction D1

Transcription:

Author s not: This articl may us idas you havn t larnd yt, and might sm ovrly complicatd. It is not. Undrstanding Stirling s formula is not for th faint of hart, and rquirs concntrating on a sustaind mathmatical argumnt ovr svral stps. Evn if you ar not intrstd in all th dtails, I hop you will still glanc through th articl and find somthing to piqu your curiosity. If you ar intrstd in th dtails, but don t undrstand somthing, you ar urgd to pstr your mathmatics tachr for hlp. Factorials! Unblivably larg numbrs ar somtims th answrs to innocnt looking qustions. For instanc, imagin that you ar playing with an ordinary dck of 52 cards. As you shuffl and r-shuffl th dck you wondr: How many ways could th dck b shuffld? That is, how may diffrnt ways can th dck b put in ordr? You rason that thr ar 52 choics for th first card, thn 51 choics for th scond card, thn 50 for th third card, tc. This givs a total of 52 51 50 2 1 ways to ordr a dck of cards. W call this numbr 52 factorial and writ it as th numral 52 with an xclamation point: 52! This numbr turns out to b th 68 digit monstr 80658175170943878571660636856403766975289505440883277824000000000000 which mans that if vry on on arth shuffld cards from now until th nd of th univrs, at a rat of 1000 shuffls pr scond, w wouldn t vn scratch th surfac in gtting all possibl ordrs. Whw! No wondr w us xclamation marks! For any positiv intgr n w calculat n factorial by multiplying togthr all intgrs up to and including n, that is, n! = 1 2 3 n. Hr ar som mor xampls of factorial numbrs: 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880 10! = 3628800 Stirling s formula Factorials start off rasonably small, but by 10! w ar alrady in th millions, and it dosn t tak long until factorials ar unwildly bhmoths lik 52! abov. Unfortunatly thr is no shortcut formula for n!, you hav to do all of th multiplication. On th othr hand, thr is a famous approximat formula, namd aftr th Scottish mathmatician Jams Stirling 1692-1770), that givs a prtty accurat ida about th siz of n!. Stirling s formula: n! n 2πn

Bfor w continu, lt s tak a momnt to contmplat th fact that n factorial involvs nothing mor sophisticatd than ordinary multiplication of whol numbrs, which Stirling s formula rlats to an xprssion involving squar roots, π th ara of a unit circl), and th bas of th natural logarithm). Such ar th surpriss in stor for studnts of mathmatics. Hr is Stirling s approximation for th first tn factorial numbrs: 1! 0.92 2! 1.92 3! 5.84 4! 23.51 5! 118.02 6! 710.08 7! 4980.39 8! 39902.39 9! 359536.87 10! 3598695.62 You can s that th largr n gts, th bttr th approximation proportionally. In fact th approximation 1! 0.92 is accurat to 0.08, whil 10! 3598695.62 is only accurat to about 30,000. But th proportional rror for 1! is 1!.92)/1! =.0800 whil for 10! it is 10! 3598695.62)/10! =.0083, tn tims smallr. This is th corrct way to undrstand Stirling s formula, as n gts larg, th proportional rror n! 2πnn/ )/n! gos to zro. Dvloping approximat formulas is somthing of an art. You nd to know whn to b sloppy and whn to b prcis. W will mak two attmpts to undrstand Stirling s formula, th first uss asir idas but only givs a sloppy vrsion of th formula. W will follow that with a mor sophisticatd attack that uss knowldg of calculus and th natural log function. This will giv us Stirling s formula up to a constant. Attmpt 1. To warm up, lt s look at an approximation for th xponntial function x. Th functions 1 + y and y hav th sam valu and th sam slop whn y = 0. This mans that 1 + y y whn y is nar zro, ithr positiv or ngativ. Applying this approximation to x/n, for any x but larg n, givs 1 + x/n x/n. Now if w tak n 1st powr on both sids, w gt th approximation 1 + x n 1 n 1)x/n x. Rturning to factorials, w bgin with an obvious uppr bound. Th numbr n! is th product of n intgrs, non biggr than n, so that n! n n. With a bit mor car, w can writ n! prcisly as a fraction of n n as follows: n! = 1 1 ) 1 1 1 2 1 2 3) n) 1 n 1 n n. I won t dpriv you of th plasur of working out th algbra to confirm that this formula is rally corrct. Using th approximation for th xponntial function x w can rplac ach of th factors 1 1/k) k 1 by 1 and arriv at n! n/. Bcaus of cumulativ rrors, th formula n/ sorly undrstimats n!, but it dos hav th right ordr of magnitud and xplains whr th factor coms from. Attmpt 2. Mathmatically, addition is asir to handl than multiplication so our nxt attmpt to gt Stirling s formula convrts it into an addition problm by taking logs. Our

warmup problm this tim is an approximat formula for th natural log function. W start with th sris xpansion ) 1 1 + x 2 ln = x + x3 1 x 3 + x5 5 + x7 7 +. Substitut x = 1/2j + 1) and rarrang to gt j + 1 ) 1 1 = 2 j 32j + 1) + 1 2 52j + 1) + 1 4 72j + 1) 6 Now rplacing th squnc of odd numbrs 3, 5, 7,... by th valu 3 in th dnominator maks th rsult biggr, so w hav th inquality j + 1 ) 1 1 ) 1 2 j 3 2j + 1) + 1 2 2j + 1) + 1 4 2j + 1) + 6 Th sum on th right taks th form of th famous gomtric sris ρ + ρ 2 + ρ 3 + = ρ 1 ρ. Making th rplacmnt ρ = 1/2j + 1) 2 and a littl algbra yilds j + 1 ) 1 1 ) 2j + 1) 2 = 1 2 j 3 1 2j + 1) 2 12 1 j 1 j + 1 ). 1) All that work to show that j + 1/2) ln1 + 1/j) 1 is prtty clos to zro. If you ar inclind, you could program your computr to calculat both sids of 1) for various valus of j, just to chck that th right hand sid rally is biggr than th lft. Not that w hav an uppr bound in 1), instad of an approximat formula. This mans that th valus on th two sids ar not ncssarily clos togthr, only that th valu on th right is biggr. You will b rlivd to har that w ar finally rady to rturn to Stirling s approximation for n!. Taking th natural log on both sids of n! = 1 2 n, turns th multiplication into addition: lnn!) = ln1) + ln2) + + lnn). This sum, in turn, is th ara of th first n 1 rctangls picturd hr. Th curv in th pictur is lnx), and it rminds us that ln1) = 0... 1 2 3 n 1 n

Th ara of ach rctangl is th ara undr th curv, plus th ara of th triangl at th top, minus th ovrlap. In othr words, using th dfinitions blow w hav r j = c j +t j ε j. rctangl := r j = lnj + 1) curv := c j = j+1 j lnx) dx triangl := t j = 1 [lnj + 1) lnj)] 2 ovrlap := ε j = j + 1 ) 1 2 j Th ovrlap ε j is a small slivr shapd rgion that is barly visibl in th pictur, xcpt in th first rctangl. Using th inquality 1) w workd so hard to stablish, w add up on both sids and s that th infinit sris satisfis j=n ε j < 1/12n), for any n = 1, 2, 3,.... To approximat lnn!) = n 1 r j, w bgin by splitting r j into parts n 1 n 1 n 1 lnn!) = c j + t j ε j. Sinc n 1 c j is an intgral ovr th rang 1 to n, and n 1 t j is a tlscoping sum, this simplifis to lnn!) = Taking th xponntial givs n 1 lnx) dx + 1 n 1 2 lnn) = n lnn) n + 1 + 1 2 lnn) ε j n! = 1 ε j n n ε j j=n ε j ε j ). Paus to not that this is an xact quation, not approximat. It givs n! as th product of an unknown constant, th trm n n/, and a trm j=n ε j that convrgs to 1 as n. With th formula j=n ε j < 1/12n) w now hav th bounds C n n 1 n n! C n 12n, whr 11 12 C. Onc w v idntifid C = 2π, w gt j=n 2πn n n! 2πn n 1/12n

If you v mad it this far, congratulations! Now you s why Stirling s formula works. Th part w skippd, to show that th unknown constant C is actually qual to 2π is not an asy stp. But w lav this asid, and look at som othr proprtis of th numbr n!. Numbr of digits For any x > 0 th formula dx) = log 10 x) + 1 givs th numbr of digits of x to th lft of th dcimal point. For modrat sizd factorials w can simply plug this formula into a computr to s how many digits n! has. For xampl, d52!) = 68 and d1000000!) = 5565709. But suppos w wantd to find th numbr of digits in a rally larg factorial, say googol factorial? Googol mans tn raisd to th powr 100 or 10 100 ). Evn a computr can t calculat googol factorial, so w must us Stirling s formula. Lt g = 10 100, substitut into Stirling s formula, and tak log bas 10) on both sids to obtain log 10 g ) g) 2πg log10g!) log g ) g 10 2πg 1/12g ). Lt s concntrat on th lft sid log 10 2πgg/) g ). Using th logarithm proprty and th fact that log 10 g) = 100, w simplify this to log 10 2π) + 50 + g100 log 10 )). Th hard part of this calculation is to find log 10 ) to ovr 100 dcimal placs, but th computr is happy to do it for us. Onc this is accomplishd w find that log 10 2πgg/) g ) = 99565705518096748172348871081083394917705602994196333433 8855462168341353507911292252707750506615682567.21202883... Whn w knock off th dcimal part and add 1, w gt d 2πgg/) g ). W can b sur that th numbr of digits in googol factorial is th sam by comparing with th uppr bound. Th right hand sid log 10 2πgg/) g 1/12g ) xcds th lft hand sid only by th minuscul amount log 10 1/12g ) = log 10 )/12g. Whn this is addd to th fractional part.21202883..., th first hundrd or so digits aftr th dcimal point ar not changd. Thrfor d 2πgg/) g 1/12g ) is qual to d 2πgg/) g ), and sinc dg!) is in btwn, it also must b th sam. Raising 10 to th powr of th fractional part.21202883... givs us th first fw digits of g!, so w conclud that googol factorial is g! = 16294 00000, whr th dots stand in for th rst of th xactly dg!)=995657055180967481723488710810833949177056029941963334338855462168341353507911292252707750506615682568 digits. This xplains why no on can or vr will calculat all th digits of googol factorial. Whr would you put it? A library filld with books containing nothing but digits? A trillion trillion computr hard drivs? Non of ths puny containrs could hold it. This supr-monstr has mor digits than th numbr of atoms in th univrs. Trailing zros Looking back, you may notic that 52! nds with a stram of zros. For that mattr, all th factorials starting with 5!, hav zros at th nd. Lt s try to

figur out how many zros thr will b at th nd of n!. This dosn t rly on approximat valus of n! anymor, mor importantly w nd to undrstand th divisors of n!. Each zro at th nd of n! coms from a factor of 10. For instanc, 10! has two zros at th nd, on of which coms from multiplying th 2 and th 5. 10! = 1 2 3 4 5 6 7 8 9 10 = 1 3 4 6 7 8 9) 2 5) 10 = 36288) 100) Th fact that 36288 is an vn numbr mans that thr ar xtra factors of 2 that don t gt matchd with any 5 s. Sinc thr is always an xcss of 2 s, th numbr of trailing zros in n! is qual to th numbr of 5 s that go into n!. Imagin lining up all th numbrs from 1 to n to b multiplid. You will notic that vry fifth numbr contributs a factor of 5, so th total numbr of 5 s that factor n! should b about n/5. Sinc this isn t an intgr, w knock off th fractional part and rtain n/5. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 n According to this formula, th numbr of trailing zros in 10! is 10/5 = 2, and that chcks out. But for 52! th formula givs 52/5 = 10, whn thr ar rally 12 trailing zros. What s going on? Th problm is that w forgot to tak into account that th numbr 25 contributs two factors of 5, and dos 50. That s whr th xtra two zros com from. Now w modify our formula for th numbr of trailing zros in n! to zn) = n/5 + n/25 + n/125 + n/625 + W hav anticipatd that all multipls of 125 giv thr factors of 5, multipls of 625 giv four factors of 5, tc. Also not that if n is lss than 25, for instanc, thn th formula n/25 automatically rturns a zro. W can gt an uppr bound on th numbr of zros by not knocking off th fractional part of n/5 j and using th gomtric sris zn) = n 5 j n 5 j = n 4. This turns out to b prtty clos to th right answr. In othr words, th numbr of trailing zros in n! is approximatly n/4. For xampl, th numbr of trailing zros in googol factorial works out to b xactly zg) = g/4 18 or 24999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999982.