# Solving a system of simultaneous equations with a large number of variables

I am trying to solve this system of equations for all variables. So far I have tried using the 'Solve' function, however that did not work. Recently, I have tried to create a list of equations and then use the FindRoot function, however I am unsure of how it works with such a large number of variables.

Any help would be greatly appreciated,

Thanks.

(*Define Parameters*)
Clear[ID7, ID9, ID3, ID4, VDS7, VDS9, VSGCM, VSD3, VSD4, VDS1, VDS2, \
VGS1, VGS2]

VDD = 10;
RB = 8200;
R9 = 12000;
kn = 0.722*10^-3;
kp = 0.289*10^-3;
Vtn = 0.75;
Vtp = 0.75;
\[Lambda] = 0.03;

(*Solve Iref and VGSCM*)

VGSCM = Vtn - 1/(RB*kn) + Sqrt[1 + 2*kn*RB*(VDD - Vtn)]/(RB*kn);
Iref = (VDD - VGSCM)/RB;

(*Bias Equations*)

EQ1 = (ID7 ==
Iref \[CenterDot] (1 + \[Lambda] VDS7)/(1 + \[Lambda] VGSCM));
EQ2 = (ID9 ==
Iref \[CenterDot] (1 + \[Lambda] VDS9)/(1 + \[Lambda] VGSCM));
EQ3 = (ID3 ==
ID9\[CenterDot](1 + \[Lambda] VSD3)/(1 + \[Lambda] VSGCM));
EQ4 = (ID4 ==
ID9 \[CenterDot](1 + \[Lambda] VSD4)/(1 + \[Lambda] VSGCM));
EQ5 = (ID9 == kp/2 (VSGCM - Vtp)^2 (1 + \[Lambda] VSGCM));
EQ6 = (ID4 == kn/2 (VGS2 - Vtn)^2 (1 + \[Lambda] VDS2));
EQ7 = (ID3 == kn/2 (VGS1 - Vtn)^2 (1 + \[Lambda] VDS1) );
EQ8 = (ID7 == 1/2 (ID3 + ID4));
EQ9 = (VSD3 + VDS1 + VDS7 == 2 VDD );
EQ10 = (VSD4 + VDS2 + VDS7 == 2 VDD);
EQ11 = (VSGCM + ID9\[CenterDot]R9 + VDS9 == 2 VDD);
EQ12 = (VSD3 + VDS1 - VGS1 == VDD);
EQ13 = (VSD4 + VDS2 - VGS2 == VDD);

(*Create an equation list and solve*)

EQLIST = {EQ1, EQ2, EQ3, EQ4, EQ5, EQ6, EQ7, EQ8, EQ9, EQ10, EQ11,
EQ12, EQ13};
SOLN = FindRoot[{EQLIST}, {ID7, Iref}, {ID9, Iref}, {ID3, Iref}, {ID4,
Iref}, {VSGCM, VDD}, {VGS2, VDD}, {VGS1, VDD}, {VDS9,
VDD}, {VDS7, VDD}, {VSD3, VDD}, {VDS2, VDD}, {VSD4, VDD}];
ID7 = ID7 /. SOLN

• Please post code that can be copied by others (use Copy As > Input Text); posting code as pictures makes it less likely for people to help you. Commented Oct 18, 2018 at 13:21
• Ok, I have done that. Thanks for the heads up.
– Mush
Commented Oct 18, 2018 at 13:35
• Solve[] can only be used with exact parameter values. Commented Oct 18, 2018 at 14:49
• If we correct all the errors associated with the misuse of \[CenterDot], reduce the system to the first 4 equations by substitution, then the remaining system of 8 equations has an empty set of roots. Commented Oct 18, 2018 at 15:21
• But a system of 9 equations has a numerical solution. Commented Oct 18, 2018 at 16:46

If we correct all the errors associated with the misuse of \[CenterDot], reduce the system to the first 4 equations by substitution, then the remaining system of 9 equations has numerical solution.

(*Define Parameters*)Clear[ID7, ID9, ID3, ID4, VDS7, VDS9, \
VSGCM, VSD3, VSD4, VDS1, VDS2, VGS1, VGS2]

VDD = 10;
RB = 8200;
R9 = 12000;
kn = 722*10^-5;
kp = 289*10^-5;
Vtn = 75/100;
Vtp = 75/100;
\[Lambda] = 3/100;

(*Solve Iref and VGSCM*)

VGSCM = Vtn - 1/(RB*kn) + Sqrt[1 + 2*kn*RB*(VDD - Vtn)]/(RB*kn);
Iref = (VDD - VGSCM)/RB;

(*Bias Equations*)

