CS 417/517 Computational Methods and Software Homework 3, Assignments of Computer Science

Information about homework 3 for the cs 417/517 computational methods and software course, which was due on february 12, 2004. Instructions for accessing the homework problems, requirements for receiving credit, and two problems related to fruit purchases and the hilbert matrix in matlab. The first problem involves determining the cost of single pieces of fruit based on the given purchases. The second problem involves investigating the hilbert matrix in matlab, creating a right hand side vector, solving the system of equations, and analyzing the condition number and machine precision.

Typology: Assignments

Pre 2010

Uploaded on 02/12/2009

koofers-user-2kj-1
koofers-user-2kj-1 🇺🇸

8 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 417/517 Computational Methods and Software
Spring 2004
HW 3
Assigned: Thurs Feb 5, 2004; Due: Thurs Feb 12, 2004
Homework problems will be posted in the course directory:
www.cs.odu.edu/˜pothen/Courses/CS417. If any corrections are found to be neces-
sary, they will be posted in this directory as well. You must show your work to receive credit for
your answers. In problems where you are asked to give reasons, an answer without a stated reason
will receive no credit.
1. Alice buys three apples, twelve bananas, and one cantaloupe for $2.36. Bob buys twelve
apples and two cantaloupes for $5.26. Carol buys two bananas and three cantaloupes for
$2.77. How much do single pieces of each fruit cost?
2. Matlab has a collection of ill-conditioned matrices that cause large errors in the computed
solution when floating point arithmetic is used. These matrices include magic,pascal,
hilb, etc. For this problem, let us investigate the n×nHilbert matrix H, whose elements
are given by
hij = 1/(i+j1),for i= 1,2, . . . , n;j= 1,2, . . . , n.
(a) In Matlab, type type hilb.m to see Matlab’s efficient ‘vectorized’ code for com-
puting the Hilbert matrix. There are five lines of code in this Matlab program. Explain
what each line of code does.
Hint. Use Matlab’s help command as you need. In particular, you might find
help punct to give you useful information.
(b) Create a Hilbert matrix of order nand create a right hand side vector bsuch that the
exact solution to Hx =bis the vector of all ones. Solve the system of equations
Hx =bin Matlab. Compare the solution that you compute with the exact solution. Do
this for three values of matrix sizes: n= 10,n= 20, and n= 30.
(c) The difference between the computed solution and the exact solution (in absolute value)
is known to be less than or equal to the product of two numbers: the condition number
of the matrix and the machine precision. Use the Matlab command cond to calcu-
late the condition numbers of the three Hilbert matrices; then compute the product of
the condition number and machine precision in Matlab. Do the values of the product
correctly predict the errors you see for the three values of n?

Partial preview of the text

Download CS 417/517 Computational Methods and Software Homework 3 and more Assignments Computer Science in PDF only on Docsity!

CS 417/517 Computational Methods and Software

Spring 2004 HW 3 Assigned: Thurs Feb 5, 2004; Due: Thurs Feb 12, 2004

Homework problems will be posted in the course directory: www.cs.odu.edu/˜pothen/Courses/CS417. If any corrections are found to be neces- sary, they will be posted in this directory as well. You must show your work to receive credit for your answers. In problems where you are asked to give reasons, an answer without a stated reason will receive no credit.

  1. Alice buys three apples, twelve bananas, and one cantaloupe for $2.36. Bob buys twelve apples and two cantaloupes for $5.26. Carol buys two bananas and three cantaloupes for $2.77. How much do single pieces of each fruit cost?
  2. Matlab has a collection of ill-conditioned matrices that cause large errors in the computed solution when floating point arithmetic is used. These matrices include magic, pascal, hilb, etc. For this problem, let us investigate the n × n Hilbert matrix H, whose elements are given by

hij = 1/(i + j − 1), for i = 1, 2 ,... , n; j = 1, 2 ,... , n.

(a) In Matlab, type type hilb.m to see Matlab’s efficient ‘vectorized’ code for com- puting the Hilbert matrix. There are five lines of code in this Matlab program. Explain what each line of code does. Hint. Use Matlab’s help command as you need. In particular, you might find help punct to give you useful information. (b) Create a Hilbert matrix of order n and create a right hand side vector b such that the exact solution to Hx = b is the vector of all ones. Solve the system of equations Hx = b in Matlab. Compare the solution that you compute with the exact solution. Do this for three values of matrix sizes: n = 10, n = 20, and n = 30. (c) The difference between the computed solution and the exact solution (in absolute value) is known to be less than or equal to the product of two numbers: the condition number of the matrix and the machine precision. Use the Matlab command cond to calcu- late the condition numbers of the three Hilbert matrices; then compute the product of the condition number and machine precision in Matlab. Do the values of the product correctly predict the errors you see for the three values of n?