Got Questions? Get Answers.
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:
Nonlinear system of equations

Subject: Nonlinear system of equations

From: Milos Milenkovic

Date: 26 Feb, 2011 10:04:43

Message: 1 of 7

Dear all,
I have the following system of nonlinear equations

(a*c*h-a*b*c)/b^2+n/2=0

(a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0

variables are h and b, other are constants.

There is a way to solve it in MATLAB?

Best,
Milos

Subject: Nonlinear system of equations

From: Torsten

Date: 26 Feb, 2011 13:28:51

Message: 2 of 7

On 26 Feb., 11:04, "Milos Milenkovic" <m.milenko...@mathworks.com>
wrote:
> Dear all,
> I have the following system of nonlinear equations
>
> (a*c*h-a*b*c)/b^2+n/2=0
>
> (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0
>
> variables are h and b, other are constants.
>
> There is a way to solve it in MATLAB?
>
> Best,
> Milos

help fsolve

Best wishes
Torsten.

Subject: Nonlinear system of equations

From: Miroslav Balda

Date: 26 Feb, 2011 14:52:04

Message: 3 of 7

"Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message <ikaj7r$5u9$1@fred.mathworks.com>...
> Dear all,
> I have the following system of nonlinear equations
>
> (a*c*h-a*b*c)/b^2+n/2=0
>
> (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0
>
> variables are h and b, other are constants.
>
> There is a way to solve it in MATLAB?
>
> Best,
> Milos

Hi Milos,
Your system of equations has the effective form
p*h - p*b + q*b^2 = 0
r - p*b*h + p*h^2 + s*b - q*b^3 = 0,
where p, q, r, s are constants composed of the original ones a, c, m, n.
If you create the function
res = @(x) [(x(2)-x(1))*p + x(1)^2*q
                 (x(1)-x(2))*x(2)*p + x(1)*s -x(1)^3*q];
you may solve your problem by any o nonlinear solvers. I would use my function LMFnlsq from FEX. You will find it at
      www.mathworks.com/matlabcentral/fileexchange/17534
The calling sequence could be
     a = [b0; h0] % your estimates of unknowns b and h respectively.
     [x,ssq,cnt] = LMFnlsq(res,ones(2,1), 'Display',-5); % find solution
     x = x.*a; % rescaling the solution from normalized form to real size
If your estimates were not far from the solution, you get b=x(1) and h=x(2).
I hope that I have not introduce any error, and that it helps.

Mira

Subject: Nonlinear system of equations

From: Milos Milenkovic

Date: 26 Feb, 2011 18:46:05

Message: 4 of 7

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ikb42k$dg0$1@fred.mathworks.com>...
> "Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message <ikaj7r$5u9$1@fred.mathworks.com>...
> > Dear all,
> > I have the following system of nonlinear equations
> >
> > (a*c*h-a*b*c)/b^2+n/2=0
> >
> > (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0
> >
> > variables are h and b, other are constants.
> >
> > There is a way to solve it in MATLAB?
> >
> > Best,
> > Milos
>
> Hi Milos,
> Your system of equations has the effective form
> p*h - p*b + q*b^2 = 0
> r - p*b*h + p*h^2 + s*b - q*b^3 = 0,
> where p, q, r, s are constants composed of the original ones a, c, m, n.
> If you create the function
> res = @(x) [(x(2)-x(1))*p + x(1)^2*q
> (x(1)-x(2))*x(2)*p + x(1)*s -x(1)^3*q];
> you may solve your problem by any o nonlinear solvers. I would use my function LMFnlsq from FEX. You will find it at
> www.mathworks.com/matlabcentral/fileexchange/17534
> The calling sequence could be
> a = [b0; h0] % your estimates of unknowns b and h respectively.
> [x,ssq,cnt] = LMFnlsq(res,ones(2,1), 'Display',-5); % find solution
> x = x.*a; % rescaling the solution from normalized form to real size
> If your estimates were not far from the solution, you get b=x(1) and h=x(2).
> I hope that I have not introduce any error, and that it helps.
>
> Mira

Thank you Miroslav,
I tried with fsolve and it works for real parameters, but I want to find a general form for calculating b and h, so I want to keep this symbolic expressions for parameters.
How with symbolic variables, a,c,k, etc?

Best,
Milos

Subject: Nonlinear system of equations

From: Roger Stafford

Date: 26 Feb, 2011 21:24:05

Message: 5 of 7

"Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message <ikbhpd$fqk$1@fred.mathworks.com>...
> > "Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message <ikaj7r$5u9$1@fred.mathworks.com>...
> > > I have the following system of nonlinear equations
> > > (a*c*h-a*b*c)/b^2+n/2=0
> > > (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0
> > > variables are h and b, other are constants.
> > > ......
> ......
> I tried with fsolve and it works for real parameters, but I want to find a general form for calculating b and h, so I want to keep this symbolic expressions for parameters.
> How with symbolic variables, a,c,k, etc?
>
> Best,
> Milos
- - - - - - - - -
  By solving for h in terms of b in your first equation and substituting the result into the second equation you would obtain a quartic polynomial equation in the single unknown 'b'. You can use matlab's 'roots' function to solve for the four roots of b (some of which may be complex-valued) for any given set of constants and then evaluate h for each of these using the first equation.

  The difficulty with using 'fsolve' or other nonlinear matlab solvers is that they will not automatically give you all four roots unless the appropriate things are done with the estimate parameters.

  As for obtaining symbolic expressions for b and h in terms of the constants, there does exist a general analytic method for solving quartic equations, but it is a rather cumbersome affair. I'm not sure you would want to go through all that. For example see:

 http://mathworld.wolfram.com/QuarticEquation.html

Roger Stafford

Subject: Nonlinear system of equations

From: Think blue, count two.

Date: 27 Feb, 2011 17:33:15

Message: 6 of 7

On 26/02/11 4:04 AM, Milos Milenkovic wrote:

> I have the following system of nonlinear equations
>
> (a*c*h-a*b*c)/b^2+n/2=0
>
> (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0
>
> variables are h and b, other are constants.
>
> There is a way to solve it in MATLAB?

Yes with the symbolic toolkit.

syms a b c h k m n
solve([(a*c*h-a*b*c)/b^2+n/2,
(a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2], h, b)

The answer involves b being the roots of a quartic, and h being an
expression of the form (1 - f*b)*b where f is a relatively simple ratio
involving some of the constants.

Subject: Nonlinear system of equations

From: Milos Milenkovic

Date: 1 Mar, 2011 12:38:05

Message: 7 of 7

"Think blue, count two." <roberson@hushmail.com> wrote in message <vVvap.15264$QD2.4360@newsfe10.iad>...
> On 26/02/11 4:04 AM, Milos Milenkovic wrote:
>
> > I have the following system of nonlinear equations
> >
> > (a*c*h-a*b*c)/b^2+n/2=0
> >
> > (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2=0
> >
> > variables are h and b, other are constants.
> >
> > There is a way to solve it in MATLAB?
>
> Yes with the symbolic toolkit.
>
> syms a b c h k m n
> solve([(a*c*h-a*b*c)/b^2+n/2,
> (a*c*k^2/3-a*b*c*h+a*c*h^2+a*b*m)/b^3-n/2], h, b)
>
> The answer involves b being the roots of a quartic, and h being an
> expression of the form (1 - f*b)*b where f is a relatively simple ratio
> involving some of the constants.


Thank you all!!!
Best,
Milos

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