# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

20 Pages

### FloTrik

Course: MATH 128, Fall 2008
School: Berkeley
Rating:

Word Count: 9548

#### Document Preview

FloTrik A File Floating-Point Trick version dated May 22, 2007 5:08 pm A Floating-Point Trick to Solve Boundary-Value Problems Faster Prof. W. Kahan Math. and Computer Sci. Depts. Univ. of Calif. @ Berkeley 0. Abstract: These notes resuscitate an old trick to accelerate the numerical solution of certain discretized boundary-value problems. Without the trick, half the digits carried by the arithmetic can be...

Register Now

#### Unformatted Document Excerpt

Coursehero >> California >> Berkeley >> MATH 128

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
FloTrik A File Floating-Point Trick version dated May 22, 2007 5:08 pm A Floating-Point Trick to Solve Boundary-Value Problems Faster Prof. W. Kahan Math. and Computer Sci. Depts. Univ. of Calif. @ Berkeley 0. Abstract: These notes resuscitate an old trick to accelerate the numerical solution of certain discretized boundary-value problems. Without the trick, half the digits carried by the arithmetic can be lost to roundoff when the discretizations grid-gaps get very small. The trick can obtain adequate accuracy from arithmetic with float variables 4-bytes wide instead of double variables 8-bytes wide. Wider data moves slower through the computers memory system and pipelines. The trick is tricky for programs written in MATLAB 7, JAVA, FORTRAN and post1985 ANSI C. The trick is easy for the original Kernighan-Ritchie C of the late 1970s, and for a few implementations of C99 that fully support IEEE Standard 754 for Binary Floating-Point. Contents: 1. Introduction: div(pgrad u) + qu = r 2. Discretizing the Differential Equation: Divided Differences 3. How Roundoff Corrupts the Discretization: 4. Accurate Residuals: 5. A Trickier Trick: 6. Example: (xu' )' + 4x(1x2)u = 0 7. The 2nd Program: preserves symmetry 8. Iterative Renement: recovers accuracy if done right 9. Conclusions: Hardly any programmers will ever know the tricks. 10. Appendix 1: accuracy despite cancellation 11. Appendix 2: tridiagonal and 2nd order despite variable gaps page 1 2 3 5 6 7 11 13 16 17 19 1. Introduction: The solution u(x) of a differential equation div(pgrad u) + qu = r is often a potential computed only to permit the subsequent computation of a vector force-eld grad u from nite-difference formulas. Because these formulas amplify errors in u it must be computed accurately enough that subsequent subtractive cancellations will not leave too few correct digits to determine grad u as accurately as it is needed. This accuracy is achieved by computing u over a sufciently rened grid of mesh-points. As we shall see, mesh renement can exacerbate the contamination of u by roundoff unless the program acts to abate that contamination. By far the simplest abatement resorts to extra-precise arithmetic. When extra precision is unavailable or too slow, the abatement must use a tricky trick exhibited in these notes. An example will show how well it works to compute the regular solution of a singular differential equation. The trick will be explained for a second-order ordinary differential equation (PU')' + QU = R with boundary conditions at the ends of some interval. The tricks application to elliptic partial differential equations, or to higher-order differential equations that determine an equilibrium solution U , entails routine elaboration needing no explanation. Further elaborating the trick to apply to parabolic and hyperbolic partial differential equations that characterize propagation may incur enough additional memory trafc to vitiate the trick; but thats a story for another day. Prof. W. Kahans notes for Math. 128B Page 1/20 File FloTrik A Floating-Point Trick version dated May 22, 2007 5:08 pm 2. Discretizing the Differential Equation: Suppose P, Q and R are scalar-valued functions of the scalar independent variable x , and Q and R may depend also upon the scalar solution U(x) of the differential equation (PU')' + QU = R . We assume that P, Q and R are smooth functions to preclude distracting complications. Choose a sequence x0 < x1 < x2 < < xN of mesh-points to span the interval over which the solution U(x) is to be computed; they can be spaced non-uniformly so long as every gap hj := xj+1 xj is small. Let uj U(xj) numerically and then set, say, pj+1/2 := P((xj+xj+1)/2), qj := Q(xj, uj) and rj := R(xj, uj) . One of several discretized approximations to the derivative (PU')' at x = xj is the difference-quotient 2( pj+1/2(uj+1 uj)/hj pj1/2(uj uj1)/hj1 )/(hj + hj1) = (PU')' + O(|hj hj1| + (hj + hj1)2) . (Eliminating the term |hj hj1| complicates the exposition without affecting the trick; see Appendix 2 below.) Substituting this approximation into the differential equation (PU')' + QU = R at every meshpoint produces an (almost) linear system (T + Diag(q))u = r of equations in which u is a column of unknowns uj , Diag(q) is a diagonal matrix computed from the elements qj and gaps hj, column r is computed from the elements rj and gaps hj , and T is a tridiagonal matrix computed from the elements pj+1/2 and gaps hj . The bottom and topmost entries in T + Diag(q) and r include contributions from the boundary-value problems boundary conditions. Sometimes Diag(q) is supplanted by a tridiagonal matrix to help approximate the differential equation better. For the same reason T may become ve-diagonal; but we shall disregard these possibilities in what follows since they can be accommodated by a straightforward elaboration of a trick whose description we still hope to keep simple. The equation (T + Diag(q))u = r has to be solved for the desired u = (T + Diag(q))1r . Even if q and r are independent of u , the solution process will usually require iteration if only to attenuate obscuration by roundoff during the solution process. One process, akin to Gaussian elimination, factorizes T + Diag(q) EB wherein B is bidiagonal and upper-triangular, and E is a bidiagonal lower-triangular matrix or else one whose rows have been permuted by pivoting during the factorization process. These factors serve to compute u B1(E1r) by rst forward substitution (perhaps permuted) to compute E1r and then back-substitution to get u . If q and r depend upon u they will have been estimated from a guess at u and must now be recomputed from the latest estimate of u , after which their changes...
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Berkeley - CS - 188
CS 188 Fall 20051. (12 pts.)Introduction to AI Stuart RussellSome Easy Questions to Start WithFinal Solutions(a) (2) True. This follows from the property that each variable is independent of its predecessors given its parents. Since X1 , . .
Berkeley - CS - 188
Temporal probability modelsChapter 15, Sections 15Chapter 15, Sections 151Outline Time and uncertainty Inference: ltering, prediction, smoothing Hidden Markov models Kalman lters (a brief mention) Dynamic Bayesian networks Particle lter
Berkeley - CS - 188
NAME:SID#:Section:1CS 188 Fall 2005Introduction to AI Stuart RussellFinalYou have 2 hours and 50 minutes. The exam is open-book, open-notes. 100 points total. Panic not. Mark your answers ON THE EXAM ITSELF. Write your name, SID, and se
Berkeley - CS - 188
NAME:SID#:Section:1CS 188 Spring 2005Introduction to AI Stuart RussellFinalYou have 2 hours and 50 minutes. The exam is open-book, open-notes. 100 points total. Panic not. Mark your answers ON THE EXAM ITSELF. Write your name, SID, and
Berkeley - CS - 188
CS 188 Fall 20051. (12 pts.)Introduction to AI Stuart RussellTrue/FalseMidterm Solution(a) (2) True; both because it is often possible to make changes to an environment without aecting optimal action choices (e.g., small changes to outcome pr
Berkeley - CS - 188
CS 188 Spring 20051. (12 pts.)Introduction to AI Stuart RussellFinal SolutionSome Easy Questions to Start With(a) (2) False. DBNs can include continuous variables. (b) (2) True. The two clauses resolve to give Q(F (F (z), which entails Q(F (
Berkeley - CS - 188
CS 188 Spring 20051. (12 pts.)Introduction to AI Stuart RussellMidterm SolutionTrue/False(a) (2) True/False: There exists a task environment (PEAS) in which every agent is rational. TRUE: e.g., let the performance measure be zero for every h
Berkeley - CS - 188
Propositional inference, propositional agentsChapter 7.57.7Chapter 7.57.71Outline Inference rules and theorem proving forward chaining backward chaining resolution Ecient model checking algorithms Boolean circuit agentsChapter 7.57.7
Berkeley - CS - 188
NAME:SID#:Login:Sec:1CS 188 Fall 2005Introduction to AI Stuart RussellMidtermYou have 80 minutes. The exam is open-book, open-notes. 100 points total. Panic not. Mark your answers ON THE EXAM ITSELF. Write your name, SID, login, and s
Berkeley - CS - 188
Rational decisionsChapter 16Chapter 161Outline Rational preferences Utilities Money Multiattribute utilities Decision networks Value of informationChapter 162PreferencesAn agent chooses among prizes (A, B, etc.) and lotteries, i.
Berkeley - CS - 188
NAME:SID#:Section:1CS 188 Spring 2005Introduction to AI Stuart RussellMidtermYou have 80 minutes. The exam is open-book, open-notes. 100 points total. Panic not. ALL QUESTIONS IN THIS EXAM ARE TRUE/FALSE, MULTIPLE-CHOICE, OR SHORT-ANSWE
Berkeley - CS - 70
These are notes on Gdels Theorem and Turings proof of the undecidability of the halting problem, o taken from a longer naration. 1. GODELS PROOFSubject: Splean From: bald@math.unitrieste.it Date: July 19, 1999. 2:15 (GST) It is a hot summer night
Berkeley - CS - 70
CS 70 Spring 2008 InvariantsDiscrete Mathematics for CS David WagnerNote 5We have a robot that lives on an innite grid. Initially, it is at position (0, 0). At any point, it can take a single step in one of four directions: northeast, northwest
Berkeley - CS - 70
CS 70 Spring 2008 FingerprintingDiscrete Mathematics for CS David WagnerNote 12Suppose we just finished transmitting an enormous file to the Moon. We'd like to verify that our file got there correctly, without any errors. We could of course re-
Berkeley - CS - 70
Discrete Mathematics and Probability TheoryComputer Science 70 Lecture 23(www.cs.berkeley.edu/~ddgarcia)Big Idea: memoization General principle: store rather than recompute. Context is a tree-recursive algorithm with lots of repeated computati
Berkeley - CS - 70
CS 70 Spring 2008Discrete Mathematics for CS David WagnerNote 9Modular ArithmeticOne way to think of modular arithmetic is that it limits numbers to a predened range {0, 1, . . . , N 1}, and wraps around whenever you try to leave this range
Berkeley - CS - 261
CS 261: Computer SecurityFall 2007Nov 13: CryptographyLecturer: David Wagner Scribe: Gunho Lee1How to solve security problem?Here is a trajectory how people (and I) think about this problem.1.1Security is a cryptographic problem.Many
Berkeley - CS - 70
CS 70 Spring 2008 Lesson PlanDiscrete Mathematics for CS David WagnerNote 2In order to be uent in mathematical statements, you need to understand the basic framework of the language of mathematics. This rst week, we will start by learning about
Berkeley - CS - 70
CS 70 Fall 2000Discrete Mathematics for CS WagnerMT1 SolSolutions to Midterm 11. (16 pts.) Theorems and proofs (a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of
Berkeley - CS - 70
CS 70 Spring 2008Discrete Mathematics for CS David WagnerNote 11Error Correcting CodesErasure ErrorsWe will consider two situations in which we wish to transmit information on an unreliable channel. The first is exemplified by the internet, w
Berkeley - CS - 170
UC BerkeleyCS 170 Lecturer: David WagnerProblem Set 9 Due on April 17 at 3:30 p.m.Problem Set 9 for CS 170Formatting Please use the following format for the top of the solution you turn in, with one line per item below (in the order shown below)
Berkeley - CS - 70
CS 70 Spring 2008Discrete Mathematics for CS David WagnerNote 6Well Ordering PrincipleHow can the induction axiom fail to be true? Recall that the axiom says the following: [P(0) (n . P(n) = P(n + 1)] = n . P(n). What would it take for n N .
Berkeley - CS - 70
CS 70 Spring 2008Discrete Mathematics for CS David WagnerNote 8Cake Cutting and Fair Division AlgorithmsThe cake-cutting problem is as follows. We have a cake, to be shared among n of us, and we want to split it amongst themselves fairly. Howe
Berkeley - CS - 276
U.C. Berkeley CS276: Cryptography Professor David WagnerLecture 30 May 9, 2006Lecture 30 Fun Topics 11.1Secret SharingSecret sharing backgroundConsider a bank vault locked with a combination lock, and n bank vice presidents that need to b
Berkeley - CS - 70
CS 70 Spring 2008P RINT your name:Discrete Mathematics for CS David Wagner,(last)Final Exam(rst)S IGN your name: P RINT your Unix account login: Your section time (e.g., Tue 3pm): Name of the person sitting to your left: Name of the person
Berkeley - MATH - 185
File: DSpr2p43Solution for Ex. 2 p.43 of Sarasons NotesOctober 16, 2006 10:18 amExercise 2 p. 43: Let be a complex number of unit modulus and an irrational real number. Prove that the values of form a dense subset of the unit circle. Solutio
Berkeley - CS - 262
Advanced Topics in Computer Systems, CS262B Prof Eric A. BrewerPractical Byzantine Fault ToleranceMarch 11, 2004[updated 3/12/04]I. MotivationWe need to make systems work without having trust all of the components. We call faults with arbitrar
Berkeley - CS - 174
CS174 Lecture 18Byzantine AgreementThis lecture, we describe the Byzantine agreement problem. Given n processors, the goal is to have all processors agree on a binary decision. This is a basic and deceptively difficult task in distributed computing
Berkeley - CS - 18
CS174 Lecture 18Byzantine AgreementThis lecture, we describe the Byzantine agreement problem. Given n processors, the goal is to have all processors agree on a binary decision. This is a basic and deceptively difficult task in distributed computing
Berkeley - CS - 174
CS174Formula SheetX u; Y=John CannyY v1 X= PrIndependence: Random variables X , Y are independent iff for all values u and v ,Pr =v= PrX u=Pr=Expected Value: The expected value EEX=X of X :EXX=kkPrX k=
Berkeley - CS - 174
Solutions for CS174 Homework 1Pr Y = 1 = 1=3; Pr Y = 1jX = 1 = 2=3; so Pr Y = 1jX = 1 6= Pr Y = 1 . Therefore X and Y are not independent. E XY = 1 Pr X = 1; Y = 1 + 0 Pr X = 1; Y = 0 + Pr X = 0; Y = 1 + Pr X = 0; Y = 0 = 1=3:Solution 1. Solutio
Berkeley - CS - 12
CS174 Lecture 12Program CheckingMany application programs (e.g. air traffic control, financial management) have become so complicated that its very difficult to discover and correct errors and produce a correct (or sufficiently correct) program. Pr
Berkeley - CS - 174
CS174 Lecture 12Program CheckingMany application programs (e.g. air traffic control, financial management) have become so complicated that its very difficult to discover and correct errors and produce a correct (or sufficiently correct) program. Pr
Berkeley - CS - 174
CS174 Lecture Note 4Based on notes by Alistair Sinclair, September 1998; based on earlier notes by Manuel Blum/Douglas Young. More on random permutations We might ask more detailed questions, such as: Q3: What is the probability that contains at le
Berkeley - CS - 4
CS174 Lecture Note 4Based on notes by Alistair Sinclair, September 1998; based on earlier notes by Manuel Blum/Douglas Young. More on random permutations We might ask more detailed questions, such as: Q3: What is the probability that contains at le
Berkeley - CS - 174
CS174Lecture 3John CannyRandomized Quicksort and BSTsA couple more needed results about permutations: Q1: Whats the probability that 4 comes before 5 in a random permutation? Tempting to say 1/2, but why? For every permutation where 4 is befor
Berkeley - CS - 174
Solutions for CS174 Homework 4Consider a nal stable marriage. Because all the males have the same preference ordering, then we can assign each female a unique number k representing her ranking on the lists. Female k has a spouse, and she must be th
Berkeley - CS - 4
Solutions for CS174 Homework 4Consider a nal stable marriage. Because all the males have the same preference ordering, then we can assign each female a unique number k representing her ranking on the lists. Female k has a spouse, and she must be th
Berkeley - CS - 174
CS174 CryptographyLecture 21John CannyThe idea of cryptography is to protect data by transforming into a representation from which the original is hard to recover. These days many networking technologies (internet, wireless) allow many agents t
Berkeley - CS - 21
CS174 CryptographyLecture 21John CannyThe idea of cryptography is to protect data by transforming into a representation from which the original is hard to recover. These days many networking technologies (internet, wireless) allow many agents t
Berkeley - CS - 17
CS174 Lecture 17Minimum Spanning TreesRemember the minimum spanning tree problem from CS170 you are given a graph G with weighted edges (real values on each edge) and the goal is to find a spanning tree T whose total weight is minimal. The minimum
Berkeley - CS - 174
CS174 Lecture 17Minimum Spanning TreesRemember the minimum spanning tree problem from CS170 you are given a graph G with weighted edges (real values on each edge) and the goal is to find a spanning tree T whose total weight is minimal. The minimum
Berkeley - CS - 174
CS174Lecture 25John CannySecret Sharing and Threshold DecryptionThe goal of secret-sharing is to divide a secret S into n pieces S1 , . . . , Sn such that any m + 1 pieces are sufcient to reconstruct S, but any m pieces give no information abo
Berkeley - CS - 25
CS174Lecture 25John CannySecret Sharing and Threshold DecryptionThe goal of secret-sharing is to divide a secret S into n pieces S1 , . . . , Sn such that any m + 1 pieces are sufcient to reconstruct S, but any m pieces give no information abo
Berkeley - CS - 174
CS174Lecture 24John CannyZero-Knowledge Proofs for discrete logsSuppose you want to prove your identity to someone, in order to cash a check or pick up a package. Most forms of ID can be copied or forged, but there is a zero-knowledge method t
Berkeley - CS - 24
CS174Lecture 24John CannyZero-Knowledge Proofs for discrete logsSuppose you want to prove your identity to someone, in order to cash a check or pick up a package. Most forms of ID can be copied or forged, but there is a zero-knowledge method t
Berkeley - CS - 174
CS174Monte-Carlo vs. Las VegasLecture 2John CannyA random algorithm is Las Vegas if it always produces the correct answer. The running time depends on the random choices made in the algorithm. Random Quicksort (where pivot elements are chosen
Berkeley - CS - 174
CS174Lecture 8John CannyMore on Coupon CollectingRecall that coupon collecting is equivalent to placing m balls in n bins so that no bin is empty. Last time we derived an upper bound for the probability that some bin is empty which is Pr[some
Berkeley - CS - 174
CS174Lecture 22John CannySecure Hash AlgorithmsAnother basic tool for cryptography is a secure hash algorithm. Unlike encryption, given a variablelength message x, a secure hash algorithm computes a function h(x) which has a xed and often smal
Berkeley - CS - 22
CS174Lecture 22John CannySecure Hash AlgorithmsAnother basic tool for cryptography is a secure hash algorithm. Unlike encryption, given a variablelength message x, a secure hash algorithm computes a function h(x) which has a xed and often smal
Berkeley - CS - 12
CS174 Sp2001Homework 12 Solutionsout: May 3, 20011. Each secret share si of a secret s is a pair xi ; yi where yi1= pxi andpx = rtxt + + r x + smod p is a polynomial whose coefcients r ; : : : ; rt are chosen independently and uniformly
Berkeley - CS - 174
CS174 Sp2001Homework 12 Solutionsout: May 3, 20011. Each secret share si of a secret s is a pair xi ; yi where yi1= pxi andpx = rtxt + + r x + smod p is a polynomial whose coefcients r ; : : : ; rt are chosen independently and uniformly
Berkeley - CS - 174
CS174Tail BoundsLecture 6John CannyLast time we looked at occupancy problems and derived some results on the distribution of some random variables. We derived bounds on the probability of a bin containing more than k balls, and the expected nu
Berkeley - CS - 6
CS174Tail BoundsLecture 6John CannyLast time we looked at occupancy problems and derived some results on the distribution of some random variables. We derived bounds on the probability of a bin containing more than k balls, and the expected nu
Berkeley - CS - 174
CS174 J. CannyMidterm 1Spring 2000 Feb 29This is a closed-book exam with 4 questions. You have 80 minutes. All questions are worth equal points, so be sure to budget 20 minutes per question. You are allowed to use the formula sheet that will be
Berkeley - CS - 174
CS174 J. CannyMidterm 2Spring 2000 April 6This is a closed-book exam with 4 questions. You are allowed to use the 4 sides of notes that you brought with you. The marks for each question are shown in parentheses, and the total is 80 points. Make
Berkeley - CS - 14
CS174 Lecture 14Data-Punctuated Token Trees (Berlekamp)Fingerprints provide a fast and communication-efficient way to check whether two strings are identical or not. Rather than sending S and T over a network, you can send the fingerprint f(S) from
Berkeley - CS - 174
CS174 Lecture 14Data-Punctuated Token Trees (Berlekamp)Fingerprints provide a fast and communication-efficient way to check whether two strings are identical or not. Rather than sending S and T over a network, you can send the fingerprint f(S) from
Berkeley - CS - 11
CS174 Lecture 11Routing in a Parallel ComputerWe study the problem of moving packets around in a parallel computer. In this lecture we will consider parallel computers with hypercube connection networks. The methods we describe are easy to adapt to
Berkeley - CS - 174
CS174 Lecture 11Routing in a Parallel ComputerWe study the problem of moving packets around in a parallel computer. In this lecture we will consider parallel computers with hypercube connection networks. The methods we describe are easy to adapt to
Berkeley - CS - 174
CS174 J. CannyMidterm 1Spring 99 Mar 2This is a closed-book exam with 4 questions. You have 80 minutes. All questions are worth equal points, so be sure to budget 20 minutes per question. You are allowed to use the formula sheet that will be ha