Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Activities 1. Write a MATLAB function to generate a sequence of n + 1 evenly spaced values between a and b, inclusive. The distance between

Activities

1. Write a MATLAB function to generate a sequence of n + 1 evenly spaced values between a and b, inclusive. The distance between these points will be h = ba n . Thus, you should use as input to the function n, a, and b. The output should be the computed list of points between a and b, inclusive.

2. Generate 11, 21, and 51 evenly spaced points between 0 and 1, inclusive, using two different (yet mathematically equivalent) methods.

(a) Generate xk, where x1 = 0, using xk = xk1 + h. Save the values in an array and output the array. Note that k = 1, . . . , 11. Use the format long e option when displaying the results.

(b) Generate xk using xk = x1 + (k 1)h. Again, save and output the values in an array. Is there a difference between the two methods?

3. Use the MATLAB linspace command to compute the same sequences of values. Compare your answers and discuss. Use help linspace in order to get information on using the command.

4. Generate the data in Tables 2.1 and 2.2 of Heister and Rebholz. That is, first compute lim x0 e x e x x . Next, using that e x = X n=0 x n n! e x e x x 2 + x 2 3 compute limx0 2 + x 2 3 . The idea is that you can often manipulate expressions to avoid the mathematical operations that computationally unstable. This is demonstrated again in the next problem.

5. Compute the polynomial (x 1)7 in the interval [0.988, 1.012] two ways. Use both the compact expression and the expansion (x 1)7 = x 7 7x 6 + 21x 5 35x 4 + 35x 3 21x 2 + 7x 1. Plot both expressions, and describe what you observe. Give reasons for the discrepancies in the plots. The following script can be used to generate the data points and the plots:

% Generate the data points; there will be a lot of them so be sure to suppress.

% Note this alternative way to generate a set of points between a 2

% starting and ending value.

% Contrast this with linspace; the spacing between values can be controlled

% using this strategy.

x = 0.988:.0001:1.012;

% compute the values using the expanded form

y1 = x.^7-7*x.^6+21*x.^5-35*x.^4+35*x.^3-21*x.^2+7*x-1;

% generate the plot

plot(x,y1)

% the hold command can be used to keep the figure open for another plot

% this is in contrast to the plot command with several arguments as used

% in CA 1

hold on;

% generate the values of the dependent variable using vector operators

y2 = (x-1).^7 ;

% put the plot on the same figure

plot(x,y2, r);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

8-13 What is a botnet?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago