c Bo 9780511972942 a 052

87
8/15/2019 c Bo 9780511972942 a 052 http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 1/87

Transcript of c Bo 9780511972942 a 052

Page 1: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 1/87

Page 2: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 2/87

Page 3: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 3/87

Page 4: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 4/87

Page 5: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 5/87

Page 6: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 6/87

Page 7: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 7/87

Page 8: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 8/87

Page 9: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 9/87

Page 10: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 10/87

Page 11: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 11/87

Page 12: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 12/87

Page 13: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 13/87

Page 14: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 14/87

Page 15: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 15/87

Page 16: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 16/87

Page 17: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 17/87

Page 18: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 18/87

Page 19: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 19/87

Page 20: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 20/87

Page 21: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 21/87

Page 22: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 22/87

Page 23: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 23/87

Page 24: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 24/87

Page 25: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 25/87

Page 26: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 26/87

Page 27: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 27/87

Page 28: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 28/87

Page 29: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 29/87

Page 30: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 30/87

Page 31: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 31/87

Page 32: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 32/87

Page 33: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 33/87

Page 34: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 34/87

Page 35: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 35/87

Page 36: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 36/87

Page 37: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 37/87

Page 38: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 38/87

Page 39: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 39/87

Page 40: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 40/87

Page 41: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 41/87

Page 42: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 42/87

Page 43: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 43/87

Page 44: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 44/87

Page 45: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 45/87

Page 46: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 46/87

Page 47: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 47/87

Page 48: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 48/87

Page 49: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 49/87

Page 50: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 50/87

Page 51: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 51/87

Page 52: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 52/87

Page 53: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 53/87

Page 54: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 54/87

Page 55: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 55/87

Page 56: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 56/87

Page 57: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 57/87

Page 58: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 58/87

Page 59: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 59/87

Page 60: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 60/87

Page 61: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 61/87

Page 62: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 62/87

Page 63: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 63/87

Page 64: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 64/87

Page 65: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 65/87

Page 66: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 66/87

Page 67: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 67/87

Page 68: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 68/87

Page 69: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 69/87

Page 70: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 70/87

Page 71: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 71/87

Page 72: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 72/87

Page 73: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 73/87

Page 74: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 74/87

Page 75: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 75/87

Page 76: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 76/87

Page 77: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 77/87

Page 78: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 78/87

Page 79: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 79/87

Page 80: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 80/87

Page 81: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 81/87

Page 82: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 82/87

Page 83: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 83/87

Page 84: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 84/87

In[173]:= RandomCompose @20, " Vibraphone " D

Out[173]=

11.25 s

A listener would be hard pressed to find a pattern or any autocorrelation in this “tune” and themusic is quite uninteresting as a result. Melodies generated using this scaling are referred to as1ê f 0 , where the0 loosely refers to the level of correlation.

We leave as an exercise the writing of more sophisticated 1ê f 0 melodies, where the likelihoodof a note being chosen obeys a certain probability distribution.

We now move in the other direction and generate melodies that are overly correlated. The

randomness will be applied to the distance between notes, essentially performing a “randomwalk” through the C major scale. Music generated in such a way is calledBrownian because itbehaves much like the movement of particles suspended in liquid – Brownian motion.

Here is our random walk function, essentially borrowed from Section13.1. We will limit the“distance” any step can take to the range- 4 to 4.

In[174]:= Accumulate @RandomChoice @Range @- 4, 4 D, 12 DDOut[174]= 80, 3, 1, - 1, - 1, - 3, - 2, 1, 4, 2, 5, 1 <

This puts all the pieces together, plus one additional piece to create random durations.

In[175]:= BrownianCompose @steps_Integer , instr_: " Vibraphone " D :=

Module @8 walk , durs <, walk @n_ D : = Accumulate @RandomChoice @Range @- 4, 4 D, nDD;

durs = RandomChoice @Range @1 ê16, 1, 1 ê16 D, 8steps <D;Sound ü

MapThread @SoundNote @Ò 1 , Ò 2 , instr D &, 8 walk @steps D, durs <DDIn[176]:= BrownianCompose @18, " Marimba " D

Out[176]=

10 s

10.4 Examples and applications 445

Downloaded from Cambridge Books Online by IP 157.253.50.50 on Wed May 18 01:20:04 BST 2016.http://dx.doi.org/10.1017/CBO9780511972942.011

Cambridge Books Online © Cambridge University Press, 2016

Page 85: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 85/87

This melody has a different character from the 1ê f 0 melody produced above. In fact, it is quiteovercorrelated and it is often referred to as 1ê f 2 music as a result of a computed spectral density.Although different in character from 1ê f 0 music, it is just as monotonous. The melody mean-

ders up and down the scale aimlessly without any central theme. The exercises contain a discus-sion of 1ê f music (or noise), that is, music that is moderately correlated. 1ê f noise is quitewidespread in nature and is intimately tied to areas of science that study fractal behavior; seeCasti (1992) or Mandelbrot (1982).

Exercises1. Create a function ComplexListPlot that plots a list of complex numbers in the complex plane

