6 Pages

asst6-05f-soln

Course: M 353, Fall 2009
School: Delaware
Rating:
 
 
 
 
 

Word Count: 1303

Document Preview

353 Math Engineering Mathematics III 05F R. J. Braun http://www.math.udel.edu/braun/M353/M353.html Assignment 6, due 9/28/05, 2:30pm 1. Download the TestMyExp script files and the related function files. Run the script files, record the results in a diary file and comment on the relative speed of the scalar and vector versions. Also comment on the ways used to time the approaches. Note: You will likely have to...

Register Now

Unformatted Document Excerpt

Coursehero >> Delaware >> Delaware >> M 353

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.
353 Math Engineering Mathematics III 05F R. J. Braun http://www.math.udel.edu/braun/M353/M353.html Assignment 6, due 9/28/05, 2:30pm 1. Download the TestMyExp script files and the related function files. Run the script files, record the results in a diary file and comment on the relative speed of the scalar and vector versions. Also comment on the ways used to time the approaches. Note: You will likely have to adjust the value of nRepeat in the script files to get a good value of the relative time required that doesn't take too long to run on your computer. In your comments, tell me about the kind of computer you are using: cpu, cache memory, memory, operating system and so forth. 2. Modify the trapezoidal rule script file on the course web page (given to you by Dr. Monk in my absense as well) so that it uses a function file to evaluate the function at every point. (Create a separate function file for this purpose.) Use the code to do the following integrals using n = 16 intervals with the trapezoidal rule. (a). I1 = (b). I2 = (c). I3 = 1 x e dx. 0 3 ln(x)dx. 1 cos(x)dx. - Compute the error in each case. Solutions, hints and answers Problem 1. Timing Taylor Polynomials for Approximating Exponentials. The following diary file shows some timing results from using TestMyExpRB1.m and TestMyExpRB2.m. >> >> >> >> >> >> % Testing the scalar implementation in MyExp1.m vs the vector implemenation % in MyExp2.m using two different timing commands. % TestMyExpRB1.m uses tic and toc to find wall clock time % TestMyExpRB2.m uses cputime to find actual cpu time % type MyExp1.m function y = MyExp1(x) % y = MyExp1(x) % x is a column n-vector and y is a column n-vector with the property that % y(i) is a Taylor approximation to exp(x(i)) for i=1:n. nTerms = 17; n = length(x); y = ones(n,1); for i=1:n y(i) = MyExpF(x(i),nTerms); end >> type MyExp2.m function y = MyExp2(x) % y = MyExp2(x) % x is an n-vector and y is an n-vector with with the same shape 1 % and the property that y(i) is a Taylor approximation to % exp(x(i)) for i=1:n. y = ones(size(x)); nTerms = 17; term = ones(size(x)); for k=1:nTerms term = x.*term/k; y = y + term; end >> TestMyExpRB1 % using nRepeat = 50 T1 = MyExp1 benchmark. T2 = MyExp2 benchmark. Length(x) T2/T1 ----------------------1000 0.147430 1100 0.131516 1200 0.138785 1300 0.126010 1400 0.124822 1500 0.139547 1600 0.125225 1700 0.132961 1800 0.132659 1900 0.133946 2000 0.128568 >> TestMyExpRB2 % using nRepeat = 50 T1 = MyExp1 benchmark. T2 = MyExp2 benchmark. Length(x) T2/T1 ----------------------1000 0.125000 1100 0.166667 1200 0.105263 1300 0.150000 1400 0.136364 1500 0.125000 1600 0.160000 1700 0.153846 1800 0.142857 1900 0.133333 2000 0.129032 >> TestMyExpRB2 % using nRepeat = 100 T1 = MyExp1 benchmark. T2 = MyExp2 benchmark. Length(x) T2/T1 ----------------------1000 0.156250 1100 0.147059 1200 0.135135 2 1300 0.150000 1400 0.136364 1500 0.127660 1600 0.140000 1700 0.129630 1800 0.142857 1900 0.135593 2000 0.145161 >> TestMyExpRB2 % using nRepeat = 10 T1 = MyExp1 benchmark. T2 = MyExp2 benchmark. Length(x) T2/T1 ----------------------1000 0.000000 1100 0.333333 1200 0.000000 1300 0.000000 1400 0.200000 1500 0.000000 1600 0.000000 1700 0.200000 1800 0.166667 1900 0.142857 2000 0.166667 >> % using a large value of nRepeat eliminates bogus timings and >> % helps minimize fluctuations in the ratio of times >> diary off The value of nRepeat must be large enough to get reasonable timings for the two methods; a ratio of zero is clearly bogus, and with enough repetitions, the values of T2/T1 stabilize to sensible values. In all cases, the vectorized method of MyExp2.m is faster than MyExp1.m because the ratio is never larger than one. The two timing methods give similar results. The commands tic and toc give a wall-clock time, that is, what you might get if you were very good with a stop watch. The cputime command will count only the time that the cpu spends on the Matlab task at hand, not other processes that the cpu may be doing during the calculation. Solutions, hints and answers Problem 2. First Approach. The following diary file shows a script Trap1.m file that uses three function files, one for each part of the problem. The user inputs the function name (without the .m) and the limits of integration; the script selects the correct exact answer to use with an if-else-end structure. The results show that the first two integrals are approximated well, around 10-4 error or so, while the third one seems particularly good, being about the size of the unit round with only 16 points. We'll discuss this later; something special happens in that last integral due to symmetry. >> type Trap1.m % Script Trap1.m uses the composite trapezoidal rule % to approximate the integral of function f % % Input: f - function to integrate 3 % a - lower limit of integration % b - upper limit of integration % f = input('Type in the function name within single quotes: ') a = input('Type in the lower limit: ') b = input('Type in the upper limit: ') n = 16; % fixed at n = 16 intervals for this problem h = (b-a)/n; % n intervals means n+1 points; use that in linspace x = linspace(a,b,n+1); F = feval(f,x); % do integration now; uses vectorized calculation S = (F(1)+F(n+1))/2 + sum(F(2:n)); ApproxI = S*h % choose between three exact answers if (f == 'Hw7F1') Exact = exp(b) - exp(1); % first problem elseif (f == 'Hw7F2') Exact = b*(log(b) - 1) - a*(log(a) - 1); % second problem elseif (f == 'Hw7F3') Exact = sin(b) - sin(a); % third problem end ErrInApprox = abs(Exact - ApproxI) >> type Hw7F1.m function y = Hw7F1(x) % Function for Hw 7, numerical integration problem % First function y = exp(x); >> Trap1 Type in the function name within single quotes: 'Hw7F1' f = Hw7F1 Type in the lower limit: 0 a = 0 Type in the upper limit: 1 b = 1 ApproxI = 1.7188 ErrInApprox = 5.5930e-04 >> type Hw7F2.m function y = Hw7F2(x) % Function for Hw 7, numerical integration problem % Second function y = log(x); >> Trap1 Type in the function name within single quotes: 'Hw7F2' 4 f = Hw7F2 Type in the lower limit: 1 a = 1 Type in the upper limit: 3 b = 3 ApproxI = 1.2950 ErrInApprox = 8.6741e-04 >> type Hw7F3.m function y = Hw7F3(x) % Function for Hw 7, numerical integration problem % Third function y = cos(x); >> Trap1 Type in the function name within single quotes: 'Hw7F3' f = Hw7F3 Type in the lower limit: -pi a = -3.1416 Type in the upper limit: pi b = 3.1416 ApproxI = 1.7439e-16 ErrInApprox = 7.0536e-17 >> diary off Second Approach. This time, we have function file that does the trapezoidal rule for us; the function for the integ...

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:

