what's wrong with this code? I properly impleme nted this before and it worked and now…
- User
what's wrong with this code? I properly impleme nted this before and it worked and now it deosn,'t want to work.
library(Matrix)
A = matrix(c(2,3,5,4), 2, byrow=TRUE)
b = matrix(c(5,15), 2, byrow=TRUE)
L = expand(lu(A))$L
U = expand(lu(A))$U
y = forwardsolve(L, b) solve(U, y) # wrong?
solve(A, b) # isn't the same somehoiw
- Assistant
Based on your description, it looks like you're trying to solve a system of linear equations ( A \mathbf{x} = \mathbf{b} ) using LU decomposition and then verify it with a direct solve.
You're using the
Matrixlibrary, but there are some issues that might be causing your discrepancy. Let's go through the code step by step to identify potential issues: