15.2-1 -- Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is (5, 10, 3, 12, 5, 50, 6).
5. -- Implement Matrix-ChainMultiply(A,s,i,j) using algorithm Matrix-Chain-Order and Matrix-Multiply, where Matrix-Multiply(X,Y, p,q,r) multiplies matrices X and Y, X and Y have pxq and qxr demension, respectively. Given a chain of 6 matrices whose dimensions are given in 15.2-1, and elements are random real numbers from -10 to 10, use Matrix-Chian-ultiply to calculate the product of these matrices.
Solution
First we will assign the values
(5,10,3,12,5,50,6)
Let p0=5
p1=10
p2=3
p3=12
p4=5
p5=50
p6=6
The corresponding matrix as follows
A1=5*10
A2=10*3
A3=3*12
A4=12*5
A5=5*50
A6=50*6
Using the algorithm
for all m[i,j]=0
m[1,2]=m[1,1]+m[2,2]+p0 x p2 x p2
m[1,2]=0+150
m[1,2]=150
--
m[3,4]=m[3,3]+m[4,4]+p2 x p3 x p4
m[3,4]=0+180
m[3,4]=180
--
m[4,5]=m[4,4]+m[5,5]+p3 x p4 x p5
m[4,5]=0+3000
m[4,5]=3000
---
m[5,6]=m[5,5]+m[6,6]+p4 x p5 x p6
m[5,6]=0+1500
m[5,6]=1500
--
m[1,3]
=
min of
{m[1,1]+m[2,3]+p0 x p1 x p3 =750 }
{m[1,2]+m[3,3]+p0 x p2 x p3 =330 }
=330
--
m[2,4]
=
min of
{m[2,2]+m[3,4]+p1 x p2 x p4 =330 }
{m[2,3]+m[4,4]+p1 x p3 x p4 =960 }
=330
---
m[3,5]
=
min of
{m[3,3]+m[4,5]+p2 x p3 x p5 =4800 }
{m[3,4]+m[5,5]+p2 x p4 x p5 =930 }
=930
--
m[4,6]
=
min of
{m[4,4]+m[5,6]+p3 x p4 x p6 =1860 }
{m[4,5]+m[6,6]+p3 x p5 x p6 =6600 }
=1860
---
m[1,4]
=
min of
{m[1,1]+m[2,4]+p0 x p1 x p4 =580 }
{m[1,2]+m[3,4]+p0 x p2 x p4 =405 }
{m[1,3]+m[4,4]+p0 x p3 x p4 =630 }
=630
--
m[2,5]
=
min of
{m[2,2]+m[3,5]+p1 x p2 x p5 =2430 }
{m[2,3]+m[4,5]+p1 x p3 x p5 =9360 }
{m[2,4]+m[5,5]+p1 x p4 x p5 =2830 }
=2430
---
m[3,6]
=
min of
{m[3,3]+m[4,6]+p2 x p3 x p6 =2076 }
{m[3,4]+m[5,6]+p2 x p4 x p6 =1770 }
{m[3,5]+m[6,6]+p2 x p5 x p6 =1830 }
=1770
---
m[1,5]
=
min of
{m[1,1]+m[2,5]+p0 x p1 x p5 =4930 }
{m[1,2]+m[3,5]+p0 x p2 x p5 =1830 }
{m[1,3]+m[1,4]+p0 x p3 x p5 =6330 }
{m[1,4]+m[1,5]+p0 x p4 x p5 =1655 }
=1655
--
m[1,6]
=
min of
{m[1,1]+m[2,6]+p0 x p1 x p6 =2250 }
{m[1,2]+m[3,6]+p0 x p2 x p6 =2010 }
{m[1,3]+m[4,6]+p0 x p3 x p6 =2550 }
{m[1,4]+m[5,6]+p0 x p4 x p6 =2055 }
{m[1,5]+m[6,6]+p0 x p5 x p6 =3155 }
=2010
--
m[2,6]
=
min of
{m[2,2]+m[3,6]+p1 x p2 x p6 =1950 }
{m[2,3]+m[4,6]+p1 x p3 x p6 =2940 }
{m[2,4]+m[5,6]+p1 x p4 x p6 =2130 }
{m[2,5]+m[6,6]+p1 x p5 x p6 =5430 }
=1950
m-table
s-table
The min cost is 2010
the optimal paranthesizaiton =
((A1*A2)*(A3*A4)*(A5*A6))
---
ALL THE BEST
15.2-1 -- Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is (5,...
Find an optimal parameterization of a matrix-chain product whose sequence of dimensions is p= <6, 10, 3, 15, 8>. Show the m and s tables and the printing of an optimal parameterization. Use the algorithm learned in class. Upload a file with your solution.
Use the dynamic programming technique to find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is <5, 8, 40, 10, 20, 6>. Matrix Dimension A1 5 * 8 A2 8*40 A3 40*10 A4 10*20 A5 20*6
Use the dynamic programming technique to find
an optimal parenthesization of a matrix-chain product whose
sequence of dimensions is <5, 8, 4, 10, 7, 50, 6>.
Matrix Dimension
A1 5*8
A2 8*4
A3 4*10
A4 10*7
A5 7*50
A6 50*6
You may do this either by implementing the MATRIX-CHAIN-ORDER
algorithm in the text or by simulating the algorithm by hand. In
either case, show the dynamic programming tables at the end of the
computation.
Using Floyd’s algorithm (See Dynamic Programming...
Find an optimal parenthesisation of a matrix chain product whose sequene of dimensions given by {4,6,30,8,9}
Compute the optimal solution for MATRIX-CHAIN-multiplication for a matrix-chain whose dimensions is given by p = [2, 3, 7, 5, 6, 4, 3]. ( give the number of scalar multiplication, and the optimal order of multiplication)
READ CAREFULLY AND CODE IN C++
Dynamic Programming: Matrix Chain Multiplication Description In
this assignment you are asked to implement a dynamic programming
algorithm: matrix chain multiplication (chapter 15.2), where the
goal is to find the most computationally efficient matrix order
when multiplying an arbitrary number of matrices in a row. You can
assume that the entire input will be given as integers that can be
stored using the standard C++ int type and that matrix sizes will
be at...
10×8,8×6,6×15,15×12
4. [15] Dynamic Programming. We are given a set of matrices Ap.A1, A2. .. .An-1. which we must multiply in this order. We let (d, dira) be the dimension of matrix A. The minimal number Nij of operations required to multiply matrices (A, Ati .. A) is defined by: a. Explain this formula. Apply this formula to compute the optimal parenthetization of the product of matrices Ao-A1,Az,A3, where the dimensions of these matrices are, respectively: 6x15, and 15x12. b....
Question A matrix of dimensions m × n (an m-by-n matrix) is an ordered collection of m × n elements. which are called eernents (or components). The elements of an (m × n)-dimensional matrix A are denoted as a,, where 1im and1 S, symbolically, written as, A-a(1,1) S (i.j) S(m, ). Written in the familiar notation: 01,1 am Gm,n A3×3matrix The horizontal and vertical lines of entries in a matrix are called rows and columns, respectively A matrix with the...
4.
5.
6
7
8.
Find the 8th term of the geometric sequence whose common ratio is 3 2 and whose first term is 7. 8 х 5 ? For a given geometric sequence, the 3 term, as, is equal to write your answer as a fraction. 11 81 and the 8th term, ay, is equal to - 33. Find the value of the 12th term, aiz. If applicable, 음 X 5 Suppose that a sequence is defined as follows....
1. Find a 2x2 matrix A if for the vector v= [R], Av = [4 +38] 2. For this problem, use matrices A = La ), B=1 _Jandc=lo 9]. Suppose that the matrices A and B commute (so AB=BA) and the matrices A and C commute. Find the entries for the matrix A. 3. Find a number a so that the vectors v = [3 2 a) and w = [2a -1 3] are orthogonal (perpendicular). 4. For the vector...
> How did you get S-table?
Orlando Aguilar Wed, Nov 10, 2021 4:27 PM