Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve the following in python: The banded, upper triangular matrix A E RnXn can be written as 0 a2 b2 c2 0 3 3 an-2

Solve the following in python:

image text in transcribed

The banded, upper triangular matrix A E RnXn can be written as 0 a2 b2 c2 0 3 3 an-2 bn-2 Cn-2 where (, , an-2,an-1, an) E R", 6- (bi,b2,...,bn-2,bn,-1) R-1, n-2 The entries of , b, and are all assumed to be nonzero (a) Write a pseudocode for computing the matrix-vector product of A with a vector x. That is, given vectors a, b, and c that define A as in definition (1), and given a vector x E Rn, your algorithm should compute the matrix-vector product y- Aa Your pseudocode should have the following form Input: vector re Rn and vectors a E R", be Rn-i and Rn-2 Insert pseudocode here Output: vector fE R" such that y- At (b) Analyse the complexity of the algorithm from part (a). That is, determine how many flops are required to compute the product y - Ai with your algorithm. In terms of "Big-Oh" notation, what is the asymptotic behaviour of your algorithm as n increases? (c) Implement your pseudo-code in as a function called tridag matvec.py. Also, write a script called compare.py to generate a tridiagonal test matrix and a test vector for a n -10*, k- 2' .. , 7, compute the product and measure the time your code takes to complete. Produce a plot of the time taken versus n on a logarithmic scale, along with your prediction. (d) Repeat the test, but now using the built-in matrix-vector product (scipy.dot/scipy.matmul) and the matrix A defined as an n n matrix with mostly zeros. Plot the time taken in the same plot as for (c). Which algorithm is faster? Is the difference as great as you expectedi

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

Students also viewed these Databases questions

Question

What is the difference between animal welfare and animal rights?

Answered: 1 week ago

Question

Identify the elements that make up the employee reward package.

Answered: 1 week ago

Question

Understand the purpose, value and drawbacks of the interview.

Answered: 1 week ago