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:
Solving non linear equations

Subject: Solving non linear equations

From: Ashwini Deshpande

Date: 15 May, 2008 05:02:24

Message: 1 of 5

I have 3 unknowns and 3 nonlinear equations, as follows:

x^3 - 3x = y;
y^3 - 3y = z;
z^3 - 3z = x;

How do i solve this using matlab.

Thanks !
Ashwini

Subject: Solving non linear equations

From: Ashwini Deshpande

Date: 15 May, 2008 05:39:01

Message: 2 of 5

"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
message <g0gg50$hb4$1@fred.mathworks.com>...
> I have 3 unknowns and 3 nonlinear equations, as follows:
>
> x^3 - 3x = y;
> y^3 - 3y = z;
> z^3 - 3z = x;
>
> How do i solve this using matlab.
>
> Thanks !
> Ashwini
>

I tried to solve these equations using 'fsolve' command, i
am getting confused with how to set the starting values for
x, y and z. The procedure which i tried to solve is as follows:
function F = myfun(x)
F = [x(1)^3 - 3*x(1) - x(2);
     x(2)^3 - 3*x(2) - x(3);
     x(3)^3 - 3*x(3) - x(1)];

then from command prompt:
x0 = [-1;-1;-1];
[x,fval] = fsolve(@myfun,x0)

The problem is for all value of x0, i am getting different
answers for x, y and.

And one more doubt is i am getting one root value for x, y
and z. But i suppose to get 3 values for each variable as it
is a 3rd order equation.

Is there anything wrong in my approach, plz suggest me the
correct one.

Thanks!
Ashwini

Subject: Solving non linear equations

From: Roger Stafford

Date: 15 May, 2008 06:57:01

Message: 3 of 5

"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in message
<g0gi9l$gtu$1@fred.mathworks.com>...
> "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
> message <g0gg50$hb4$1@fred.mathworks.com>...
> > I have 3 unknowns and 3 nonlinear equations, as follows:
> >
> > x^3 - 3x = y;
> > y^3 - 3y = z;
> > z^3 - 3z = x;
> >
> > How do i solve this using matlab.
> >
> > Thanks !
> > Ashwini
>
> I tried to solve these equations using 'fsolve' command, i
> am getting confused with how to set the starting values for
> x, y and z. The procedure which i tried to solve is as follows:
> function F = myfun(x)
> F = [x(1)^3 - 3*x(1) - x(2);
> x(2)^3 - 3*x(2) - x(3);
> x(3)^3 - 3*x(3) - x(1)];
>
> then from command prompt:
> x0 = [-1;-1;-1];
> [x,fval] = fsolve(@myfun,x0)
>
> The problem is for all value of x0, i am getting different
> answers for x, y and.
>
> And one more doubt is i am getting one root value for x, y
> and z. But i suppose to get 3 values for each variable as it
> is a 3rd order equation.
>
> Is there anything wrong in my approach, plz suggest me the
> correct one.
>
> Thanks!
> Ashwini
----------------
  This is a problem for 'roots'. By substitution, you can obtain a 27th degree
polynomial equation and that will have 27 roots altogether. First substitute
x^3-3x in for y in the second equation getting:

 (x^3-3x)^3-3(x^3-3x) = z

Then substitute the left hand expression in this equation for z in the third
equation:

 ((x^3-3x)^3-3(x^3-3x))^3-3((x^3-3x)^3-3(x^3-3x)) = x

This is a polynomial equation of the 27th degree in x. For each of the 27
roots for x, the values of y and z can be determined uniquely from the first
two equations, so that makes 27 possible triplets x, y, and z which can satisfy
the three equations simultaneously.

  It is easy to see that there are three triplet solutions with x, y, and z all
equal: (0,0,0), (2,2,2), and (-2,-2,-2). I can only guess at the remaining 24
solutions, but because of the symmetry of the equations, very likely they
consist of four basically different solutions with six permutations among x, y,
and z possible for each one. I wouldn't be surprised if many of these were
complex-valued.

  Finding all such multiple solutions is a task well beyond the capabilities of
