solve mathematical equation

Moderator: Dr.BeauWebber

solve mathematical equation

Postby m_labbaf » Fri Aug 21, 2015 12:28 pm

I want to solve Ax=b, which A is 8x8 and x and b are 8x1.
I should find x as fast as possible. Is APL language can help me to reach my desire goal?

thanks
m_labbaf
 
Posts: 20
Joined: Sun Mar 29, 2015 7:25 am

Re: solve mathematical equation

Postby Dr.BeauWebber » Mon Dec 21, 2015 5:44 am

I want to solve Ax=b, which A is 8x8 and x and b are 8x1.
I should find x as fast as possible. Is APL language can help me to reach my desire goal ?


This is something Apl is excellent at : it even has a "solve" primitive ⌹

Let us set up a set of example equations :

⊢ A ← 8 8 ⍴ ? 64 ⍴ 1000
495 73 81 626 946 39 708 431
510 402 80 269 368 248 373 871
175 483 96 75 956 261 390 195
611 988 198 575 455 170 368 2
763 345 98 465 693 963 221 647
177 905 812 849 247 11 568 459
265 513 447 900 53 372 914 528
631 34 976 65 354 542 848 450

⊢ x ← ? 8 1 ⍴ 100
49
5
15
76
50
91
30
88

⊢ b ← A +.× x
183428
177450
118541
130985
261771
160685
201041
182731


We can now easily solve for x :
⊢ x ← b ⌹ A
49
5
15
76
50
91
30
88

Which we see above is correct.
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England


Return to APL

Who is online

Users browsing this forum: No registered users and 2 guests

cron