Math Assignment 1 for Math 477/577: Matrix Operations and Graphing in Matlab, Assignments of Linear Algebra

A computer assignment for math 477/577 students, focusing on matrix operations and graphing functions in matlab. The assignment includes defining matrices, finding sums and products, generating graphs, and verifying solutions. Students are required to submit matlab code and executions for each question.

Typology: Assignments

Pre 2010

Uploaded on 08/16/2009

koofers-user-54t-2
koofers-user-54t-2 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Math 477/577 Computer Assignment 1 Charles Tier
For each question, please submit the Matlab code along with an execution of the code.
1. Define a 6 by 6 integer matrix A= floor(10*rand(6)) and use the sum function to find the
sum of first row and third column of A.
2. Write a script that prompts the user to input two square matrices Aand B. The output should
be the size of the matrices and the sum, difference and product of Aand B. Use comments
in the script and use disp to output titles. It might be useful to look at the script statistics.m
on the Matlab tip page.
3. Write a Matlab script to generate graphs of the functions y= cos xand y= cos(x2)in the
range x=-4:0.02:4 on the same axes. Please label the graphs using xlabel,ylabel, and title.
4. (Leon) Let n= 200 and generate an n×nmatrix and two vectors in Rnboth having integer
entries using
A=floor(10*rand(n));b=sum(A0)0;z=ones(n,1)
(a) Verify that the exact solution of Ax=bis z. Explain why.
(b) The solution of Ax=bcan be found in Matlab using the \ operation or by comput-
ing A1and finding A1b.Compare the speed of the two methods using Matlab’s tic
and toc commands to measure the elapsed time for each computation. Which method
is faster?
(c) Compare the accuracy of the two methods using the command: max(abs(x-z)). Explain
what is being measured and which method is more accurate.
(d) repeat if n= 1000.
5. Write a function col-sum that generates a random square matrix Aof specified size nand
then finds the sum of each column using:
(a) for loops
(b) the sum function
Test the function with n= 10,50.

Partial preview of the text

Download Math Assignment 1 for Math 477/577: Matrix Operations and Graphing in Matlab and more Assignments Linear Algebra in PDF only on Docsity!

Math 477/577 Computer Assignment 1 Charles Tier

For each question, please submit the Matlab code along with an execution of the code.

  1. Define a 6 by 6 integer matrix A = floor(10*rand(6)) and use the sum function to find the sum of first row and third column of A.
  2. Write a script that prompts the user to input two square matrices A and B. The output should be the size of the matrices and the sum, difference and product of A and B. Use comments in the script and use disp to output titles. It might be useful to look at the script statistics.m on the Matlab tip page.
  3. Write a Matlab script to generate graphs of the functions y = cos x and y = cos(x^2 ) in the range x = -4:0.02:4 on the same axes. Please label the graphs using xlabel, ylabel, and title.
  4. (Leon) Let n = 200 and generate an n × n matrix and two vectors in Rn^ both having integer entries using A = floor(10*rand(n)); b = sum(A′)′; z = ones(n,1)

(a) Verify that the exact solution of Ax = b is z. Explain why. (b) The solution of Ax = b can be found in Matlab using the ”\” operation or by comput- ing A−^1 and finding A−^1 b. Compare the speed of the two methods using Matlab’s tic and toc commands to measure the elapsed time for each computation. Which method is faster? (c) Compare the accuracy of the two methods using the command: max(abs(x-z)). Explain what is being measured and which method is more accurate. (d) repeat if n = 1000.

  1. Write a function col-sum that generates a random square matrix A of specified size n and then finds the sum of each column using:

(a) for loops (b) the sum function

Test the function with n = 10, 50.