Question: below you have a correct solution, which i don't understand. please explain it to me in great detail. a ) Writea functionthat, by receiving theLU

below you have a correct solution, which i don't understand. please explain it to me in great detail. a)Writea functionthat, by receiving theLU-factors ofA, b andavector\gamma as input,
returns the solutionx to the systemBx=\gamma using the identity (1). Therefore, the function
shouldnotcomputethematricesA1,B,B1explicitly.Assumethatyoualreadyhaveavailable
afunctionthatreturnsthesolutiontoalinearsystembyreceivingtheLU-factorsofamatrixand
aright-hand-side.Youcanusevector(notmatrix)operationssum,subtraction,dotproduct,and
multiplication/divisionbyascalar.Hint: ifyouhaveamatrixS=C+D@E, thenyouhavethe
indentityS@g=C@g+D@(E@g
b) Computethenumberofoperationsof thealgorithmsolvingthe linear systemBx=\gamma .
Assumethatsolvingthe linearsystemsassociatedwithLandUcostsn2 elementaryoperations
each.
c))If thecostofdoinganLUfactorizationofamatrixinRn\times n is (2/3)n3,whichstrategy
wouldleadtoareducednumberofoperationstosolvethelinearsystemBxwhentheLUfactors of A and B still need to be computed? Strategy (i): to compute the full matrix B then compute
LU and then solve, or Strategy (ii): the one you developed using identity (1)? What about if A
has a sparse structure?
Solutions: a)
deflin_sys(L,U,b,rhs):
#SolvelinearsystemwithAandb
invAb=lin_sys_A(L,U, b)
#SolvelinearsystemwithAandrhs
invArhs=lin_sys_A(L,U, rhs)
#Scalarfactor
scalar=np.dot(b,invArhs)/(1+np.dot(b,invAb))
#Computeresult
result=invArhs-invAb*scalar
returnresult
b)
SolvelinearsystemforL,Uand b: 2n2ops.
(0.2pts)SolvelinearsystemforL,Uand\gamma : 2n2ops.
(0.2pts)Compute the scalar factor: twodot products 2neach, nsumsbyone, n
divisions. So4nintotal.
(0.2pts)Computetheresult:multiplicationofvectorbyscalarn,nsubstractions. So
2nintotal.
(0.2pts)Addingalloperations: 4n2+6n
c)Computing the full matrix B can be performed in n2 multiplications of the rank
1 term and then n2 additions, hence 2n2(0.5 pts). Then the total cost of solving Bx =\gamma
would be 2n2+2/3n3+2n2=4n2+2/3n3. For the strategy above one obtain 4n2+6n +
2/3n3. All cubic and quadratic terms are the same, so both strategies lead to the same results
asymptotically (0.25 pts). If A is sparse, then the LU decomposition of A may take much
less operations than the one of B and therefore strategy (ii) may be more efficient

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!