ID7 = Iref*(1 + \[Lambda] VDS7)/(1 + \[Lambda] VGSCM);
ID9 = Iref*(1 + \[Lambda] VDS9)/(1 + \[Lambda] VGSCM);
ID3 = ID9*(1 + \[Lambda] VSD3)/(1 + \[Lambda] VSGCM);
ID4 = ID9*(1 + \[Lambda] VSD4)/(1 + \[Lambda] VSGCM);
EQ5 = (ID9 == kp/2 (VSGCM - Vtp)^2 (1 + \[Lambda] VSGCM));
EQ6 = (ID4 == kn/2 (VGS2 - Vtn)^2 (1 + \[Lambda] VDS2));
EQ7 = (ID3 == kn/2 (VGS1 - Vtn)^2 (1 + \[Lambda] VDS1));
EQ8 = (ID7 == 1/2 (ID3 + ID4));
EQ9 = (VSD3 + VDS1 + VDS7 == 2 VDD);
EQ10 = (VSD4 + VDS2 + VDS7 == 2 VDD);
EQ11 = (VSGCM + ID9*R9 + VDS9 == 2 VDD);
EQ12 = (VSD3 + VDS1 - VGS1 == VDD);
EQ13 = (VSD4 + VDS2 - VGS2 == VDD);

(*Create an equation list and solve*)

EQLIST = EQ5 && EQ6 && EQ7 && EQ8 && EQ9 && EQ10 && EQ11 && EQ12 &&
EQ13 // Simplify

Out[]= -(((-548637 + 20 Sqrt[2740685]) (100 + 3 VDS9))/(
8200 (6050609 + 60 Sqrt[2740685]))) == (
289 (1 + (3 VSGCM)/100) (-(3/4) + VSGCM)^2)/
200000 && -(((-548637 + 20 Sqrt[2740685]) (100 + 3 VDS9) (100 +
3 VSD4))/(
8200 (6050609 + 60 Sqrt[2740685]) (100 + 3 VSGCM))) == (
361 (1 + (3 VDS2)/100) (-(3/4) + VGS2)^2)/
100000 && -(((-548637 + 20 Sqrt[2740685]) (100 + 3 VDS9) (100 +
3 VSD3))/(
8200 (6050609 + 60 Sqrt[2740685]) (100 + 3 VSGCM))) == (
361 (1 + (3 VDS1)/100) (-(3/4) + VGS1)^2)/
100000 && (-VDS9 (200 + 3 VSD3 + 3 VSD4) -
100 (VSD3 + VSD4 - 2 VSGCM) + VDS7 (200 + 6 VSGCM))/(
100 + 3 VSGCM) == 0 && VDS1 + VDS7 + VSD3 == 20 &&
VDS2 + VDS7 + VSD4 == 20 &&
VDS9 - (60 (-548637 + 20 Sqrt[2740685]) (100 + 3 VDS9))/(
41 (6050609 + 60 Sqrt[2740685])) + VSGCM == 20 &&
VDS1 + VSD3 == 10 + VGS1 && VDS2 + VSD4 == 10 + VGS2

soln=NSolve[EQLIST, {VDS7, VDS9, VSGCM, VSD3, VSD4, VDS1, VDS2,
VGS1, VGS2}]

