How to solve for multiple variables using multiple equations?
Mostrar comentarios más antiguos
I am trying to find the positive values for N1 N2 N3 N4 N5 N6 using the following equations. Running solver gives values for all as 0 by 1. I was suggested to use Newton's iteration but I have no Idea how to do that as I am new to the software.
syms N1 N2 N3 N4 N5 N6;
N7 = 3.135E+00*N1*N2;
N8 = 4.100E-01*N2*N6;
N9 = 1.381E+01*N1*N4;
N10 = 7.610E+01*N2^2*N3;
N11 = 1.720E+05*N2*N3^2*N5^3;
N12 = 4.034E+04*N3*N5^2;
N13 = 2.615E+04*N2*N3^2*N5^2;
N14 = 3.826E+44*N1*N3*N5^2;
N15 = 1.458E+03*N2*N3*N5;
N16 = 2.435E+04*N1*N3^2*N5;
N17 = 1.186E+08*N3^2*N5^3;
N18 = 7.511E+02*N3*N5;
N19 = 6.874E+02*N3*N5;
eqn1 = N1+N2+N3+N4+N5+N6+N7+N8+N9+N10+N11+N12+N13+N14+N15+N16+N17+N18+N19 == 1;
eqn2 = 0.1962*(N2+N7+N8+2*N10+N11+N13+N15)-0.6575*(N1+N7+N9+N14+N16) == 0;
eqn3 = 0.0557*(N3+N10+2*N11+N12+2*N13+N14+N15+2*N16+2*N17+N18+N19)-0.4698*(N4+N9) == 0;
eqn4 = 0.0099*(N5+3*N11+2*N12+2*N13+2*N14+N15+N16+3*N17+N18+N19)-0.3525*(N6+N8) == 0;
eqn5 = 0.0557*(N1+N7+N9+N14+N16)-0.1962*(N4+N9) == 0;
eqn6 = 0.0099*(N2+N7+N8+2*N10+N11+N13+N15)-0.6575*(N6+N8) == 0;
eqns = [eqn1 eqn2 eqn3 eqn4 eqn5 eqn6];
S = solve(eqns,[N1 N2 N3 N4 N5 N6]);
4 comentarios
Stephan
el 18 de Ag. de 2020
Is N14 correct with 3.826E+44*N1*N3*N5^2 ? This is much greater then all the other constant factors
if "N14 = 3.826E+44*N1*N3*N5^2 then:
n1: 0.0102966513751017
n2: 0.239882301702705
n3: 0.0756391318035683
n4: 0.0675904371464799
n5: 9.05432958842336E-22
n6: 0.0124929422701635
Feval:
-2.66453525910038E-15
5.39845945723982E-14
-1.38083988687754E-14
1.96308160699266E-12
2.21940521516473E-14
-1.04990321991849E-12
While if "N14 = 3.826E+04*N1*N3*N5^2;", the results will be:
n1: 0.08914189187665
n2: 0.276778705046795
n3: 0.0249154871811356
n4: 0.0266564101251453
n5: 0.00558667307837047
n6: 0.00949311488376945
Feval:
6.66133814775094E-16
1.66533453693773E-16
2.08166817117217E-17
-1.30104260698261E-18
5.20417042793042E-18
7.80625564189563E-18
TAHMEED TASNIM
el 24 de Ag. de 2020
Alex Sha
el 25 de Ag. de 2020
Hi, the results obtained above are from another math software named 1stOpt, the code looks like below. Matlab should be able to solve this problem, however, it is more possible that some difficulties will be encountered, for example, guess of initial start values. In 1stOpt, guess of start values are no longer needed anymore.
ParameterDomain = [0,];
ConstStr
N7 = 3.135E+00*N1*N2,
N8 = 4.100E-01*N2*N6,
N9 = 1.381E+01*N1*N4,
N10 = 7.610E+01*N2^2*N3,
N11 = 1.720E+05*N2*N3^2*N5^3,
N12 = 4.034E+04*N3*N5^2,
N13 = 2.615E+04*N2*N3^2*N5^2,
N14 = 3.826E+44*N1*N3*N5^2, //N14 = 3.826E+04*N1*N3*N5^2,
N15 = 1.458E+03*N2*N3*N5,
N16 = 2.435E+04*N1*N3^2*N5,
N17 = 1.186E+08*N3^2*N5^3,
N18 = 7.511E+02*N3*N5,
N19 = 6.874E+02*N3*N5;
Function
N1+N2+N3+N4+N5+N6+N7+N8+N9+N10+N11+N12+N13+N14+N15+N16+N17+N18+N19 = 1;
0.1962*(N2+N7+N8+2*N10+N11+N13+N15)-0.6575*(N1+N7+N9+N14+N16) = 0;
0.0557*(N3+N10+2*N11+N12+2*N13+N14+N15+2*N16+2*N17+N18+N19)-0.4698*(N4+N9) = 0;
0.0099*(N5+3*N11+2*N12+2*N13+2*N14+N15+N16+3*N17+N18+N19)-0.3525*(N6+N8) = 0;
0.0557*(N1+N7+N9+N14+N16)-0.1962*(N4+N9) = 0;
0.0099*(N2+N7+N8+2*N10+N11+N13+N15)-0.6575*(N6+N8) = 0;
Results:
n1: 0.010296651426512
n2: 0.23988230158704
n3: 0.0756391318899229
n4: 0.0675904371072629
n5: 9.05432955846619E-22
n6: 0.0124929422697438
feval:
2.22044604925031E-16
1.0547118733939E-15
2.77555756156289E-17
2.34187669256869E-17
-6.24500451351651E-17
6.24500451351651E-17
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre C Matrix API en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!