'fsolve' unless you provide it with a very large quantity of initial guesses for
its 'x0' argument. The 'roots' function seems the only reasonable way to do
the problem.

Roger Stafford

Subject: Solving non linear equations

From: Ashwini V

Date: 15 May, 2008 08:30:20

Message: 4 of 5

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <g0gmrt$bej$1@fred.mathworks.com>...
> "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
message
> <g0gi9l$gtu$1@fred.mathworks.com>...
> > "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
> > message <g0gg50$hb4$1@fred.mathworks.com>...
> > > I have 3 unknowns and 3 nonlinear equations, as follows:
> > >
> > > x^3 - 3x = y;
> > > y^3 - 3y = z;
> > > z^3 - 3z = x;
> > >
> > > How do i solve this using matlab.
> > >
> > > Thanks !
> > > Ashwini
> >
> > I tried to solve these equations using 'fsolve' command, i
> > am getting confused with how to set the starting values for
> > x, y and z. The procedure which i tried to solve is as
follows:
> > function F = myfun(x)
> > F = [x(1)^3 - 3*x(1) - x(2);
> > x(2)^3 - 3*x(2) - x(3);
> > x(3)^3 - 3*x(3) - x(1)];
> >
> > then from command prompt:
> > x0 = [-1;-1;-1];
> > [x,fval] = fsolve(@myfun,x0)
> >
> > The problem is for all value of x0, i am getting different
> > answers for x, y and.
> >
> > And one more doubt is i am getting one root value for x, y
> > and z. But i suppose to get 3 values for each variable as it
> > is a 3rd order equation.
> >
> > Is there anything wrong in my approach, plz suggest me the
> > correct one.
> >
> > Thanks!
> > Ashwini
> ----------------
> This is a problem for 'roots'. By substitution, you can
obtain a 27th degree
> polynomial equation and that will have 27 roots
altogether. First substitute
> x^3-3x in for y in the second equation getting:
>
> (x^3-3x)^3-3(x^3-3x) = z
>
> Then substitute the left hand expression in this equation
for z in the third
> equation:
>
> ((x^3-3x)^3-3(x^3-3x))^3-3((x^3-3x)^3-3(x^3-3x)) = x
>
> This is a polynomial equation of the 27th degree in x.
For each of the 27
> roots for x, the values of y and z can be determined
uniquely from the first
> two equations, so that makes 27 possible triplets x, y,
and z which can satisfy
> the three equations simultaneously.
>
> It is easy to see that there are three triplet solutions
with x, y, and z all
> equal: (0,0,0), (2,2,2), and (-2,-2,-2). I can only guess
at the remaining 24
> solutions, but because of the symmetry of the equations,
very likely they
> consist of four basically different solutions with six
permutations among x, y,
> and z possible for each one. I wouldn't be surprised if
many of these were
> complex-valued.
>
> Finding all such multiple solutions is a task well
beyond the capabilities of
> 'fsolve' unless you provide it with a very large quantity
of initial guesses for
> its 'x0' argument. The 'roots' function seems the only
reasonable way to do
> the problem.
>
> Roger Stafford
>
>


Thank u very much for ur reply,
I got the result, i tried as follows:
F = ((x^3-3*x)^3-3*(x^3-3*x))^3-3*((x^3-3*x)^3-3*(x^3-3*x))-x;
F1 = expand(F);
F2 = sym2poly(F1);
F3 = roots(F2);

Thanks!
Ashwini

Subject: Solving non linear equations

From: Dineshen

Date: 3 Jul, 2008 22:23:02

Message: 5 of 5

hi,

use jacobian to solve them

rgds,
dinesh


"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
message <g0gg50$hb4$1@fred.mathworks.com>...
> I have 3 unknowns and 3 nonlinear equations, as follows:
>
> x^3 - 3x = y;
> y^3 - 3y = z;
> z^3 - 3z = x;
>
> How do i solve this using matlab.
>
> Thanks !
> Ashwini
>

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