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. aWritea functionthat, by receiving theLUfactors ofA, b andavectorgamma as input,
returns the solutionx to the systemBxgamma using the identity Therefore, the function
shouldnotcomputethematricesABBexplicitly.Assumethatyoualreadyhaveavailable
afunctionthatreturnsthesolutiontoalinearsystembyreceivingtheLUfactorsofamatrixand
arighthandside.Youcanusevectornotmatrixoperationssumsubtraction,dotproduct,and
multiplicationdivisionbyascalarHint: ifyouhaveamatrixSCD@E thenyouhavethe
indentityS@gC@gD@E@g
b Computethenumberofoperationsof thealgorithmsolvingthe linear systemBxgamma
Assumethatsolvingthe linearsystemsassociatedwithLandUcostsn elementaryoperations
each.
cIf thecostofdoinganLUfactorizationofamatrixinRntimes n is nwhichstrategy
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 What about if A
has a sparse structure?
Solutions: a
deflinsysLUbrhs:
#SolvelinearsystemwithAandb
invAblinsysALU b
#SolvelinearsystemwithAandrhs
invArhslinsysALU rhs
#Scalarfactor
scalarnpdotbinvArhsnpdotbinvAb
#Computeresult
resultinvArhsinvAbscalar
returnresult
b
SolvelinearsystemforL,Uand b: nops.
ptsSolvelinearsystemforLUandgamma : nops.
ptsCompute the scalar factor: twodot products neach, nsumsbyone, n
divisions. Sonintotal.
ptsComputetheresult:multiplicationofvectorbyscalarn,nsubstractions. So
nintotal.
ptsAddingalloperations: nn
cComputing the full matrix B can be performed in n multiplications of the rank
term and then n additions, hence n pts Then the total cost of solving Bx gamma
would be nnnnn For the strategy above one obtain nn
n All cubic and quadratic terms are the same, so both strategies lead to the same results
asymptotically 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
