October 22, 2024
Chicago 12, Melborne City, USA
python

How to Solve Extremely Ill-Conditioned Linear System of Equations Ax = b?


I am working on solving a system of linear equations with multiple variables. The system is of the form Ax=b, where the matrix A is extremely ill-conditioned. I have been struggling to find a stable solution for this problem. I have tried several numerical approaches, including genetic algorithms and other optimization methods, but I have not been successful in obtaining a reliable solution.
Here are some additional details about the problem:

  1. The system is ill-conditioned, leading to significant numerical instability.
  2. I know the boundaries of the solution space for x.
  3. I also have the real solution for x that can be used for comparison.
    I have been working on this problem for 4 months and would greatly appreciate any advice or suggestions on possible methods I could use to solve this problem. Below is the code I have been working on:
    import numpy as np

Example of a linear system Ax = b

A = np.array([[0.2631578947368421, 0.5263157894736842, 0.5263157894736844, 0.5263157894736842, 0.5263157894736832, 0.5263157894736863, 0.5263157894736847, 0.5263157894736807, 0.5263157894736858, 0.5263157894736874, 0.5263157894736807, 0.5263157894736903, 0.5263157894736719, 0.5263157894736908, 0.5263157894736841, 0.5263157894736907, 0.5263157894736836, 0.5263157894736858, 0.5263157894736823, 0.2631578947368365], [0.04616805170821791, 0.2770083102493075, 0.5540166204986151, 0.831024930747922, 1.1080332409972313, 1.3850415512465382, 1.6620498614958414, 1.939058171745151, 2.2160664819944698, 2.4930747922437604, 2.770083102493075, 3.0470914127423727, 3.324099722991689, 3.6011080332410406, 3.8781163434902615, 4.155124653739605, 4.432132963988941, 4.7091412742382674, 4.986149584487408, 2.585410895660285], [0.01214948729163629, 0.17009282208290807, 0.6074743645818146, 1.3364436020799917, 2.3570005345774394, 3.669145162074166, 5.2728774845701425, 7.1681975020654125, 9.355105214559902, 11.833600622053815, 14.60368372454684, 17.665354522039188, 21.01861301453058, 24.663459202021933, 28.599893084511656, 32.82791466200125, 37.3475239344895, 42.15872090197777, 47.261505564466304, 25.404577926811076], [0.003836680197358829, 0.11510040592076487, 0.6906024355245893, 2.1869077124945333, 5.064417860513651, 9.783534503265015, 16.80465926443172, 26.58819376769665, 39.594539636743036, 56.284098495254156, 77.11727196691214, 102.55446167540148, 133.05606924440457, 169.08249629760482, 211.09414445868117, 259.55141535132645, 314.9147105992111, 377.64443182603173, 448.20098065546176, 249.66812716292327], [0.0013462035780206416, 0.08346462183727979, 0.8104145539684264, 3.6374420678117727, 10.98771360380448, 26.253662178558574, 53.79698738486087, 98.9486553916731, 168.00889894413191, 268.2472173635493, 407.90237654741054, 596.1824089693795, 843.2646136792825, 1160.2955563031492, 1559.391069043153, 2053.6362506776254, 2657.085466561179, 3384.7623486244856, 4252.659795374332, 2454.0443119062293], [0.0005060915706844517, 0.06376753790624091, 0.977768914562361, 6.142939484967874, 24.061617636621573, 70.88824630577116, 172.98007449366287, 369.44785878279066, 714.7065648531495, 1281.0260689984716, 2161.081859642508, 3470.505738855215, 5350.43652386912, 7970.0707485954135, 11529.213365140262, 16260.828445321196, 22433.589882183536, 30354.432091514733, 40371.10071336558, 24125.111885079627], [0.000199772988428073, 0.05074233906073054, 1.2086265799898421, 10.52204330050661, 53.1623890425482, 192.56158309179648, 558.6040316046474, 1383.8734386286008, 3047.9544640160657, 6129.78922823161, 11468.088664052528, 20229.79871516316, 33986.62138164197, 54799.590612342974, 85311.70304416865, 128848.60358824069, 189527.3258629603, 272373.0874739548, 383444.14014094067, 237204.74234135504], [8.177841631558544e-05, 0.04170699232094857, 1.525985248448825, 18.26030257910707, 118.45767160145178, 526.1288014237875, 1811.5015044680817, 5200.14311014287, 13030.461637079174, 29389.261475642077, 60955.02933243027, 118078.62618847642, 216131.06102286233, 377148.0220534573, 631800.8412464914, 1021723.567846711, 1602225.8266797115, 2445421.1369783944, 3643800.3674849914, 2332619.738889518], [3.4433017396035974e-05, 0.035190543778748765, 1.962750857608843, 32.07442457044231, 266.08189945425056, 1445.6186547125121, 5898.669318115217, 19601.25346918999, 55842.64128933968, 141181.32899328327, 324503.95250974444, 690124.2684128385, 1375984.281639135, 2598144.550058879, 4682875.646503484, 8107787.7093846835, 13553559.963574778, 21967957.043749705, 34643943.90293282, 22941960.12632054], [1.482761514661836e-05, 0.030337300589981166, 2.565948456352602, 56.96855739498626, 602.2482623315084, 3993.597356552123, 19284.214364763036, 74109.57945885368, 239888.82621006214, 679517.2093759514, 1730274.894110321, 4038820.3886221624, 8769871.909895979, 17915506.810620558, 34737927.90495606, 64385056.11119948, 114725411.2807917, 197456437.405424, 329548714.5873195, 225674523.46717367], [6.503339976586999e-06,0.02662467386414718, 3.4028726427491502, 102.2222941881844, 1372.9697489546622, 11090.004552603008, 63289.61469608228, 281033.2830500356, 1032937.6510927714, 3276775.5064827166, 9240322.067976553, 23667239.005026072, 55956770.12012526, 123653482.54987651, 257900340.81605792, 511658163.1909542, 971720095.7421173, 1775814264.2008028, 3136394342.565819, 2220237465.9689145], [2.8962242810711336e-06, 0.023720076861972583, 4.570068142073387, 185.1510132922707, 3151.3229048050794, 30950.201396962748, 208494.3362667524, 1068818.2269598143, 4457993.562056249, 15830831.885090895, 49422845.06949101, 138867527.81984574, 357427116.3471756, 854263842.1830392, 1916259653.4407656, 4068975766.190217, 8235627619.322586, 15979652255.529503, 29864798291.84165, 21846437986.30958], [1.3065673448441202e-06, 0.021404186243236374, 6.206458814613235, 338.25186559371514, 7279.4454734617675, 86789.47840610598, 689342.65808103, 4076443.7713192627, 19283526.19090452, 76622938.48406932, 264745332.77745613, 815845210.1666586, 2285564263.2410135, 5907216373.350897, 14249800747.22237, 32381636881.49914, 69843294987.58371, 143873066255.11298, 284515200746.77954, 214993631768.52744], [5.959780871218794e-07, 0.019527818002635502, 8.51257672221022, 622.8428590479372, 16916.506272015595, 244484.25863030527, 2287190.539621752, 15590449.467408989, 83597816.14014326, 371533995.77371144, 1420298802.259079, 4799128586.505964, 14630724487.06968, 40886082041.68018, 106050481742.22818, 257880802621.92126, 592684672089.4023, 1296083092479.491, 2711860524177.4087, 2116088064345.1155], [2.7446359275349705e-07, 0.017986697087507678, 11.77878348435163, 1155.2006266611124, 39534.011119679184, 691711.1315644486, 7614525.421026114, 59786466.295246, 363198541.24247295, 1804717403.959104, 7630842667.81576, 28265577978.617073, 93756165298.87509, 283247629416.0, 789883793326.0531, 2055150639057.134, 5032595199694.663, 11682238560420.287, 25860932202386.844, 20830730007071.32], [1.2745987279574165e-07, 0.016706165527337863, 16.426776035367066, 2156.840269762967, 92881.13795323373, 1965171.272331401, 25433360.16749781, 229869476.23104456, 1581294278.124596, 8781658481.32602, 41057910856.38818, 166681448812.9191, 601437347775.399, 1964045239510.5566, 5887861964076.559, 16389682820891.781, 42759037053713.48, 105355646694028.62, 246737331622183.28, 205086597582329.47], [5.963034984596101e-08, 0.01563161916931991, 23.070755879333625, 4051.5780321443635, 219299.30164694792, 5605210.04790599, 85218232.7768693, 886055196.0568076, 6898888714.529369, 42804163505.82198, 221229310438.997, 984109398414.4504, 3862177717923.6807, 13630983578797.812, 43923094262784.516, 130796881210748.77, 363521124682395.56, 950663152606046.4, 2355256815163718.5, 2019442693090968.5], [2.8080774165688005e-08, 0.0147223567642319, 32.607756978537495, 7653.524746891779, 520193.33047812904, 16047815.505060311, 286402813.21115005, 3423797740.5710363, 30159319716.338284, 208988683676.4698, 1193712085762.3616, 5817264240315.865, 24826756703769.566, 94686780484992.38, 327918591757438.6, 1044532105808638.8, 3092397682125914.0, 8582841945379103.0, 2.249330105310868e+16, 1.9887796789081304e+16], [1.3301419341641686e-08, 0.01394752248474259, 46.351286386722236, 14532.32081666552, 1239318.4485046524, 46109677.25641766, 965354723.2627482, 13261423708.873953, 132104572079.00903, 1022049013592.322, 6449960132843.258, 34427531659546.523, 159752623907578.7, 658315014825255.8, 2450043309292364.0, 8347208993546228.0, 2.632225110056608e+16, 7.75299725776407e+16, 2.1492077468011373e+17, 1.958854252542722e+17], [6.334009210305565e-09, 0.013283367415392315, 66.2294067770186, 27724.768445003378, 2964642.6736306846, 132936122.76553169, 3262957243.629135, 51484202983.95192, 579756872725.7793, 5006308363854.427, 34898293769824.617, 203984359826476.7, 1028988547542219.4, 4580955854480411.0, 1.8319465121853e+16, 6.675031315801434e+16, 2.2418714306276528e+17, 7.007136858670711e+17, 2.0545304276194056e+18, 1.929644497166946e+18]])
b = np.array([0.21889287411681013, -5.451469125207363, -48.5405314111465, -458.2759116776347, -4311.992215246077, -40260.24003268487, -372856.5160208128, -3421741.880529692, -31075527.988023646, -278812725.61645645, -2465651256.114232, -21423032881.895355, -182020352145.8224, -1501367485609.5044, -11876653122710.586, -88078883844433.19, -582227768868795.0, -2932551616930456.0, -1492184231720320.0, 2.5194117264312883e+17])
solution = np.linalg.solve(A, b)
expected_aswers=[4.0, 4.270097886399373, -8.382908651112068, 0.260794703228136, 8.215263850540378, -4.622495002557022, -3.6694066584396534, 4.355700288551071, -0.5393594859501372, 0.19510866155667922, 0.046693314545347864, -4.239215687981718, 4.631117088009776, 3.5118819266702994, -8.633001352821319, 1.2993435355343206, 7.798322490681102, -5.268200108841968, -2.9851261381642176, 4.34257160194708]'''



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video