Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fsolve won't solve non-linear system of equations

Subject: fsolve won't solve non-linear system of equations

From: Marcio Barbalho

Date: 16 Dec, 2011 23:10:10

Message: 1 of 2

Hi you all.

I've had a hard time understanding why matlab can't solve this problem using fsolve.

It's a system of non-linear equations.

These are the m-files:

function F = ORVP(k)
    F(1) = 0.6*k(3)/k(2)*44.44-k(1);
    F(2) = 1/( 0.6/(k(2)*44.44)+0.4/(k(4)*65.43))-k(3);
    F(3) = 1 - k(1)-k(5);
    F(4) = exp(1.107*k(5)^2)-k(2);
    F(5) = exp(1.107*k(1)^2)-k(4);
end

clc
k0 = [0.81; 1.03; 62.89; 2.09; 0.19];
options=optimset('Display','iter','MaxFunEvals',5d4,'MaxIter',1d4);
[x,fval] = fsolve(@ORVP,k0,options)

where k0, starting guess, is the solution already. It just won't get to the result. I've double-checked the equations, they are fine!

Any ideas?

Many thanks

Subject: fsolve won't solve non-linear system of equations

From: John D'Errico

Date: 17 Dec, 2011 00:03:07

Message: 2 of 2

"Marcio Barbalho" <marciobarbalho@live.com> wrote in message <jcgj4i$hd5$1@newscl01ah.mathworks.com>...
> Hi you all.
>
> I've had a hard time understanding why matlab can't solve this problem using fsolve.
>
> It's a system of non-linear equations.
>
> These are the m-files:
>
> function F = ORVP(k)
> F(1) = 0.6*k(3)/k(2)*44.44-k(1);
> F(2) = 1/( 0.6/(k(2)*44.44)+0.4/(k(4)*65.43))-k(3);
> F(3) = 1 - k(1)-k(5);
> F(4) = exp(1.107*k(5)^2)-k(2);
> F(5) = exp(1.107*k(1)^2)-k(4);
> end
>
> clc
> k0 = [0.81; 1.03; 62.89; 2.09; 0.19];
> options=optimset('Display','iter','MaxFunEvals',5d4,'MaxIter',1d4);
> [x,fval] = fsolve(@ORVP,k0,options)
>
> where k0, starting guess, is the solution already. It just won't get to the result. I've double-checked the equations, they are fine!
>
> Any ideas?
>
> Many thanks

Funny. If K0 is already the solution, then it should
return zeros for F, at least approximately.

>> k = [0.81; 1.03; 62.89; 2.09; 0.19];
>> F(1) = 0.6*k(3)/k(2)*44.44-k(1);
    F(2) = 1/( 0.6/(k(2)*44.44)+0.4/(k(4)*65.43))-k(3);
    F(3) = 1 - k(1)-k(5);
    F(4) = exp(1.107*k(5)^2)-k(2);
    F(5) = exp(1.107*k(1)^2)-k(4)
F =
          1627.24724271845 -0.519342857456024 -5.55111512312578e-17 0.0107719526745367 -0.0225774221160711

So I wonder why, if you have checked the equations,
and they are correct, AND this is a solution, then why
is F not zero?

Just one of those little mysteries we are faced with.

John

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us