ALINEARSYS

=ALINEARSYS(ec)

ec
1D vertical array containing the system equations in text format

solves any system of linear equations

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
832
Office Version
  1. 365
Platform
  1. Windows
ALINEARSYS solves any system of linear equations. Thought to put some of text manipulation formulas to work for a higher purpose. ?
calls : AFLATTEN , ASPLIT , ATRIM , AREPLACE , AREMOVE , T_CHARS
Excel Formula:
=LAMBDA(ec,
    LET(d,"|",r,ROWS(ec),ae,SWITCH(LEFT(ec,1),"+","","-","","+")&ec,es,ASPLIT(ae,"="),e,INDEX(es,,1),n,INDEX(es,,2),ea,ASPLIT(ATRIM(AREPLACE(e,{"+";"-"},{"|+";"|-"}),d,),d),c,COLUMNS(ea),
       f,AFLATTEN(ea),l,LEN(f),fr,AREMOVE(f,T_CHARS(,-1,),d),rf,SEARCH(d,fr),fs,IF(ISERR(rf),IF(l=0,fr,fr&d),fr),sf,SEARCH(d,fs),ce,MID(f,1,sf-1),
       cf,IFERROR(--SWITCH(ce,"-",-1,"+",1,ce),0),v,IFERROR(MID(f,sf,l-sf+1),""),uv,SORT(UNIQUE(FILTER(v,v<>""))),tv,TRANSPOSE(uv),
       q,QUOTIENT(SEQUENCE(r*c)-1,c)+1,x,XMATCH(v,tv),s,(q-1)*r+x,m,IFNA(XLOOKUP(SEQUENCE(r,r),s,cf),0),mi,MINVERSE(m),rs,MMULT(mi,n),
       cx,OR(AREMOVE(LOWER(ec),T_CHARS(1,-1,"+-.="),"")<>""),ca,r<>ROWS(uv),cb,AND(ISNUMBER(n)),cc,AND(ISERR(mi)),
       IFS(cx,"check syntax",ca,"check variables",NOT(cb),"only nrs after =",cc,"no solutions",TRUE,CHOOSE({1,2},uv&" =",rs))
    )
)
LAMBDA 7.0.xlsx
ABCDEFGHIJKLMNOPQRS
1sample=ALINEARSYS(A2:A12)=ALINEARSYS(H2:H5)=ALINEARSYS(M2:M5)
2x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11=100x1 =9.901271973-b-c+d=-4a =2.82352941x=2a =-3
3-2x3+4x6-2x11=12x10 =10.78741129b+c+a+d=10b =2.52941176-a=3b =1
44x2-3x11+2x9-4x5=6x11 =-34.00819959c-2d+2a-b=3c =3.05882353b=1c =-4
5-2x10+2x1+0.7x4+x8=12x2 =-15.81144776-2c+2d+3a-b=3d =1.58823529-c=4x =2
6x5-2x7+x2=9x3 =-19.90090621sum check10
7x5+2x3-x9+3x7-2x6=15x4 =-20.11349492
82x8-x10-2x1+x4=5x5 =55.44094879=ALINEARSYS(H9:H12)=ALINEARSYS(M9:M11)
91.5x7-2x2+3x4-1.2x6=23x6 =-23.95455292ax3-2ax2+ax1=10ax1 =84.94736842x11-x22+2x33=-3x11 =2
10x8-2x3+x10-x5=23x7 =15.31475052-ax4+.5ax2=-2ax2 =-17.789474x11+x22-x33=6x22 =1
11-x9+2x10+x1-2x11=5x8 =27.85172508.33ax3+.25ax1=3ax3 =-55.263158x11+2x22-4x33=16x33 =-3
12x3-x4+x10=11x9 =94.49249372ax1+ax3+ax4+ax2=5ax4 =-6.8947368
13sum check5
14=SUM(F2:F12)
15check100
16=ALINEARSYS(J17:J18)=ALINEARSYS(O17:O18)
17Syntax rules:No variables after "=" signa-2*b=3check syntaxa-2b=3a =7
18If ecuation starts with + or - use " ' " as first char. '-2x+….a+b=9a+b=9b =2
190.5 instead of 1/2(* char)
20
21=ALINEARSYS(B22:B24)=ALINEARSYS(F22:F24)=ALINEARSYS(J22:J23)=ALINEARSYS(M22:M23)
22Error debug.x+y-z=5no solutionsx+y-z=5no solutionsx+y=2xonly nrs after =x+y+z=3check variables
23y-5z=8y-5z=8x-y=1x-y=1
24y-5z=-12x+2y-2z=10(=2x)(3 variables,only 2 ec)
25(2nd and 3rd ec inconsistent)(1st and 3rd, same ecuation, infinite solutions)
26
ALINEARSYS post
Cell Formulas
RangeFormula
E1,O21,G21,K21,C21,P16,K16,F14,O8,J8,O1,J1E1=FORMULATEXT(E2)
E2:F12E2=ALINEARSYS(A2:A12)
J2:K5,J9:K12,O2:P5J2=ALINEARSYS(H2:H5)
K6,K13K6=SUM(K2:K5)
O9:P11O9=ALINEARSYS(M9:M11)
F15F15=SUM(F2:F12)
K17,K22,P17:Q18K17=ALINEARSYS(J17:J18)
C22,G22C22=ALINEARSYS(B22:B24)
O22O22=ALINEARSYS(M22:M23)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top