Out[]= {{VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 9.25066 + 21.5394 I, VSD3 -> 4.2358*10^12 + 1.43999*10^12 I,
VSD4 -> -4.2358*10^12 - 1.43999*10^12 I,
VDS1 -> -4.2358*10^12 - 1.43999*10^12 I,
VDS2 -> 4.2358*10^12 + 1.43999*10^12 I, VGS1 -> 0.75 - 21.5392 I,
VGS2 -> 0.75 - 21.5392 I}, {VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 9.25 + 21.5392 I, VSD3 -> 4.87178*10^9 + 7.86419*10^9 I,
VSD4 -> -4.87178*10^9 - 7.86419*10^9 I,
VDS1 -> -4.87178*10^9 - 7.86419*10^9 I,
VDS2 -> 4.87178*10^9 + 7.86419*10^9 I, VGS1 -> 0.75 - 21.5392 I,
VGS2 -> 0.75 - 21.5392 I}, {VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 9.25 - 21.5392 I, VSD3 -> -1.32681*10^9 + 2.6144*10^9 I,
VSD4 -> 1.32681*10^9 - 2.6144*10^9 I,
VDS1 -> 1.32681*10^9 - 2.6144*10^9 I,
VDS2 -> -1.32681*10^9 + 2.6144*10^9 I, VGS1 -> 0.75 + 21.5392 I,
VGS2 -> 0.75 + 21.5392 I}, {VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 9.25 - 21.5392 I, VSD3 -> 3.6096*10^8 - 2.84899*10^9 I,
VSD4 -> -3.6096*10^8 + 2.84899*10^9 I,
VDS1 -> -3.6096*10^8 + 2.84899*10^9 I,
VDS2 -> 3.6096*10^8 - 2.84899*10^9 I, VGS1 -> 0.75 + 21.5392 I,
VGS2 -> 0.75 + 21.5392 I}, {VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 86.5878, VSD3 -> -33.2601, VSD4 -> -33.2601,
VDS1 -> -33.3277, VDS2 -> -33.3277, VGS1 -> -76.5878,
VGS2 -> -76.5878}, {VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 8.85808, VSD3 -> -33.3076, VSD4 -> -33.3076,
VDS1 -> 44.4495, VDS2 -> 44.4495, VGS1 -> 1.14192,
VGS2 -> 1.14192}, {VDS9 -> 29.9904, VSGCM -> -33.2947,
VDS7 -> 9.6476, VSD3 -> -33.3071, VSD4 -> -33.3071, VDS1 -> 43.6595,
VDS2 -> 43.6595, VGS1 -> 0.352404,
VGS2 -> 0.352404}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 9.25 - 0.577801 I, VSD3 -> -1.17287*10^10 + 4.35828*10^10 I,
VSD4 -> 1.17287*10^10 - 4.35828*10^10 I,
VDS1 -> 1.17287*10^10 - 4.35828*10^10 I,
VDS2 -> -1.17287*10^10 + 4.35828*10^10 I, VGS1 -> 0.75 + 0.577795 I,
VGS2 -> 0.75 + 0.577795 I}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 9.25 - 0.577772 I, VSD3 -> 2.20421*10^10 - 3.61094*10^10 I,
VSD4 -> -2.20421*10^10 + 3.61094*10^10 I,
VDS1 -> -2.20421*10^10 + 3.61094*10^10 I,
VDS2 -> 2.20421*10^10 - 3.61094*10^10 I, VGS1 -> 0.75 + 0.577795 I,
VGS2 -> 0.75 + 0.577795 I}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 9.25 + 0.577795 I, VSD3 -> -5.34492*10^8 + 6.82361*10^8 I,
VSD4 -> 5.34492*10^8 - 6.82361*10^8 I,
VDS1 -> 5.34492*10^8 - 6.82361*10^8 I,
VDS2 -> -5.34492*10^8 + 6.82361*10^8 I, VGS1 -> 0.75 - 0.577795 I,
VGS2 -> 0.75 - 0.577795 I}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 9.25 + 0.577795 I, VSD3 -> 3.72285*10^8 - 5.04828*10^8 I,
VSD4 -> -3.72285*10^8 + 5.04828*10^8 I,
VDS1 -> -3.72285*10^8 + 5.04828*10^8 I,
VDS2 -> 3.72285*10^8 - 5.04828*10^8 I, VGS1 -> 0.75 - 0.577795 I,
VGS2 -> 0.75 - 0.577795 I}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 9.25 - 0.577795 I, VSD3 -> 3.73395*10^8 - 5.00453*10^8 I,
VSD4 -> -3.73395*10^8 + 5.00453*10^8 I,
VDS1 -> -3.73395*10^8 + 5.00453*10^8 I,
VDS2 -> 3.73395*10^8 - 5.00453*10^8 I, VGS1 -> 0.75 + 0.577795 I,
VGS2 -> 0.75 + 0.577795 I}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 31.5738, VSD3 -> 21.7227, VSD4 -> 21.7227, VDS1 -> -33.2965,
VDS2 -> -33.2965, VGS1 -> -21.5738,
VGS2 -> -21.5738}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 31.5738, VSD3 -> 21.7227, VSD4 -> 21.7227, VDS1 -> -33.2965,
VDS2 -> -33.2965, VGS1 -> -21.5738,
VGS2 -> -21.5738}, {VDS9 -> 5.77184, VSGCM -> -0.163258,
VDS7 -> 8.71927, VSD3 -> 2.33683, VSD4 -> 2.33683, VDS1 -> 8.9439,
VDS2 -> 8.9439, VGS1 -> 1.28073, VGS2 -> 1.28073}, {VDS9 -> 5.77184,
VSGCM -> -0.163258, VDS7 -> 9.80068, VSD3 -> 3.25412,
VSD4 -> 3.25412, VDS1 -> 6.9452, VDS2 -> 6.9452, VGS1 -> 0.199315,
VGS2 -> 0.199315}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.25 - 0.553344 I, VSD3 -> 2.92043*10^9 - 3.12811*10^10 I,
VSD4 -> -2.92043*10^9 + 3.12811*10^10 I,
VDS1 -> -2.92043*10^9 + 3.12811*10^10 I,
VDS2 -> 2.92043*10^9 - 3.12811*10^10 I, VGS1 -> 0.75 + 0.553341 I,
VGS2 -> 0.75 + 0.553341 I}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.25 - 0.553344 I, VSD3 -> 4.94566*10^9 + 1.76156*10^10 I,
VSD4 -> -4.94566*10^9 - 1.76156*10^10 I,
VDS1 -> -4.94566*10^9 - 1.76156*10^10 I,
VDS2 -> 4.94566*10^9 + 1.76156*10^10 I, VGS1 -> 0.75 + 0.553341 I,
VGS2 -> 0.75 + 0.553341 I}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.25 - 0.553341 I, VSD3 -> 2.77928*10^7 + 1.01051*10^8 I,
VSD4 -> -2.77928*10^7 - 1.01051*10^8 I,
VDS1 -> -2.77928*10^7 - 1.01051*10^8 I,
VDS2 -> 2.77928*10^7 + 1.01051*10^8 I, VGS1 -> 0.75 + 0.553341 I,
VGS2 -> 0.75 + 0.553341 I}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.25 - 0.553341 I, VSD3 -> -2.64586*10^7 + 4.41099*10^7 I,
VSD4 -> 2.64586*10^7 - 4.41099*10^7 I,
VDS1 -> 2.64586*10^7 - 4.41099*10^7 I,
VDS2 -> -2.64586*10^7 + 4.41099*10^7 I, VGS1 -> 0.75 + 0.553341 I,
VGS2 -> 0.75 + 0.553341 I}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.25 + 0.553344 I, VSD3 -> -2.09644*10^7 - 4.97956*10^6 I,
VSD4 -> 2.09644*10^7 + 4.97957*10^6 I,
VDS1 -> 2.09644*10^7 + 4.97956*10^6 I,
VDS2 -> -2.09644*10^7 - 4.97957*10^6 I, VGS1 -> 0.75 - 0.55334 I,
VGS2 -> 0.75 - 0.553342 I}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.25 + 0.553341 I, VSD3 -> -9.76015*10^6 - 388984. I,
VSD4 -> 9.76016*10^6 + 388985. I, VDS1 -> 9.76016*10^6 + 388984. I,
VDS2 -> -9.76015*10^6 - 388986. I, VGS1 -> 0.75 - 0.553339 I,
VGS2 -> 0.75 - 0.553343 I}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 28.9855, VSD3 -> 24.3026, VSD4 -> 24.3026, VDS1 -> -33.288,
VDS2 -> -33.288, VGS1 -> -18.9855,
VGS2 -> -18.9855}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 8.69823, VSD3 -> 5.53979, VSD4 -> 5.53979, VDS1 -> 5.76198,
VDS2 -> 5.76198, VGS1 -> 1.30177,
VGS2 -> 1.30177}, {VDS9 -> 4.46494, VSGCM -> 1.62461,
VDS7 -> 9.82531, VSD3 -> 6.58217, VSD4 -> 6.58217, VDS1 -> 3.59253,
VDS2 -> 3.59253, VGS1 -> 0.174695, VGS2 -> 0.174695}}

