Class 19: Golden Ages and Astrophysics CS200: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans.
Download ReportTranscript Class 19: Golden Ages and Astrophysics CS200: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans.
Class 19: Golden Ages and Astrophysics CS200: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans Astrophysics • “If you’re going to use your computer to simulate some phenomenon in the universe, then it only becomes interesting if you change the scale of that phenomenon by at least a factor of 10. … For a 3D simulation, an increase by a factor of 10 in each of the three dimensions increases your volume by a factor of 1000.” • How much work is astrophysics simulation (in notation)? When we double the size of the 3 (n ) 23 February 2004 simulation, the work octuples! (Just like oceanography octopi simulations) CS 200 Spring 2004 2 Orders of Growth 1200 1000 simulating universe logn n nlogn n^2 800 600 400 n^3 200 bubblesort insertsort-tree 0 1 2 23 February 2004 3 4 5 6 7 CS 200 Spring 2004 8 9 10 3 Astrophysics and Moore’s Law • Simulating universe is (n3) • Moore’s law: computing power doubles every 18 months • Tyson: to understand something new about the universe, need to scale by 10x • How long does it take to know twice as much about the universe? 23 February 2004 CS 200 Spring 2004 4 Knowledge of the Universe ;;; doubling every 18 months = ~1.587 * every 12 months (define (computing-power nyears) (if (= nyears 0) 1 (* 1.587 (computing-power (- nyears 1))))) ;;; Simulation is (n3) work (define (simulation-work scale) (* scale scale scale)) (define (log10 x) (/ (log x) (log 10))) ;;; log is base e ;;; knowledge of the universe is log 10 the scale of universe ;;; we can simulate (define (knowledge-of-universe scale) (log10 scale)) 23 February 2004 CS 200 Spring 2004 5 Knowledge of the Universe (define (computing-power nyears) (if (= nyears 0) 1 (* 1.587 (computing-power (- nyears 1))))) ;;; doubling every 18 months = ~1.587 * every 12 months (define (simulation-work scale) (* scale scale scale)) ;;; Simulation is O(n^3) work (define (log10 x) (/ (log x) (log 10))) ;;; primitive log is natural (base e) (define (knowledge-of-universe scale) (log10 scale)) ;;; knowledge of the universe is log 10 the scale of universe we can simulate (define (find-knowledge-of-universe nyears) (define (find-biggest-scale scale) ;;; today, can simulate size 10 universe = 1000 work (if (> (/ (simulation-work scale) 1000) (computing-power nyears)) (- scale 1) (find-biggest-scale (+ scale 1)))) 23 February 2004 CS 200 Spring 2004 (knowledge-of-universe (find-biggest-scale 1))) 6 > (find-knowledge-of-universe 0) 1.0 > (find-knowledge-of-universe 1) 1.041392685158225 > (find-knowledge-of-universe 2) 1.1139433523068367 > (find-knowledge-of-universe 5) 1.322219294733919 > (find-knowledge-of-universe 10) 1.6627578316815739 > (find-knowledge-of-universe 15) 2.0 > (find-knowledge-of-universe 30) 3.00560944536028 > (find-knowledge-of-universe 60) 5.0115366121349325 > (find-knowledge-of-universe 80) 6.348717927935257 23 February 2004 Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein Will there be any mystery left in the Universe when you die? CS 200 Spring 2004 7 Any Harder Problems? • Understanding the 3 universe is (n ) • Are there any harder problems? 23 February 2004 CS 200 Spring 2004 8 Who’s the real genius? 23 February 2004 CS 200 Spring 2004 9 All Cracker Barrel Games (starting with peg 2 1 missing) Pegs Left Number of Ways 1 1550 2 20686 3 62736 4 46728 5 5688 6 374 7 82 10 2 23 February 2004 Fraction of Games IQ Rating 0.01 “You’re Genius” 0.15 “You’re Purty Smart” 0.46 “Just Plain Dumb” 0.33 0.04 “Just Plain 0.0027 Eg-no-ra-moose” 0.00058 0.00001 CS 200 Spring 2004 10 Solving the Peg Board Game • Try all possible moves • Try all possible moves from the positions you get after each possible first move • Try all possible moves from the positions you get after trying each possible move from the positions you get after each possible first move • … 23 February 2004 CS 200 Spring 2004 11 Possible Moves Start Peg board game n = number of holes Initially, there are n-1 pegs. Cracker Barrel’s game has n = 15 Assume there are always exactly 2 possible moves, how many possible games are there? 23 February 2004 CS 200 Spring 2004 12 Cracker Barrel Game • Each move removes one peg, so if you start with n-1 pegs, there are up to n-2 moves • There are at most n choices for every move: n * n * n * n * … * n = nn-2 • There are at least 2 choices for every move: 2 * 2 * 2 * … * 2 = 2n-2 23 February 2004 CS 200 Spring 2004 13 How much work is our straightforward peg board solving procedure? O n (n ) n (2 ) n n upper bound is n lower bound is 2 Important Note: I don’t know if this is the best possible procedure for solving the peg board puzzle. So the peg board puzzle problem might not be harder than understanding the Universe (but it probably is.) 23 February 2004 CS 200 Spring 2004 14 True Genius? “Genius is one percent inspiration, and ninety-nine percent perspiration.” Thomas Alva Edison “Genius is one percent sheer luck, but it takes real brilliance to be a true eg-no-ra-moose.” Cracker Barrel “80% of life is just showing up.” Woody Allen 23 February 2004 CS 200 Spring 2004 15 Orders of Growth 1200 1000 simulating universe logn n nlogn n^2 800 600 peg board game 400 n^3 2^n 200 Tuttlesort insertsort-tree 0 1 23 February 2004 2 3 4 5 6 7 CS 200 Spring 2004 8 9 10 16 Orders of Growth 70000 peg board game 60000 logn n nlogn n^2 n^3 2^n 50000 40000 30000 20000 10000 simulating universe 0 1 2 23 February 2004 3 4 5 6 7 8 9 10 11 12 13 14 15 16 TuttleSort CS 200 Spring 2004 17 Orders of Growth 1200000 1000000 logn n nlogn n^2 peg board game 800000 “intractable” 600000 400000 n^3 2^n “tractable” 200000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 simulating universe I do nothing that a man of unlimited funds, superb physical endurance, and maximum scientific knowledge could not do. – Batman (may be able to solve intractable problems, but computer scientists can only solve tractable ones for large n) Any other procedures we’ve seen that are more work than simulating the Universe? (To be continued in Lecture 20) 23 February 2004 CS 200 Spring 2004 19