Solver for a system of nonlinear equations

Nov 2007
7
0
Solver for a system of nonlinear equations needed

Hi everyone,

I am trying to solve a nonlinear system of 12 equations for 12 unknowns.
(For the purpose of verifying, all the exact value of unknowns are available)

I have tried:

1. The function "solve" in Matlab.
2. The secant method for simultaneous nonlinear equations (by Philip Wolfe, 1959).

But both of them gave me wrong answer.

Could you please kindly help tell me

1. How can I find out whether the equations in the system are independent?
2. Are there any other functions or method which can be used to solve this system of nonlinear equations.

Thank you very much for your time.
 
Last edited:

CaptainBlack

MHF Hall of Fame
Nov 2005
14,972
5,271
someplace
Hi everyone,

I am trying to solve a nonlinear system of 12 equations for 12 unknowns.
(For the purpose of verifying, all the exact value of unknowns are available)

I have tried:

1. The function "solve" in Matlab.
2. The secant method for simultaneous nonlinear equations (by Philip Wolfe, 1959).

But both of them gave me wrong answer.

Could you please kindly help tell me

1. How can I find out whether the equations in the system are independent?
2. Are there any other functions or method which can be used to solve this system of nonlinear equations.

Thank you very much for your time.
Are you trying to solve these numericaly or symbolicaly?

Can you post your matlab code?

RonL
 
Nov 2007
7
0
Thank you very much for your response
I am trying to find numerical solution.
In Matlab:
+12 equations with 12 unknowns from x1 to x12 (dt=0.01 known)
f1 = x1*x11 + x2*x12 + x5*x9 + x6*x10;
f2 = x3*x11 + x4*x12 + x7*x9 + x8*x10;
f3 = x1*x11 + 0.0019*dt*x1 + x2*x12 + 0.8960*dt*x2 + x5*x9 + dt*x5*x11 + 0.001*dt^2*x5 + x6*x10 + dt*x6*x12 + 0.4480*dt^2*x6 + 0.3828;
f4 = x3*x11 + 0.0019*dt*x3 + x4*x12 + 0.8960*dt*x4 + x7*x9 + dt*x7*x11 + 0.001*dt^2*x7 + x8*x10 + dt*x8*x12 + 0.4480*dt^2*x8 - 0.3844;
f5 = x1*x11 + 0.0080*dt*x1 + x2*x12 + 1.8396*dt*x2 + x5*x9 + 2*dt*x5*x11 + 0.0059*dt^2*x5 + x6*x10 + 2*dt*x6*x12 + 1.8158*dt^2*x6 + 0.8342;
f6 = x3*x11 + 0.0080*dt*x3 + x4*x12 + 1.8396*dt*x4 + x7*x9 + 2*dt*x7*x11 + 0.0059*dt^2*x7 + x8*x10 + 2*dt*x8*x12 + 1.8158*dt^2*x8 - 0.8412;
f7 = x1*x11 + 0.0189*dt*x1 + x2*x12 + 2.8060*dt*x2 + x5*x9 + 3*dt*x5*x11 + 0.0193*dt^2*x5 + x6*x10 + 3*dt*x6*x12 + 4.1386*dt^2*x6 + 1.3449;
f8 = x3*x11 + 0.0189*dt*x3 + x4*x12 + 2.8060*dt*x4 + x7*x9 + 3*dt*x7*x11 + 0.0193*dt^2*x7 + x8*x10 + 3*dt*x8*x12 + 4.1386*dt^2*x8 - 1.3620;
f9 = x1*x11 + 0.0351*dt*x1 + x2*x12 + 3.7696*dt*x2 + x5*x9 + 4*dt*x5*x11 + 0.0463*dt^2*x5 + x6*x10 + 4*dt*x6*x12 + 7.4264*dt^2*x6 + 1.9038;
f10 = x3*x11 + 0.0351*dt*x3 + x4*x12 + 3.7696*dt*x4 + x7*x9 + 4*dt*x7*x11 + 0.0463*dt^2*x7 + x8*x10 + 4*dt*x8*x12 + 7.4264*dt^2*x8 - 1.9365;
f11 = x1*x11 + 0.0571*dt*x1 + x2*x12 + 4.7050*dt*x2 + x5*x9 + 5*dt*x5*x11 + 0.0924*dt^2*x5 + x6*x10 + 5*dt*x6*x12 + 11.6637*dt^2*x6 + 2.4984;
f12 = x3*x11 + 0.0571*dt*x3 + x4*x12 + 4.7050*dt*x4 + x7*x9 + 5*dt*x7*x11 + 0.0924*dt^2*x7 + x8*x10 + 5*dt*x8*x12 + 11.6637*dt^2*x8 - 2.5533;

when using "solve" function in Matlab, no code is needed
when using the Secant method, the code is as follows
dt=1e-2;
% initial values for variables
varc=[120,-40,-40,40]; vark=[1600,-600,-600,600]; var=[];
for i =1:25
[var]=[var;[awgn(varc,20,'measured')],[awgn(vark,20,'measured')],[ 0.01*randn(1,4)], [0.1*randn(1,12)]];
end
k=12;tol=1e-6; ndof=2; ns=1; B=zeros(1,24); B=[B,1]'; neq=ns*k; % (neq is the number of equations)
[A]=A2dofs(var,ndof,dt);
[A]=[A;ones(1,k+1)];
n=zeros(k+1,1); for ii=1:length(n) n(ii)=norm(A(1:neq,ii)); end
xx=var; e1=max(n); % save result for visualization purpose
for jj=1:500
p=A\B;
var_bar=p'*var;
pp=[A2dofs(var_bar,ndof,dt);1];
% Find the column which have maximal norm and replace:
[maxn,Imax]=max(n);
[minn,Imin]=min(n);
var(Imax,:)=var_bar;
A:),Imax)=pp;
n(Imax)=norm(pp(1:neq,1));
err1=norm(var_bar-var(Imin,:));
err2=n(Imax); [e1]=[e1,max(err1,err2)];
iter=jj;
[xx]=[xx;var_bar];
if (err1<tol) & (err2<tol)
break
end
end

Where A2dofs is simply the m-file to evaluate the value of the 12 functions at certain value of x1 to x12.
If possible, pls contact me directly through my email: g0500479@nus.edu.sg
Thank you very much.
 

CaptainBlack