ID7 /. soln

Out[]= {0.00130597 + 0.000660573 I, 0.00130595 + 0.000660568 I,
0.00130595 - 0.000660568 I,
0.00130595 - 0.000660568 I, 0.00367776, 0.00129393, 0.00131815,
0.00130595 - 0.0000177201 I, 0.00130595 - 0.0000177192 I,
0.00130595 + 0.0000177199 I, 0.00130595 + 0.0000177199 I,
0.00130595 -
0.0000177199 I, 0.00199058, 0.00199058, 0.00128968, 0.00132284,
0.00130595 - 0.0000169701 I, 0.00130595 - 0.00001697 I,
0.00130595 - 0.00001697 I, 0.00130595 - 0.0000169699 I,
0.00130595 + 0.0000169701 I,
0.00130595 + 0.00001697 I, 0.0019112, 0.00128903, 0.0013236}


Real part

Re[ID7 /. soln]

Out[]= {0.00130597, 0.00130595, 0.00130595, 0.00130595, 0.00367776, \
0.00129393, 0.00131815, 0.00130595, 0.00130595, 0.00130595, \
0.00130595, 0.00130595, 0.00199058, 0.00199058, 0.00128968, \
0.00132284, 0.00130595, 0.00130595, 0.00130595, 0.00130595, \
0.00130595, 0.00130595, 0.0019112, 0.00128903, 0.0013236}

