intro - Chapter 1 Introduction to MATLAB This book is an...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 1 Introduction to MATLAB This book is an introduction to two subjects: Matlab and numerical computing. This first chapter introduces Matlab by presenting several programs that inves- tigate elementary, but interesting, mathematical problems. If you already have some experience programming in another language, we hope that you can see how Matlab works by simply studying these programs. If you want a more comprehensive introduction, an on-line manual from The MathWorks is available. Select Help in the toolbar atop the Matlab command window, then select MATLAB Help and Getting Started . A PDF version is available under Printable versions . The document is also available from The MathWorks Web site [10]. Many other manuals produced by The MathWorks are available on line and from the Web site. A list of over 600 Matlab -based books by other authors and publishers, in sev- eral languages, is available at [11]. Three introductions to Matlab are of particular interest here: a relatively short primer by Sigmon and Davis [8], a medium-sized, mathematically oriented text by Higham and Higham [3], and a large, comprehen- sive manual by Hanselman and Littlefield [2]. You should have a copy of Matlab close at hand so you can run our sample programs as you read about them. All of the programs used in this book have been collected in a directory (or folder) named NCM (The directory name is the initials of the book title.) You can either start Matlab in this directory or use pathtool to add the directory to the Matlab path. February 15, 2008 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Chapter 1. Introduction to MATLAB 1.1 The Golden Ratio What is the world’s most interesting number? Perhaps you like π , or e , or 17. Some people might vote for φ , the golden ratio , computed here by our first Matlab statement. phi = (1 + sqrt(5))/2 This produces phi = 1.6180 Let’s see more digits. format long phi phi = 1.61803398874989 This didn’t recompute φ , it just displayed 15 significant digits instead of 5. The golden ratio shows up in many places in mathematics; we’ll see several in this book. The golden ratio gets its name from the golden rectangle, shown in Figure 1.1. The golden rectangle has the property that removing a square leaves a smaller rectangle with the same shape. φ φ 1 1 1 Figure 1.1. The golden rectangle. Equating the aspect ratios of the rectangles gives a defining equation for φ : 1 φ = φ 1 1 . This equation says that you can compute the reciprocal of φ by simply subtracting one. How many numbers have that property? Multiplying the aspect ratio equation by φ produces the polynomial equation φ 2 φ 1 = 0 .
Image of page 2
1.1. The Golden Ratio 3 The roots of this equation are given by the quadratic formula: φ = 1 ± 5 2 . The positive root is the golden ratio. If you have forgotten the quadratic formula, you can ask Matlab to find the roots of the polynomial. Matlab represents a polynomial by the vector of its coe cients, in descending order. So the vector p = [1 -1 -1] represents the polynomial p ( x ) = x 2 x 1 .
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern