help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Solving Complex Simultaneous Equations


From: c.
Subject: Re: Solving Complex Simultaneous Equations
Date: Wed, 19 Jun 2013 22:53:03 +0200

On 19 Jun 2013, at 21:24, JoshE87 <address@hidden> wrote:

> All values mentioned are scalars.  ui is known for each individual species
> "i".  
> 
> You're right Olaf,  I meant complicated.  I should have been more clear.  
> 
> I have tried to use fsolve in order to solve this.  As I understand it you
> have to write
> 
> [x (variable I want solved), fval (which is the value of the function), info
> (which will display if the values converged or not)]=fsolve( the function,
> initial guess)
> 
> in order to do fsolve.  Is this correct?  

no, you cannot solve separately for x if y and z are also unknown, you will have
to define a vector valued function of the vector unknown X = [x; y; z] and have 
fsolve solve the three equations simultaneously by requiring that

F(X) = 0

You should do something like:

u = [u1, u2, …];
fx = @(X) X(1)^2 - sum (5 * ((2 - X(2) * u) ./ (1 + X(1) * u)));
fy = @(X) X(2) -  sum (u ./ (1 + X(1) * u)) ./ X(3);
fz = @(X) X(3) - (1 + sum (u ./ (1 + x * u)));

X0 = [0, 0, 0]; % you may have to define a better initial guess for this to 
work properly

F = @(X) [fx(X); fy(X); fz(X)];

fsolve (F, X0);

To make this more efficient and robust you should also pass a Jacobian to 
fsolve.

In the above notice the use of "./" in place of "/", if you don't understand 
what that means, you probably need
to familiarize with the basics of the Octave/Matlab language before you can try 
to solve your actual problem.

I suggest you read the som basic tutorial like for example 
https://staff.ti.bfh.ch/sha1/Labs/PWF/Documentation/OctaveAtBFH.pdf
section 1.3.3 covers problems similar to yours, while element-wise operators 
like "./" are covered in section 1.1.3


HTH,
c.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]