Delaware - M - 353
University of Delaware Department of Mathematical Sciences Math 353 Engineering Mathematics III 05F R. J. Braun Homework 9: Due Friday, 11/11/05, 2:30pm 1. Read 7.1,7.2,7.4,7.5. 2. 7.1, Problems 7.1.2(c),7.1.3(b). Only use the Trapezoidal and Simpson
Rochester - ME - 406
sir1.nb1S-I-R Model of Epidemics Part 1 Basic Model and Examples Revised January 13, 2009sysidMathematica 6.0.3, DynPac 11.01, 11320091. IntroductionDescription of the ModelIn this notebook, we develop in detail the standard S-I-R model
Delaware - HLY - 0203
75587845 -155.2496 71.6774 12 49.7 20.8 207. 3.3 -6. 30 85 100.0 -0.4 2.1 58.9 127.2 32 15.8 110 1 75587845 -155.2496 71.6774 11 55.4 19.3 207. 3.2 -1. 38 85 100.0 -1.4 1.8 60.2 126.6 40 15.7 102
Delaware - HLY - 0402
76541284 -159.0494 72.3470 14 -570.7 -965.9 999. 0.2 11. 52 4 0.0 -15.3 0.1 77.4 110.2 71 8.8 72 1 76541284 -159.0494 72.3470 13 -569.9 -965.0 999. 0.2 4. 49 4 0.0 -15.3 -0.5 79.7 109.1 68 7.6 68
Sveriges lantbruksuniversitet - BISC - 309
Rio de Janeiro Earth Summit Signatories pledged to establish a system of protected areas Reserves should be Comprehensive Representative Adequate Flexible and Efficient consider Irreplaceability Shape Connectivity Risk spreadingRESERVE DESIGN The G
UCSC - AMS - 005
ugeg0sus Q vP cfS @ FGrb FD f@6)eqGVsu8u8 ADPR@ uRiP`CD8B uyf@AcI0VUF8 S EDPAqBRc@ `C8s )IEUqdwQ8 uQ@Pwc 8 RUd C CBTiP6bq@ED8Bs uB~ Y@ R@Bi ersF uyTxtRcB8i p`vs )T0AQ7q88 AFeBPVB fSVruP8B CDrRQsB 6CBB Aqe@G2v S B Fr c i B c ugpx ge} B
Colorado State - PY - 100
Rochester - AAH - 262
Rochester - AAH - 262
Delaware - CIS - 659
CIS 659 Introduction to Network Security Fall 2003 Class 15 10/28/03CIS 659 Introduction to Network Security Fall 2003 Class 15 10/28/03What is a Worm? What is a Worm?A program that:A program that: 1CIS 659 Intro
Delaware - CIS - 864
Caveat TheseIDisclaimerslides have more information than you need for 864 courseleft it in so that people who want more information can find itSome techniques and tools mentioned in this class could be: Dangerous Forquick reading Re
UCSC - CMPE - 012
HC11 Input and OutputMuch shorter than A. Di Blas'. See Spring 08 site for more.CMPE12 Winter 2009 Joel FergusonInput and outputThe include file <v2_18g3.asm> provides a set of useful I/O subroutines: GETCHAR, reads a char from keybo
UCSC - CMPE - 012
Welcome to CMPE 12!Computing Systems and Assembly Language ProgrammingWinter 2009Joel FergusonBased on slides from slides from Cyrus Bazeghi and (especially) Andrea Di Blas Thank you!The team:Instructor: F. Joel Ferguson TAs: Xuchu Hu Robert
UCSC - CMPE - 012
Arrays, Stacks and the LC-3(Textbook chapter 10.1 - 10.4.1)CMPE12 Winter 2009 J. FergusonSummary1. The array data structure 2. The stack data structure 3. Arithmetic using a stackCMPE12 Winter 2009 J. Ferguson11 - 2ArraysDefinition:
Maryland - MATH - 220
Math 220 Section 03* Exam 1Spring 2008Directions: Please follow the directions as to which problems go on which answer sheets. Please put problem 1 on answer sheet 1 1. (a) Find the equation of the line tangent to f (x) = 2x + (b) Find the point
UCSC - PHYS - 110
Physics 110. Electricity and Magnetism. Professor Dine Spring, 2008. Handout: Radiation1Electric Dipole RadiationOur treatment in class was essentially that of section 11.1.4, radiation from an arbitrary source. We derived 11.51 and 11.52, as w
UCSC - PHYS - 101
Physics 101BModern PhysicsHomework Assignment #4Due in class, Friday, May 7 80 points totalSpring 19991) Question 11.3 of Eisberg & Resnick. Explain why the quantum distributions merge with the classical distribution at energies much larger t
UCSC - PHYS - 110
Magnetic Properties of Materials Paramagnetism Diamagnetism FerromagnetismWeak effects, not familiar to most people, but all materials exhibit one or the other. Strong effect: Responsible for all permanent magnets. Responsible for the strong magn
UCSC - PHYS - 218
Physics 218. Advanced Quantum Field Theory. Professor Michael Dine Winter, 2009. SyllabusContact Information: ISB 323. Phone: 9-3033 Email (best): dine@scipp.ucsc.edu Office hours: Tuesday, 10:00-12:00 (subject to change) or by appointment. Course w
UCSC - EART - 279
EART-279 Interpretive Data Processing Lecture #6 Characterizing Sampled Data Given n samples, xi for i = 1, 2, ., n, of some random variable, how do we characterize them? Note that we are not yet attempting to say anything about the distribution the
UCSC - EART - 266
ES266 Geological Signal Processing Homework Assignment #1 (Due in one week or so)The following problems are meant to get you thinking math if it's been awhile and to have you work with some of the statistical underpinnings of future lectures. If you
UCSC - EART - 266
EART266 Geological Signal Processing Winter 2002 General InformationOverview An introduction to time series analysis presented with geological/geophysical applications in mind. Presentation will follow geostatistical conventions rather than traditio
UCSC - EART - 266
EART266 Geological Signal Processing Lecture #1 Statistical Principles We begin with the definition of a random variable. A random variable x is a set of real numbers representing the possible outcomes of an experiment (i.e., a measurement). It can t
University of Alaska Fairbanks - BIOL - 474
Lesson 2 Brief history of plant ecology Key historical personalities Major phases in the development of plant ecology concepts European biogeographical phase European plant community classification phase American concepts of succession, continuu
University of Alaska Fairbanks - BIOL - 474
Course syllabus Lectures M, W, F, 8-9 am, Irving Room 208Notes: 1 BBPGS = Barbour, M.G., J.H. Burk, W.D. Pitts, F.S. Gilliam, and M.W. Schwartz. 1999. Terrestrial Plant Ecology. Menlo Park: Addison Wesley Longman. 2 Walter = Walter, H. 1979. Vegetat
University of Alaska Fairbanks - BIOL - 475
Lecture 2: The Relev Method ofSampling Plant Communities1. Relev sampling method. 2. Review results of minimal area sampling. 3. Lab 2 overviewSampling methods Subjective vs. objective sampling Centralized replicate, random, and systematic samp
University of Alaska Fairbanks - BIOL - 474
Lesson 10: Species interactions: Commensalism, mutualism, and herbivoryCommensalismExamples: Epiphytes, Nurse plants,ProtocooperationExamples: Root grafts, Transfer of nutrients through mycorrhizal fungiMutualismExamples: Mycorrhizae, Symbiot
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
Lesson 33: Water in the environment and plant-water adaptations Concept of water potential Factors affecting water potential Evapotranspiration and control of ET Temperature regulation of ET Resistance to water loss Effects of leaf size and mo
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
University of Alaska Fairbanks - BIOL - 474
Rochester - PHP - 403
9/11/2007PHP 403 Cell and Molecular Physiology3 Credit hours Lectures: Mondays, Wednesdays, and Fridays, 1:00 2:00 pm Room 4-6912 (Anders Room) This course is aimed to provide an introduction to the fundamental principles of modern cell and molec
Haverford - CSTS - 209
CSTS209: CLASSICAL MYTHOLOGYKey Terms : oedipus & the Myths of thebesscapegoat or pharmakos Sigmund Freud Sophocles (497 BCE405 BCE) Ovid (3/20/63 BCE17 CE) Major Myths 1. Cadmus & the Spartoi 2. Zeus, Semele, & Dionysus 3. Zeus & Antiope 4. [Niob
Johns Hopkins - CS - 416
Correctness Criterion, Serializability, and Concurrency Control1. We had left of our discussion of transactions with: (a) definition of the page model (b) transaction syntax partial and full orderings (c) shuffle histories (d) Missing 2 steps in ou
Rochester - PHY - 100
PHY100 Problem Set #8 Nov. 2 2008Problems from Hobson:(C.Ex.=conceptual exercise; R.Q.=review question; P.=problem)1) Chapter 16, C.Ex. 2, page 406 2) Chapter 16, C.Ex. 7, page 406 3) Chapter 16, C.Ex. 12, page 406 4) Chapter 16, C.Ex. 20, page
Rochester - PHY - 100
-Melissa Greenberg, Arielle Hoffman, Zachary Feldmann, Ryan Pozin, Elizabeth Weeks, Christopher Pesota, & Sara Pilcher All explanations as to how the solar system was formedFormation Overvieware only theories and may change/evolve as scientists
East Los Angeles College - MERT - 1230
CL 102 Epistemology Ralph Wedgwood 4 November 2008 Week 4: Probability and Degrees of Belief 1. Belief comes in degrees So far, we have just been treating belief as if it were simply an attitude that one either has, or does not have, towards any pro
Rochester - CSC - 458
What is and Why Concurrency? What is a concurrent program? One with more than one active execution context (thread of control) Programming Models Standard models of parallelismshared memory (Pthreads) message passing (MPI) data parallel (Fo
UCSC - AMS - 241
AMS 241: Bayesian Nonparametric Methods (Fall 2006) Hwk set on Dirichlet process priors(due Friday October 20)1. Simulation of Dirichlet process prior realizations Consider a Dirichlet process (DP) prior, DP(, G 0 ), over the space of distribution
UCSC - AMS - 241
AMS 241: Bayesian Nonparametric Methods (Winter 2009)Summary and referencesInstructor: Athanasios Kottas, Department of Applied Mathematics and Statistics, University of California, Santa Cruz Notes 3: Dirichlet process mixture models Applicatio
Rochester - CSC - 256
Operating Systems4/4/2005Concurrent Online ServersConcurrent Online ServersServers thataccept concurrent requests (potentially high concurrency) serve online users (interactive responses) Web server: online server that implements HTTP More
Rochester - VERSION - 45431
Curriculum Vitae SUZANNE S. BELL ADDRESSES Work: Home: Reference Department 169 Dartmouth Street Rush Rhees Library Rochester, NY 14607 University of Rochester (585) 4425727 Rochester, NY 14627 (585) 2759317 suzanne.b
Rochester - DOCUMENT - 26264
XCProjectOverview 2WhatisXC? XCProjectOverview XCPartners OurvisionforXC DemonstrationofC4prototypeWhatisXC? Alternativewaytoreveallibrary collectionstousers Integratelibrarycontentintoother systems Opensource,collaborative3WhatisXC?
Rochester - DOCUMENT - 21909
Rare Books, Spring 2006 Date 15 March 06 Project/URL Updated pages to include images in databases for Ellwanger & Barry, Peter Barry/Rochester Local History, Women's Suffrage, Palmyra (the code is currently commented out, with intent to remove commen
Georgia Tech - ISYE - 6739
2.11 Discrete RVsDiscrete Random Variables Some More DenitionsDiscrete Uniform and Binomial DistributionsPoisson Distribution12.11 Discrete RVsDenition: If X is a discrete RV, its probability mass function (pmf) is f (x) Pr(X = x). Note
Rochester - ME - 213
A Practical Vibration Issuefrom 747 by Joe Sutter with Jay Spencer, Smithsonian Books pp. xxx-xxx (2006) These efforts hadn't progressed very far when the program came to a screeching halt. We had run into low damping, and that, in turn, meant the p
Johns Hopkins - C - 171
Quantum Mechanics I, Problem Set 5 Due Wednesday October 19 in class1. Townsend Chapter 3, Problem 5. 2. Townsend Chapter 3, Problem 15. 3. Townsend Chapter 3, Problem 16. 4. Townsend Chapter 3, Problem 17. 5. Townsend Chapter 3, Problem 18. 6. Town
UCSC - CMPS - 013
Program Fundamentals/* HelloWorld.java * The classic "Hello, world!" program */ class HelloWorld { public static void main (String[ ] args) { args) System.out.println("Hello, world!"); System.out.println("Hello, } }/* HelloWorld.java . <etc.> */
Georgia Tech - ECE - 2030
AnnouncementsuToday: Section (3.3) Combinational (Memoryless) Logic u Friday: Storage (Memory) (3.4 - 3.6) u Monday: Chapter 4: the von Neumann computer modelExamples of Combinational Logic StructuresuSome important combinational logic struct
Wilfrid Laurier - MATH - 411
MATH 411 - Quiz # 3 - Answers, Hints, Solutions Thursday, March 12, 2009Part A. Show your work. 1 -2 -1 1. (22%) Find the Jordan form J of the matrix A = 2 -3 -1 and such matrix M -1 2 1 -1 that M AM = J. Hint: 1 = -1 and 2 = 3 = 0 are eigenvalue
Georgia Tech - CS - 4455
Virtual Worlds LabVirtual Worlds Labwww.cc.gatech.edu/vwlabAreas of research: Virtual Environments, Scientific + Geospatial + Information VisualizationVirtual Worlds LabTime Dependent Volume Data: Doppler Radar Weathera)b)Altitude dista
Rochester - ME - 407
RollingCoin(I).nb12008 October 17 printed 2008 October 17 09:30 Derivation of equations 4.175 in Meirovitch using the method of Lagrange multipliersOff@General:spellD;The Lagrangian (after applying the single holonomic constraint)L = 1 2 M H
Rochester - ME - 213
DampedGroundMotion.nb12009 February 3printed February 4 10:40Damped Ground MotionMathematica gets upset if it thinks you are making mistakes by using variables with similar names. These error messages can get quite tiresome, so I generally tur
Wilfrid Laurier - MATH - 411
University of Calgary Department of Mathematics & Statistics MATH 411 Quiz # 3 Thursday, March 12, 2009Allowed: Calculators only (Given/Family) Name Good luck! Part A. Show your work. 1 -2 -1 1. (22%) Find the Jordan form J of the matrix A = 2 -3
Delaware - CPEG - 422
Your Design KitReading: http:/www.cvorg.ece.udel.edu/cpeg422f07/resources.html XSA-50 Manual DS92LV16 Data Sheet DS92LV16 Design GuideClaudia's ThesisXSA-50 Prototyping BoardXSA-50 Prototyping BoardXSA-50 Prototyping BoardXILINX XC2S50 FPG
Yale - ETD - 06282006
SEARCH FOR THE BASOLATERAL POTASSIUM CHANNEL IN THE SHARK RECTAL GLAND: FUNCTIONAL AND MOLECULAR IDENTIFICATION OF A TASK-1 CHANNEL COUPLED TO CHLORIDE SECRETIONA Thesis Submitted to the Yale University School of Medicine in Partial Fulfillment of