Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUdecomp #1

Open
pauljsymonds opened this issue Sep 17, 2020 · 1 comment
Open

LUdecomp #1

pauljsymonds opened this issue Sep 17, 2020 · 1 comment
Labels
good first issue Good for newcomers

Comments

@pauljsymonds
Copy link

can you take a look at the LUdecomp.py for the Doolittle algorithm.

If you take the matrix:

a = np.array([[2, -1, 0],
[-1, 2, -1],
[0, -1, 2]],float)

b = np.array([7,3,2], float)

x = array([7.2500, 7.5000, 4.7500])

Which you can get by simply running LUSolve(a,b)

When reading the book, it mentions that the following steps are required:

LUsolve(LUdecomp(a), b)

but this gives:

array([7.6667, 8.3333, 5.6667])

I think this example may be incorrect?

I have checked this with ColeskiSol

choleskiSol(choleski(A),b)

array([7.2500, 7.5000, 4.7500])

Is my assumption correct?

@nickcafferry
Copy link
Owner

Yes. you're right. This example is wrong. You can also check it on sympy online shell .

In addition to the solvers in the solver.py file, we can solve the system Ax=b by passing the b vector to the matrix A’s LUsolve function. Here we’ll cheat a little choose A and x then multiply to get b. Then we can solve for x and check that it’s correct:
`

a = Matrix([ [2, -1, 0], [-1, 2, -1], [0, -1, 2] ])
b = Matrix(3,1,[7,3,2])
x = a.LUsolve(b)
x
`
Which will return a fraction version of the solution.

@nickcafferry nickcafferry added the good first issue Good for newcomers label Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants