cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

LU Decomposition

Teddy
12-Amethyst

LU Decomposition

Anyone can help me reverse this program?

 

This program contains the lower left side triangle to be 0, and I want the program to run on the opposite side on the upper right to be 0.

 

My program does not seem to be working properly. If anyone can help me reverse "0" in the matrix, that would be a great help in my studies. 

 

Thank you.

27 REPLIES 27
LucMeekes
23-Emerald III
(To:Teddy)

Instead of (or next to) a picture, you should post your worksheet, or at least a worksheet that contains your specific problem. That will greatly help us help you.

Have you considered using the LU() function that is built into Prime?

 

Success!
Luc

Teddy
12-Amethyst
(To:LucMeekes)

I have been attaching my Prime file on the message for more than 1 hour, but it keeps on failing to attache the .mctx content type and keeps on getting removed. 

 

No, I haven't tried the LU() function on the Prime. I wanted to play with the basics for now before using the shortcut LU() function.

LucMeekes
23-Emerald III
(To:Teddy)

You should not attach an .MCTX  (template) file, but the .MCDX (worksheet) file...

And in case all else fails, you can zip the file and attach that archive.

 

Success!
Luc

Teddy
12-Amethyst
(To:LucMeekes)

It still says it doesn't match its file extension and has been removed. I already tried zipping it, the mcdx and the mctx, and it still fails.

 

Hi

Prime LU decomposition on your matrix in the file.  Usually the matrix should be square?

Capture.JPG

Cheers

Terry

 

I dont think it should be squared all the time. The last column is considered to be the constant. Was looking for a opposite side of my program, just to have the 3 "0" to be on the upper right side of the matrix.

 

I can do it manually, but I want to learn how to do the process by using the program of Mathcad Prime itself.

HI,

Found on the web the algorithm in C++ to calculate LU Decomposition of square matrices.

Converted side by side the C++ coding to Prime programming.

f_LU function gives the same answer as the web page example results.

It does not get the same answer as MathCad Prime LU function?.

It depends which L or U diagonal is normalized

 

Cheers

Terry

 

Hi

Only two changes to the algorithm to get it to work on Rectangular matrices.

Capture.JPG

Capture2.JPG

Cheers

Terry

The mathcad that I am using is 6.0. Is there any chance you could lower the version so I can see the continuation of the program?

 

Thank you.

Hi,

Some members of the community know how to save back from 7 to 6.  Trust they see this and can backdate it.

If you don't mind coding yourself here is the total program as screen shot.

Capture.JPG

Capture2.JPG

Cheers

Terry

Hi,

Have simplified the coding slightly that saves a few lines.  Work in progress.

Capture.JPG

Cheers

Terry

 

Thank you for the great program. I'll try to analyze it and try to understand the program better. I'm still struggling with programming using mathcad Prime. I really appreciated the help.

Hi,

Your welcome.

Cheers

Terry

Werner_E
25-Diamond I
(To:Teddy)

Here is Terry's worksheet converted back to version Prime 6 - hope it works OK for you

Thanks Werner,

Teddy will be able to see the C++ code next to the Prime programming.

Cheers

Terry

I am trying to do a program that will put a zero value on my b(1,2), b(1,3) and b(2,3) just like what I did on the a(2,1), a(3,1) and a(3,2).Can you check where did my program did go wrong? Thank you.

Teddy
12-Amethyst
(To:Teddy)

This is my latest file for my program.

 

 

Hi,

You latest program matches the result of Prime's LU function.

Capture.JPG

Cheers

Terry

Yes, but I need the 2nd program to work. I am close to the exact program but it seems there's a hiccup. hope you could find it here.

 

This is my latest file.

Werner_E
25-Diamond I
(To:Teddy)

There may be more elegant ways but a quick fix is to add the highlighted line to deal with the last column as well.

Werner_E_0-1642514858103.png

Note that the numeric evaluation suffers from numerical rounding errors and the like.

BTW, its always better not to use inline evaluations but rather B:=<program> and then B= or B-> in a separate region.

You may also consider turning your program into a function as this is more versatile.

 

!! Your algorithm would fail for a 2 x 3 matrix (n=2) and will not work OK for n>3.

Furthermore your algorithm (both for A and for B) suffers from a problem with choosing the pivot element so you may run into a division by zero now and then:

Werner_E_2-1642515200212.png

 

A better algorithm would run through the (first) column and find an appropriate non-zero element, swap the rows and then goes ahead.

You may want to read about that here

https://en.wikipedia.org/wiki/Gaussian_elimination

and in more detail here

https://en.wikipedia.org/wiki/Row_echelon_form

 

Teddy
12-Amethyst
(To:Werner_E)

Side note, If I wanted to do my program to be in it's Reduced Row Echelon Form (RREF),how do I do this without using the RREF function in mathcad prime?

Hi,

Have obtained an algorithm from the web in Lua and transcribed it to Prime.

It is a Prime 7 file so will need to be saved back by someone to Prime 6 for you.

Capture.JPG

Here is a comparison of the inbuilt rref(a) compared to programmed f_rref(a)

Capture2.JPG

Cheers

Terry

 

Here's the Prime6 file.

 

Success!
Luc

Can I ask what does the lead have to do with the program?

Hi Teddy

"lead" is a counter incremented by one several times in the program.

"lead" is used to set a local variable "lm several times in the program.

"lead is used a an index into the matrix "M" as test for the while loop.

 

Cheers

Terry

I wanted to program a Gauss-Seidel using this mathcad file. Can you help me out with my program? I can only do this with manually inputting the iterations and I wanted to input an error of not more than +/- 0.001 as its difference. Any tip on how to do it on this program? Thank you.

Your solution is kinda overwhelming to my understanding. Still trying to understand the long program. Thank you for helping me 🙂

Announcements

Top Tags