Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-cnmwb Total loading time: 0 Render date: 2024-07-22T19:29:07.634Z Has data issue: false hasContentIssue false

4 - Graphs and Curves

Published online by Cambridge University Press:  08 February 2010

K. Chen
Affiliation:
University of Liverpool
Peter J. Giblin
Affiliation:
University of Liverpool
A. Irving
Affiliation:
University of Liverpool
Get access

Summary

In this chapter we shall use MATLAB to draw graphs of functions y: = f(x), to approximate functions in two different ways as polynomials, to solve equations f(x) = 0 and to draw systems of lines in the plane forming an ‘envelope’. (For graphs z = f(x,y), see Chapter 17.) The technique of approximation is particularly important in applications, where it is desirable to replace a relatively complicated function (or indeed data set; compare Chapter 5) by a simple polynomial which can be easily handled. The choice here is between a very good approximation of f(x) close to some given value x0 of x, which gets steadily worse as x moves away (Taylor polynomials), and a reasonably good approximation over a larger range (‘polyfit’ approximations). Each has its uses.

Polynomials

A polynomial such as p(x) = x4 + 2x3 − 3x2 + 4x + 5 is entered by means of its coefficients:

» p=[1 2 -3 4 5]

Note the spaces between the numbers; commas are also allowed for separation. In other words, a polynomial is just entered as a vector containing the coefficients, starting with the ‘leading’ coefficient in front of the highest power of the variable x.

The roots of p (i.e., the solutions of p(x) = 0) are obtained by typing

roots(p)

Notice that this finds the complex roots as well as the real ones. We can increase the number of figures displayed by typing

format long

We can draw the graph of p by typing

» x=-4: .05:2;

» y=polyval(p,x);

» plot(x,y)

The first line creates a vector x whose entries are the numbers from –4 to 2 at 0.05 intervals.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 1999

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Graphs and Curves
  • K. Chen, University of Liverpool, Peter J. Giblin, University of Liverpool, A. Irving, University of Liverpool
  • Book: Mathematical Explorations with MATLAB
  • Online publication: 08 February 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511624117.005
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Graphs and Curves
  • K. Chen, University of Liverpool, Peter J. Giblin, University of Liverpool, A. Irving, University of Liverpool
  • Book: Mathematical Explorations with MATLAB
  • Online publication: 08 February 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511624117.005
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Graphs and Curves
  • K. Chen, University of Liverpool, Peter J. Giblin, University of Liverpool, A. Irving, University of Liverpool
  • Book: Mathematical Explorations with MATLAB
  • Online publication: 08 February 2010
  • Chapter DOI: https://doi.org/10.1017/CBO9780511624117.005
Available formats
×