How to solve these non-linear equations?
    22 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
syms a b c
i1 = 310;
i2 = 349.64;
i3 = 353;
c1 = 11.1984;
n1 = 0.5067;
c2 = 15.9867;
n2 = 0.4271;
c3 = 8.6028;
n3 = 0.2449;
mpl = 308.5;
eqn1 = 48.62236629 - (a + b + c + mpl)/mpl == 0;
eqn2 = i1*(1 - n1 * c1* a^(n1-1))/(1-c1*a^(n1-1)) *(1-c1*a^(n1-1)*((a+b+c+mpl)/(c1*a^n1 + b+c+mpl))) - i2 * (1-n2*c2*b^(n2-1)*((b+c+mpl)/(c2*b^n2+c+mpl))) == 0;
eqn3 = i2*(1 - n2 * c2* b^(n2-1))/(1-c2*b^(n2-1)) *(1-c2*b^(n2-1)*((b+c+mpl)/(c2*b^n2+c+mpl))) - i3 * (1-n3*c3*c^(n3-1)*((c+mpl)/(c3*c^n3+mpl))) == 0;
system = [eqn1,eqn2,eqn3];
0 comentarios
Respuestas (3)
  Yash
      
 el 2 de Nov. de 2023
        
      Editada: Yash
      
 el 3 de Nov. de 2023
  
      Hi Samir,
To solve nonlinear equations in MATLAB, you can utilize the 'fsolve' function from the Optimization Toolbox. This function is specifically designed to find the roots of a system of nonlinear equations. By providing an initial guess, 'fsolve' attempts to converge to a solution that satisfies the equations.
The 'fsolve' function will attempt to find a solution for the system of equations starting from the initial guess provided. It will return the solution vector 'x' that satisfies the equations, or an error if it fails to converge.
To know more about the 'fsolve' function, refer to this documentation: https://in.mathworks.com/help/optim/ug/fsolve.html
Hope this helps!
2 comentarios
  John D'Errico
      
      
 el 2 de Nov. de 2023
				
      Editada: John D'Errico
      
      
 el 2 de Nov. de 2023
  
			Not completely correct. fsolve is not built in. It is part of the optimization toolbox, and only available if you have that toolbox. In my humble opinion, it is one of the most useful toolboxes I have, but not everyone will have it.
  Sam Chak
      
      
 el 2 de Nov. de 2023
        Hi @Samir Thapa
If you have the Optimization Toolbox installed, then you can use the 'fsolve' function to solve the system of nonlinear equations. However, some nonlinear systems can have multiple solutions, depending on the initial guess values that are chosen.
% Solution set #1
x0a       = 1*[1, 1, 1];
[x, fval] = fsolve(@nonlinfcn, x0a)
% Solution set #2
x0b       = 2*[1, 1, 1];
[x, fval] = fsolve(@nonlinfcn, x0b)
function F = nonlinfcn(x)
    i1   = 310;
    i2   = 349.64;
    i3   = 353;
    c1   = 11.1984;
    n1   = 0.5067;
    c2   = 15.9867;
    n2   = 0.4271;
    c3   = 8.6028;
    n3   = 0.2449;
    mpl  = 308.5;
    F(1) = 48.62236629 - (x(1) + x(2) + x(3) + mpl)/mpl;
    F(2) = i1*(1 - n1*c1*x(1)^(n1 - 1))/(1 - c1*x(1)^(n1 - 1))*(1 - c1*x(1)^(n1 - 1)*((x(1) + x(2) + x(3) + mpl)/(c1*x(1)^n1 + x(2) + x(3) + mpl))) - i2*(1 - n2*c2*x(2)^(n2 - 1)*((x(2) + x(3) + mpl)/(c2*x(2)^n2 + x(3) + mpl)));
    F(3) = i2*(1 - n2*c2*x(2)^(n2 - 1))/(1 - c2*x(2)^(n2 - 1))*(1 - c2*x(2)^(n2 - 1)*((x(2)        + x(3) + mpl)/(c2*x(2)^n2        + x(3) + mpl))) - i3*(1 - n3*c3*x(3)^(n3 - 1)*((x(3)        + mpl)/(c3*x(3)^n3        + mpl)));
end
2 comentarios
  Dyuman Joshi
      
      
 el 2 de Nov. de 2023
				However, some nonlinear systems can have multiple solutions, and the output from fsolve will depend on the initial guess values that are chosen.
  Walter Roberson
      
      
 el 2 de Nov. de 2023
        There might be additional solutions.
Q = @(v) sym(v);
syms a b positive
syms c real
i1 = Q(310);
i2 = Q(34964) / Q(10)^2;
i3 = Q(353);
c1 = Q(111984) / Q(10)^4;
n1 = Q(5067) / Q(10)^4;
c2 = Q(159867) / Q(10)^4;
n2 = Q(4271) / Q(10)^4;
c3 = Q(86028) / Q(10)^4;
n3 = Q(2449) / Q(10)^4;
mpl = Q(308.5);
eqn1 = Q(4862236629) / Q(10)^8 - (a + b + c + mpl)/mpl == 0;
eqn2 = i1*(1 - n1 * c1* a^(n1-1))/(1-c1*a^(n1-1)) *(1-c1*a^(n1-1)*((a+b+c+mpl)/(c1*a^n1 + b+c+mpl))) - i2 * (1-n2*c2*b^(n2-1)*((b+c+mpl)/(c2*b^n2+c+mpl))) == 0;
eqn3 = i2*(1 - n2 * c2* b^(n2-1))/(1-c2*b^(n2-1)) *(1-c2*b^(n2-1)*((b+c+mpl)/(c2*b^n2+c+mpl))) - i3 * (1-n3*c3*c^(n3-1)*((c+mpl)/(c3*c^n3+mpl))) == 0;
system = ([eqn1; eqn2; eqn3])
start1 = [0.0689    1.3999    0.0004].' * 1e-4;
start2 = [9000 5000 4];
start3 = [14000 32 2];
sol1 = vpasolve(system, [a b c], start1)
sol2 = vpasolve(system, [a b c], start2)
sol3 = vpasolve(system, [a b c], start3)
4 comentarios
  John D'Errico
      
      
 el 2 de Nov. de 2023
				Sorry, there is no hard rule that says you can positively stop looking at some point. Yes, a cubic polynomial has exactly 3 solutions. These are not cubics though. These equations are implicitly equivalent to a VERY high order polynomial. Those fractional powers make it so, if you could actually reduce the problem to a single equation in one unknown. You can't do so. And you can't even really know what order that impicit polynomial would be in such a case.
  Sam Chak
      
      
 el 3 de Nov. de 2023
				Thanks @Walter Roberson and @John D'Errico for the explanations. If you look at my code, you can already guess that my initial values were purely lucky guesses. I tried searching randomly, but complex-valued solutions were returned.
Ver también
Categorías
				Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
