Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python to solve the below : you can use native Python, as well as the math, numpy, scipy, and time libraries. A Toeplitz matrix

Use python to solve the below :

you can use native Python, as well as the math, numpy, scipy, and time libraries.

image text in transcribed

image text in transcribed

A Toeplitz matrix (T) is a special nn matrix with constant values across its diagonals: T=t0t1t2t(n1)t1t0t1t2t1t2t1tn1t2t1t0 We define a vector t of size 2n1 that contains all the diagonal constants: t=[t(n1)t2t1t0t1t2tn1] We would like to solve a system of linear equations of the form: Tx=b where x is a vector of unknowns and b is a vector of constants (both of size n1 ). (a) Create a function in Python called make_toeplitz that takes as input the vector t and returns the Toeplitz matrix T. You should use numpy functions for this task (e.g. numpy.eye (n,k=k) which creates a matrix of size nn with a diagonal of 1 's along diagonal k ). You may choose to use scipy. linalg. toeplitz instead to proceed with the problem, but you will receive a small fraction of credit for part (a). (b) Create a function in Python called gauss_elim_solve that takes as input the matrix T and vector b and returns the vector x that is solved through Gaussian Elimination. You should apply the Gaussian Elimination rules/algorithm that we discussed in class. (c) Using your functions from parts (a) and (b), solve the system of linear equations when b= 1 (all constants in b are 1) and t=[(21)(41)1(21)(41)]; note that the "..." represents a vector of zeros of length 20 , i.e. t has length 45 . Report the values of x. (d) Now, solve the same system from part (b) through matrix inversion (e.g. using numpy. linalg. inv and numpy.matmul). Report the values of x. (e) Use the perf_counter () function from the time library to compute the time it takes to perform the calculations in part (b) and part (c). Report the two times in seconds and comment on which method is faster. Note: to time how long it takes to run the code print ("Hello World"), you would use: from time import perf_counter tic = perf_counter() print ("Helio World") toc = perf_counter ( ) print ("Elapsed time was s " (toc-tic))

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions