Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!news.glorb.com!news2.glorb.com!news.glorb.com!tr22g12.aset.psu.edu!news.mathforum.org!not-for-mail
From: Torsten Hennig <Torsten.Hennig@umsicht.fhg.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Pls Help me to solve
Date: Sat, 07 Nov 2009 06:51:04 EST
Organization: The Math Forum
Lines: 63
Message-ID: <2126357853.29693.1257594694977.JavaMail.root@gallium.mathforum.org>
References: <hd1lmg$9g5$1@fred.mathworks.com>
NNTP-Posting-Host: gallium.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1257594694 16486 144.118.94.39 (7 Nov 2009 11:51:34 GMT)
X-Complaints-To: news@news.mathforum.org
NNTP-Posting-Date: Sat, 7 Nov 2009 11:51:34 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:583206


> Dear Readers
> I m facing problem in solving set of nonliner
> equations. Set contains 13 nonlinear equations and 13
> variables. I've spent lots of time but unfortunately
> couldn't solve it....
> I've tried so far solve and fsolve commands.......
> When I am using solve my computer gets hanged. And
> fsolve is returning complex number which is
> practically not possible......
> 
> I've made two files
> 
> 1st File:function file
> 
> function F=myfun(x)
> F=[-22.47+log(x(1)/(x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)
> +x(8)+x(9)+x(10)))+(3*x(11))+(3*x(12))+(8*x(13));-24.8
> 9+log(x(2)/((x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x
> (9)+x(10))))+x(12)+(2*x(13));-49.539+log(x(3)/((x(1)+x
> (2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10))))+x(11)+
> (2*x(12));-0.0574+log(x(4)/((x(1)+x(2)+x(3)+x(4)+x(5)+
> x(6)+x(7)+x(8)+x(9)+x(10))))+(2*x(13));-24.597+log(x(5
> )/((x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10)
> )))+x(11)+x(12);-0.7027+log(x(6)/((x(1)+x(2)+x(3)+x(4)
> +x(5)+x(6)+x(7)+x(8)+x(9)+x(10))))+x(11)+(4*x(13));-32
> .59+log(x(7)/((x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)
> +x(9)+x(10))))+(2*x(11))+(2*x(12))+(4*x(13));-10.927+l
> og(x(8)/((x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)
> +x(10))))+x(11)+x(12)+(4*x(13));-4.635+log(x(9)/((x(1)
> +x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10))))+(2*x
> (11))+(x(12))+(6*x(13));-7.5188+log(x(10)/((x(1)+x(2)+
> x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x 
> (10))))+(2*x(11))+(x(12))+(4*x(13));3*x(1)+x(3)+x(5)+x
> (6)+2*x(7)+x(8)+2*x(9)+2*x(10)-0.1002;3*x(1)+x(2)+2*x(
> 3)+x(5)+2*x(7)+x(8)+x(9)+x(10)-1.6332;8*x(1)+2*x(2)+2*
> x(4)+4*x(6)+4*x(7)+4*x(8)+6*x(9)+4*x(10)-3.3332] 
> 
> 
> 2nd file: calls the function
> 
> clc
> clear all
> x0=[2;13;13;13;13;13;13;13;13;13;1;1;1]  %initial
> guess
> options=optimset('Display','iter');   % Option to
> display output
> [x,fval] = fsolve(@myfun,x0,options)  % Call
> optimizer
> 
> It would be great help if u can give me some guidance
> to solve it.....
> 
> 
> Thank You

In order to avoid complex number solutions, you should
be careful that you do not take the log of a negative
number during iteration. Restrict your solution variables
to be positive or solve in the squares of your solution 
variables.

Best wishes
Torsten.