• Hi Alex, firstly thanks for helping out, much appreciated - I have corrected all the centerdot errors. I need to solve for all 13 variables, and I am only interested in finding out the real, non-imaginary solution to each variable.
– Mush
Commented Oct 18, 2018 at 17:08
• The first four equations are simply function definitions. They can be used to find the desired values by substitution, for example,  ID7 /. soln Out[30]= {0.00130597 + 0.000660573 I, 0.00130595 + 0.000660568 I, ... Commented Oct 18, 2018 at 17:50
• Real part Re[ID7 /. soln] Out[]= {0.00130597, 0.00130595, 0.00130595, 0.00130595, 0.00367776, \ 0.00129393, 0.00131815, 0.00130595, 0.00130595, 0.00130595, \ 0.00130595, 0.00130595, 0.00199058, 0.00199058, 0.00128968, \ 0.00132284, 0.00130595, 0.00130595, 0.00130595, 0.00130595, \ 0.00130595, 0.00130595, 0.0019112, 0.00128903, 0.0013236} Commented Oct 18, 2018 at 18:12

Is this what you are looking for?

(*all of your initialization and then*)
NMinimize[
Abs[ID9 - kp/2 (VSGCM - Vtp)^2 (1 + λ VSGCM)] +
Abs[ID4 - kn/2 (VGS2 - Vtn)^2 (1 + λ VDS2)] +
Abs[ID3 - kn/2 (VGS1 - Vtn)^2 (1 + λ VDS1)] +
Abs[ID7 - 1/2 (ID3 + ID4)] +
Abs[VSD3 + VDS1 + VDS7 - 2 VDD] +
Abs[VSD4 + VDS2 + VDS7 - 2 VDD] +
Abs[VSGCM + ID9*R9 + VDS9 - 2 VDD] +
Abs[VSD3 + VDS1 - VGS1 - VDD] +
Abs[VSD4 + VDS2 - VGS2 - VDD] /.
{ID7 -> Iref*(1 + λ VDS7)/(1 + λ VGSCM),
ID9 -> Iref*(1 + λ VDS9)/(1 + λ VGSCM),
ID3 -> ID9*(1 + λ VSD3)/(1 + λ VSGCM),
ID4 -> ID9*(1 + λ VSD4)/(1 + λ VSGCM)},
{ID3, ID4, ID7, ID9, VDS1, VDS2, VDS7, VDS9, VGS1, VGS2, VSD3, VSD4, VSGCM}]


which gives you in a second

{0.00372554, {
ID3 -> -5.20117, ID4 -> 2.26818, ID7 -> 7.07231, ID9 -> 0.000829577,
VDS1 -> 12.2934, VDS2 -> 3.23561, VDS7 -> 10.598, VDS9 -> 11.2391,
VGS1 -> -0.59801, VGS2 -> -0.598011, VSD3 -> -2.89137, VSD4 -> 6.16638,
VSGCM -> -5.20789}}


And if you substitute your four "definitions" plus that result into your original equations then

{ID9 - kp/2 (VSGCM - Vtp)^2 (1 + λ VSGCM),
ID4 - kn/2 (VGS2 - Vtn)^2 (1 + λ VDS2),
ID3 - kn/2 (VGS1 - Vtn)^2 (1 + λ VDS1),
ID7 - 1/2 (ID3 + ID4), VSD3 + VDS1 + VDS7 - 2 VDD,
VSD4 + VDS2 + VDS7 - 2 VDD, VSGCM + ID9*R9 + VDS9 - 2 VDD,
VSD3 + VDS1 - VGS1 - VDD, VSD4 + VDS2 - VGS2 - VDD} //.
{ID7 -> Iref*(1 + λ VDS7)/(1 + λ VGSCM),
ID9 -> Iref*(1 + λ VDS9)/(1 + λ VGSCM),
ID3 -> ID9*(1 + λ VSD3)/(1 + λ VSGCM),
ID4 -> ID9*(1 + λ VSD4)/(1 + λ VSGCM),
ID3 -> -5.20117, ID4 -> 2.26818, ID7 -> 7.07231, ID9 -> 0.000829577,
VDS1 -> 12.2934, VDS2 -> 3.23561, VDS7 -> 10.598, VDS9 -> 11.2391,
VGS1 -> -0.59801, VGS2 -> -0.598011, VSD3 -> -2.89137, VSD4 -> 6.16638,
VSGCM -> -5.20789}


gives you

{-0.0031638, 0.000915162, 0.000362026, -0.000300062, 0.00003,
-0.00001, -0.0000489611, 0.00004, 1.*10^-6}