This preview shows page 1. Sign up to view the full content.
Unformatted text preview: the problem of signiﬁcant digits. What Matlab outputs
to the computer screen and what it stores in its internal memory are two entirely diﬀerent
things. Return to the default output precision by typing the following command at the
Matlab prompt. print doc >> format back close
exit By default, Matlab displays ﬂoating point numbers with four decimal places. For example,
if you enter x=1/7 at the prompt, Matlab responds with 0.1429. However, this is not what
Matlab stores internally. Rather, Matlab stores the number in double precision. This strategy
stores a lot more signiﬁcant ﬁgures in memory than what is displayed on the screen.
In the case where the interpolating polynomial is unique, there is a simple way to build the
polynomial without entering the coeﬃcients individually. Simply strip oﬀ the last column of
the augmented matrix after it has been placed in reduced row echelon form. If the reduced
row echelon form of the augmented matrix 10000 1 0 1 0 0 0 −2 R = 0 0 1 0 0 0 , 0 0 0 1 0 1 0 0 0 0 1 −4
then the command The
Interpolating
Polynomial title page
contents >> p=R(:,6)
will strip oﬀ the last column and store the result in the variable p. Of course, the last column
contains the coeﬃcients of the interpolating polynomial, so this is an extremely eﬀective
way to build the interpolating polynomial. Remember, even if only 4 decimal places are
displayed, internally, Matlab keeps as many decimal places for each coeﬃcient as possible.
You can easily see this when you work this exercise if you enter the commands
>>
>>
>>
>> format
p
format long
p There is one ﬁnal problem students have encountered in the past when working this exercise.
Polynomials can grow so quickly (not exponentially, but still pretty fast) that the scale is previous page
next page
back
print doc
close
exit just too large to see the oscillating behavior of the interpolating polynomial as it wiggles
through its data points. The axis command will help you construct a viewing window that
highlights this local behavior of the i...
View
Full
Document
 Summer '12

Click to edit the document details