using ListPlot . Set initial options so that thePlotStyle is red, thePointSize is a little largerthan the default, and the horizontal and vertical axes are labeled “Re” and “Im,” respectively. Set itup so that options to ComplexListPlot are inherited from ListPlot .

2. Create a function ComplexRootPlot that plots the complex solutions to a polynomial in theplane. Use your implementation ofComplexListPlot that you developed in the previousexercise.

3. ModifyPathPlot so that it inherits options from Graphics as well as having its own option,PathClosed , that can take on values ofTrue or False and closes the path accordingly byappending the first point to the end of the list of coordinate points.

4. Extend the code forListLinePlot3D so that the rule for multiple datasets incorporates theoptions that were used for the single dataset rule in the text.

5. Although the program SimpleClosedPath works well, there are conditions under which it willoccasionally fail. Experiment by repeatedly computingSimpleClosedPath for a set of ten pointsuntil you see the failure. Determine the conditions that must be imposed on the selection of the basepoint for the program to work consistently.

6. ModifySimpleClosedPath so that the point with the smallest x-coordinate of the list of data ischosen as the base point; repeat but with the largest y-coordinate.

7. Another way of finding a simple closed path is to start with any closed path and progressively makeit simpler by finding intersections and changing the path to avoid them. Prove that this processends, and that it ends with a closed path. Write a program to implement this procedure and thencompare the paths given by your function with those ofSimpleClosedPath given in the text.

8. Following on the framework of theRootPlot example in this section, create a functionShowWalk @ walkD that takes the coordinates of a random walk and plots them in one, two, or threedimensions, depending upon the structure of the argument walk. For example:

In[1]:= << PwM`RandomWalks`

446 Graphics and visualization

Downloaded from Cambridge Books Online by IP 157.253.50.50 on Wed May 18 01:20:04 BST 2016.http://dx.doi.org/10.1017/CBO9780511972942.011

Cambridge Books Online © Cambridge University Press, 2016

Page 86: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 86/87

In[2]:= ShowWalk @RandomWalk @500, Dimension Ø 1 D,Frame Ø True, GridLines Ø Automatic D

Out[2]=

0 100 200 300 400 500

- 25

- 20

- 15

- 10

- 5

0

5

In[3]:= ShowWalk @RandomWalk @500, Dimension Ø 2 D, Mesh Ø All, MeshStyle Ø Directive @Brown, PointSize @Small DDD

Out[3]=

- 5 5 10

- 12

- 10

- 8

- 6

- 4

- 2

2

In[4]:= ShowWalk @RandomWalk @2500, Dimension Ø 3 D,Background Ø LightGray, BoxRatios Ø 81, 1, 1 <D

Out[4]=

9. UseMesh in a manner similar to its use in theRootPlot function to highlight the intersection oftwo surfaces, say sinH2 x - cosH yLL and sinHx - cosH2 yLL. You may need to increase the value ofMaxRecursion to get the sampling just right.

10. Rewrite TrendPlot to compute a more robust plot range, one based on the minimum andmaximum values of the data together with the minimum and maximum user-specified rates.

10.4 Examples and applications 447

Downloaded from Cambridge Books Online by IP 157.253.50.50 on Wed May 18 01:20:04 BST 2016.http://dx.doi.org/10.1017/CBO9780511972942.011

Cambridge Books Online © Cambridge University Press, 2016

Page 87: c Bo 9780511972942 a 052

8/15/2019 c Bo 9780511972942 a 052

http://slidepdf.com/reader/full/c-bo-9780511972942-a-052 87/87

11. Modify the graphics code at the end of thePointInPolygonQ example so that GatherBy alwaysorders the two lists so that the list of points that pass occurs before the list of points that fail the test.

12. Write a function pentatonic that generates 1ë f 2 music choosing notes from a five-tone scale. Apentatonic scale can be played on a piano by beginning with C¤, and then playing only the blackkeys: C¤, EŸ, F¤, AŸ, C¤. The pentatonic scale is common to Chinese, Celtic, and Native Americanmusic.

13. Modify the routine for generating 1ë f 0 music so that frequencies are chosen according to a speci-fied probability distribution. For example, you might use the following distribution that indicates anote and its probability of being chosen: C –5%, C¤ – 5%, D –5%, EŸ – 10%, E –10%, F –10%, F¤ –10%, G –10%, AŸ – 10%, A –10%, BŸ – 5%, B –5%, C –5%.

14. Modify the routine for generating 1ë f 0 music so that the durations of the notes obey 1ë f 0 scaling.

15. If you read musical notation, take a musical composition such as one of Bach’sBrandenburg Concertosand write down a list of the frequency intervalsx between successive notes. Then find a functionthat interpolates the power spectrum of these frequency intervals and determine if this function isof the form f HxL= cêx for some constant c. (Hint: To get the power spectrum, you will need to squarethe magnitude of the Fourier transform: take Abs @Fourier @…DD2 of your data.) Compute thepower spectra of different types of music using this procedure.

448 Graphics and visualization