MHF Hall of Fame
Nov 2005
14,972
5,271
someplace
Thank you very much for your response
I am trying to find numerical solution.
In Matlab:
+12 equations with 12 unknowns from x1 to x12 (dt=0.01 known)
f1 = x1*x11 + x2*x12 + x5*x9 + x6*x10;
f2 = x3*x11 + x4*x12 + x7*x9 + x8*x10;
f3 = x1*x11 + 0.0019*dt*x1 + x2*x12 + 0.8960*dt*x2 + x5*x9 + dt*x5*x11 + 0.001*dt^2*x5 + x6*x10 + dt*x6*x12 + 0.4480*dt^2*x6 + 0.3828;
f4 = x3*x11 + 0.0019*dt*x3 + x4*x12 + 0.8960*dt*x4 + x7*x9 + dt*x7*x11 + 0.001*dt^2*x7 + x8*x10 + dt*x8*x12 + 0.4480*dt^2*x8 - 0.3844;
f5 = x1*x11 + 0.0080*dt*x1 + x2*x12 + 1.8396*dt*x2 + x5*x9 + 2*dt*x5*x11 + 0.0059*dt^2*x5 + x6*x10 + 2*dt*x6*x12 + 1.8158*dt^2*x6 + 0.8342;
f6 = x3*x11 + 0.0080*dt*x3 + x4*x12 + 1.8396*dt*x4 + x7*x9 + 2*dt*x7*x11 + 0.0059*dt^2*x7 + x8*x10 + 2*dt*x8*x12 + 1.8158*dt^2*x8 - 0.8412;
f7 = x1*x11 + 0.0189*dt*x1 + x2*x12 + 2.8060*dt*x2 + x5*x9 + 3*dt*x5*x11 + 0.0193*dt^2*x5 + x6*x10 + 3*dt*x6*x12 + 4.1386*dt^2*x6 + 1.3449;
f8 = x3*x11 + 0.0189*dt*x3 + x4*x12 + 2.8060*dt*x4 + x7*x9 + 3*dt*x7*x11 + 0.0193*dt^2*x7 + x8*x10 + 3*dt*x8*x12 + 4.1386*dt^2*x8 - 1.3620;
f9 = x1*x11 + 0.0351*dt*x1 + x2*x12 + 3.7696*dt*x2 + x5*x9 + 4*dt*x5*x11 + 0.0463*dt^2*x5 + x6*x10 + 4*dt*x6*x12 + 7.4264*dt^2*x6 + 1.9038;
f10 = x3*x11 + 0.0351*dt*x3 + x4*x12 + 3.7696*dt*x4 + x7*x9 + 4*dt*x7*x11 + 0.0463*dt^2*x7 + x8*x10 + 4*dt*x8*x12 + 7.4264*dt^2*x8 - 1.9365;
f11 = x1*x11 + 0.0571*dt*x1 + x2*x12 + 4.7050*dt*x2 + x5*x9 + 5*dt*x5*x11 + 0.0924*dt^2*x5 + x6*x10 + 5*dt*x6*x12 + 11.6637*dt^2*x6 + 2.4984;
f12 = x3*x11 + 0.0571*dt*x3 + x4*x12 + 4.7050*dt*x4 + x7*x9 + 5*dt*x7*x11 + 0.0924*dt^2*x7 + x8*x10 + 5*dt*x8*x12 + 11.6637*dt^2*x8 - 2.5533;

when using "solve" function in Matlab, no code is needed
when using the Secant method, the code is as follows
dt=1e-2;
% initial values for variables
varc=[120,-40,-40,40]; vark=[1600,-600,-600,600]; var=[];
for i =1:25
[var]=[var;[awgn(varc,20,'measured')],[awgn(vark,20,'measured')],[ 0.01*randn(1,4)], [0.1*randn(1,12)]];
end
k=12;tol=1e-6; ndof=2; ns=1; B=zeros(1,24); B=[B,1]'; neq=ns*k; % (neq is the number of equations)
[A]=A2dofs(var,ndof,dt);
[A]=[A;ones(1,k+1)];
n=zeros(k+1,1); for ii=1:length(n) n(ii)=norm(A(1:neq,ii)); end
xx=var; e1=max(n); % save result for visualization purpose
for jj=1:500
p=A\B;
var_bar=p'*var;
pp=[A2dofs(var_bar,ndof,dt);1];
% Find the column which have maximal norm and replace:
[maxn,Imax]=max(n);
[minn,Imin]=min(n);
var(Imax,:)=var_bar;
A:),Imax)=pp;
n(Imax)=norm(pp(1:neq,1));
err1=norm(var_bar-var(Imin,:));
err2=n(Imax); [e1]=[e1,max(err1,err2)];
iter=jj;
[xx]=[xx;var_bar];
if (err1<tol) & (err2<tol)
break
end
end

Where A2dofs is simply the m-file to evaluate the value of the 12 functions at certain value of x1 to x12.
If possible, pls contact me directly through my email: g0500479@nus.edu.sg
Thank you very much.

Now the appearance of dt in these equations suggests that what we are
looking at is not simply a set of 12 non-linear simultaneous equations, but
something like a step of a numerical integration scheme. If so it might be
advantageous to step back and relook at the problem that gives rise to
these equations.

RonL
 
Similar Math Discussions Math Forum Date
Calculus
Calculators
Algebra
Calculus