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:
Limits of Symbolic Toolbox

Subject: Limits of Symbolic Toolbox

From: Perry

Date: 30 Sep, 2010 17:56:19

Message: 1 of 10

I tried to solve the system of 6 equations w/ 6 unknowns in symbolic toolbox and it could not handle it. I am pretty sure my math is right and was just wondering if this was just beyond the limits of symbolic toolbox or if I was doing something wrong.
thanks for the help

syms X1 X2 X3 X4 X5 X6 Y1 Y2 Y3 Y4 Y5 Y6 Z1 Z2 Z3 Z4 Z5 Z6 L13 L24 L34 L35 L56;

[X3,Y3,X4,Y4,X5,Y5]=solve( '(X1-X3)^2+(Y1-Y3)^2+(Z1-Z3)^2=L13^2',...
                           '(X3-X4)^2+(Y3-Y4)^2+(Z3-Z4)^2=L34^2',...
                           '(X2-X4)^2+(Y2-Y4)^2+(Z2-Z4)^2=L24^2',...
                           '(X3-X5)^2+(Y3-Y5)^2+(Z3-Z5)^2=L35^2',...
                           '(X4-X5)^2+(Y4-Y5)^2+(Z4-Z5)^2=L45^2',...
                           '(X5-X6)^2+(Y5-Y6)^2+(Z5-Z6)^2=L56^2');
                       

Subject: Limits of Symbolic Toolbox

From: Walter Roberson

Date: 30 Sep, 2010 19:25:03

Message: 2 of 10

On 10-09-30 12:56 PM, Perry wrote:
> I tried to solve the system of 6 equations w/ 6 unknowns in symbolic
> toolbox and it could not handle it. I am pretty sure my math is right
> and was just wondering if this was just beyond the limits of symbolic
> toolbox or if I was doing something wrong.
> thanks for the help
>
> syms X1 X2 X3 X4 X5 X6 Y1 Y2 Y3 Y4 Y5 Y6 Z1 Z2 Z3 Z4 Z5 Z6 L13 L24 L34
> L35 L56;
>
> [X3,Y3,X4,Y4,X5,Y5]=solve( '(X1-X3)^2+(Y1-Y3)^2+(Z1-Z3)^2=L13^2',...
> '(X3-X4)^2+(Y3-Y4)^2+(Z3-Z4)^2=L34^2',...
> '(X2-X4)^2+(Y2-Y4)^2+(Z2-Z4)^2=L24^2',...
> '(X3-X5)^2+(Y3-Y5)^2+(Z3-Z5)^2=L35^2',...
> '(X4-X5)^2+(Y4-Y5)^2+(Z4-Z5)^2=L45^2',...
> '(X5-X6)^2+(Y5-Y6)^2+(Z5-Z6)^2=L56^2');

You should indicate in the solve() call which variables you are solving for.

I am currently trying for a solution in Maple, under the assumption that the
variables should all be real-valued; it is taking some time to process.

Subject: Limits of Symbolic Toolbox

From: Perry

Date: 30 Sep, 2010 19:55:24

Message: 3 of 10

Aren't I telling matlab that I am solving for X3, Y3, X4, Y4, X5, Y5 by the first part of the command?
 [X3,Y3,X4,Y4,X5,Y5]=solve( '.........

p.s. I didn't say it would be an easy solution, it makes sense that it would take a while.
-perry

Walter Roberson <roberson@hushmail.com> wrote in message <i82obr$eik$1@canopus.cc.umanitoba.ca>...
> On 10-09-30 12:56 PM, Perry wrote:
> > I tried to solve the system of 6 equations w/ 6 unknowns in symbolic
> > toolbox and it could not handle it. I am pretty sure my math is right
> > and was just wondering if this was just beyond the limits of symbolic
> > toolbox or if I was doing something wrong.
> > thanks for the help
> >
> > syms X1 X2 X3 X4 X5 X6 Y1 Y2 Y3 Y4 Y5 Y6 Z1 Z2 Z3 Z4 Z5 Z6 L13 L24 L34
> > L35 L56;
> >
> > [X3,Y3,X4,Y4,X5,Y5]=solve( '(X1-X3)^2+(Y1-Y3)^2+(Z1-Z3)^2=L13^2',...
> > '(X3-X4)^2+(Y3-Y4)^2+(Z3-Z4)^2=L34^2',...
> > '(X2-X4)^2+(Y2-Y4)^2+(Z2-Z4)^2=L24^2',...
> > '(X3-X5)^2+(Y3-Y5)^2+(Z3-Z5)^2=L35^2',...
> > '(X4-X5)^2+(Y4-Y5)^2+(Z4-Z5)^2=L45^2',...
> > '(X5-X6)^2+(Y5-Y6)^2+(Z5-Z6)^2=L56^2');
>
> You should indicate in the solve() call which variables you are solving for.
>
> I am currently trying for a solution in Maple, under the assumption that the
> variables should all be real-valued; it is taking some time to process.

Subject: Limits of Symbolic Toolbox

From: Walter Roberson

Date: 30 Sep, 2010 20:52:56

Message: 4 of 10

On 10-09-30 02:55 PM, Perry wrote:
> Aren't I telling matlab that I am solving for X3, Y3, X4, Y4, X5, Y5 by
> the first part of the command?
> [X3,Y3,X4,Y4,X5,Y5]=solve( '.........

No. You are telling it which arbitrary variable names to assign the solutions
to. The order that will actually be solved if you do not specify which
variables to solve for in the solve() call, is _approximately_ X then Y then Z
then all the other variables in lexographic order (I'd have to find the
reference again for the exact order.)

Subject: Limits of Symbolic Toolbox

From: Walter Roberson

Date: 30 Sep, 2010 21:11:01

Message: 5 of 10

On 10-09-30 12:56 PM, Perry wrote:
> I tried to solve the system of 6 equations w/ 6 unknowns in symbolic
> toolbox and it could not handle it. I am pretty sure my math is right
> and was just wondering if this was just beyond the limits of symbolic
> toolbox or if I was doing something wrong.
> thanks for the help
>
> syms X1 X2 X3 X4 X5 X6 Y1 Y2 Y3 Y4 Y5 Y6 Z1 Z2 Z3 Z4 Z5 Z6 L13 L24 L34
> L35 L56;
>
> [X3,Y3,X4,Y4,X5,Y5]=solve( '(X1-X3)^2+(Y1-Y3)^2+(Z1-Z3)^2=L13^2',...
> '(X3-X4)^2+(Y3-Y4)^2+(Z3-Z4)^2=L34^2',...
> '(X2-X4)^2+(Y2-Y4)^2+(Z2-Z4)^2=L24^2',...
> '(X3-X5)^2+(Y3-Y5)^2+(Z3-Z5)^2=L35^2',...
> '(X4-X5)^2+(Y4-Y5)^2+(Z4-Z5)^2=L45^2',...
> '(X5-X6)^2+(Y5-Y6)^2+(Z5-Z6)^2=L56^2');

If you declare the symbols as all being real-valued:

If you break the equations up in to pairs, and use the degree=2 option to
solve(), to solve individually the first and third pair for
[X3,Y3,X4,Y4,X5,Y5], and solve the second pair for [Y3,Y4,X5,Y5], then each of
those pairwise solutions will generate 4 solution sets. You can then attempt
combinations from the sets: throw out any that come out empty. With some
examination you should get a feeling for which combinations would be
relatively easy to solve; I would suggest concentrating on those first. You
might find that the easily-solved combinations cannot come out to a
simultaneous solution, but if so then you can at least eliminate those and
move on to the harder combinations -- and possibly the easy combinations will
find a simultaneous solution within a decent time.

Subject: Limits of Symbolic Toolbox

From: Steven_Lord

Date: 30 Sep, 2010 21:18:43

Message: 6 of 10



"Walter Roberson" <roberson@hushmail.com> wrote in message
news:i82tgk$mai$1@canopus.cc.umanitoba.ca...
> On 10-09-30 02:55 PM, Perry wrote:
>> Aren't I telling matlab that I am solving for X3, Y3, X4, Y4, X5, Y5 by
>> the first part of the command?
>> [X3,Y3,X4,Y4,X5,Y5]=solve( '.........
>
> No. You are telling it which arbitrary variable names to assign the
> solutions to. The order that will actually be solved if you do not specify
> which variables to solve for in the solve() call, is _approximately_ X
> then Y then Z then all the other variables in lexographic order (I'd have
> to find the reference again for the exact order.)

http://www.mathworks.com/help/toolbox/symbolic/solve.html

"Three different types of output are possible. For one equation and one
output, the resulting solution is returned with multiple solutions for a
nonlinear equation. For a system of equations and an equal number of
outputs, the results are sorted alphabetically and assigned to the outputs.
For a system of equations and a single output, a structure containing the
solutions is returned."

This is why I recommend that if you call SOLVE, you call it with one output
as in example 4 on that page.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Limits of Symbolic Toolbox

From: Walter Roberson

Date: 30 Sep, 2010 21:32:32

Message: 7 of 10

On 10-09-30 04:18 PM, Steven_Lord wrote:

> "Walter Roberson" <roberson@hushmail.com> wrote in message

>> No. You are telling it which arbitrary variable names to assign the
>> solutions to. The order that will actually be solved if you do not
>> specify which variables to solve for in the solve() call, is
>> _approximately_ X then Y then Z then all the other variables in
>> lexographic order (I'd have to find the reference again for the exact
>> order.)
>
> http://www.mathworks.com/help/toolbox/symbolic/solve.html
>
> "Three different types of output are possible. For one equation and one
> output, the resulting solution is returned with multiple solutions for a
> nonlinear equation. For a system of equations and an equal number of
> outputs, the results are sorted alphabetically and assigned to the
> outputs. For a system of equations and a single output, a structure
> containing the solutions is returned."

Yes, however on that same page it says,

solve(eq1, eq2, ..., eqn) or solves the system of equations implied by
eq1,eq2,...,eqn in the n variables determined by applying symvar to the system.

When we then look at the symvar documentation,
http://www.mathworks.com/help/toolbox/symbolic/symvar.html

symvar(s,n) returns a vector containing the n symbolic variables in s that are
alphabetically closest to 'x':

    1. The variables are sorted by the first letter in their names. The
ordering is x y w z v u ... a X Y W Z V U ... A. The name of a symbolic
variable cannot begin with a number.
    2. For all subsequent letters, the ordering is alphabetical, with all
uppercase letters having precedence over lowercase: 0 1 ... 9 A B ... Z a b ...z.


Thus, the n variables determined by applying symvar are not necessarily going
to be in standard alphanumeric order; once those variables are chosen, the
multiple-output clause you quoted will take effect causing those variables to
be sorted alphabetically for the purposes of the assignment to the output
arguments.

If I interpret the symvar documentation correctly, then with this input system
and with 6 outputs, it would choose the 6 X variables as the variables to
solve for.


 > This is why I recommend that if you call SOLVE, you call it with one output
 > as in example 4 on that page.

That example shows the structure output format. On the other hand, that
example also happens to want to solve for all of the input symbolic variables
simultaneously. In the case of this input system, it would at the very least
result in a waste of time, and would quite possibly result in a useless set of
answers. I thus recommend structure output together with explicit
specification of the variables to solve for.

Subject: Limits of Symbolic Toolbox

From: Roger Stafford

Date: 30 Sep, 2010 22:58:04

Message: 8 of 10

"Perry " <ptaylor@rcrracing.com> wrote in message <i82j03$rhj$1@fred.mathworks.com>...
> I tried to solve the system of 6 equations w/ 6 unknowns in symbolic toolbox and it could not handle it. I am pretty sure my math is right and was just wondering if this was just beyond the limits of symbolic toolbox or if I was doing something wrong.
> thanks for the help
>
> syms X1 X2 X3 X4 X5 X6 Y1 Y2 Y3 Y4 Y5 Y6 Z1 Z2 Z3 Z4 Z5 Z6 L13 L24 L34 L35 L56;
>
> [X3,Y3,X4,Y4,X5,Y5]=solve( '(X1-X3)^2+(Y1-Y3)^2+(Z1-Z3)^2=L13^2',...
> '(X3-X4)^2+(Y3-Y4)^2+(Z3-Z4)^2=L34^2',...
> '(X2-X4)^2+(Y2-Y4)^2+(Z2-Z4)^2=L24^2',...
> '(X3-X5)^2+(Y3-Y5)^2+(Z3-Z5)^2=L35^2',...
> '(X4-X5)^2+(Y4-Y5)^2+(Z4-Z5)^2=L45^2',...
> '(X5-X6)^2+(Y5-Y6)^2+(Z5-Z6)^2=L56^2');
- - - - - - - -
  A couple of comments. To begin with, this is basically a two-dimensional problem. Each of the six L13^2-(Z1-Z3)^2, L34^2-(Z3-Z4)^2, ... terms can be condensed into single known squared quantities, R13^2, R34^2, etc., and this would then make it an equivalent problem in two dimensions with the R's as radii in the x-y plane. If you were to find solutions for this problem, they would undoubtedly be extremely complicated, and having separate Z and L terms would make it all the more complicated by a large factor.

  However, I put forth the hypothesis that 'solve' will never find a solution that can be expressed in radicals. Based on some rough sketches (on the back of the proverbial envelope) I have reason to believe that it is an eighth-order problem, with up to eight possible roots, and when and if it were to be reduced to a single equation in a single unknown I therefore strongly suspect that equation would prove to be an eighth-order polynomial. As is well known, courtesy of Galois and Abel, there is no solution in terms of radicals for a general eighth-order polynomial - not even for a general fifth-order polynomial.

  If you prove me wrong and do manage to coerce a solution out of 'solve', I shudder to think of how long its expressions will be, even though you may have combined the Z and L terms. I await your results with bated breath. :-)

Roger Stafford

Subject: Limits of Symbolic Toolbox

From: Perry

Date: 1 Oct, 2010 11:02:04

Message: 9 of 10

Walter-
      I have yet to ascertain from the documentation how to declare what variables to solve for. How would I structure the problem to solve for only the 6 variables that I have declared in my output matrix?

thanks for your help
-perry


Walter Roberson <roberson@hushmail.com> wrote in message <i82vqs$pp0$1@canopus.cc.umanitoba.ca>...
> On 10-09-30 04:18 PM, Steven_Lord wrote:
>
> > "Walter Roberson" <roberson@hushmail.com> wrote in message
>
> >> No. You are telling it which arbitrary variable names to assign the
> >> solutions to. The order that will actually be solved if you do not
> >> specify which variables to solve for in the solve() call, is
> >> _approximately_ X then Y then Z then all the other variables in
> >> lexographic order (I'd have to find the reference again for the exact
> >> order.)
> >
> > http://www.mathworks.com/help/toolbox/symbolic/solve.html
> >
> > "Three different types of output are possible. For one equation and one
> > output, the resulting solution is returned with multiple solutions for a
> > nonlinear equation. For a system of equations and an equal number of
> > outputs, the results are sorted alphabetically and assigned to the
> > outputs. For a system of equations and a single output, a structure
> > containing the solutions is returned."
>
> Yes, however on that same page it says,
>
> solve(eq1, eq2, ..., eqn) or solves the system of equations implied by
> eq1,eq2,...,eqn in the n variables determined by applying symvar to the system.
>
> When we then look at the symvar documentation,
> http://www.mathworks.com/help/toolbox/symbolic/symvar.html
>
> symvar(s,n) returns a vector containing the n symbolic variables in s that are
> alphabetically closest to 'x':
>
> 1. The variables are sorted by the first letter in their names. The
> ordering is x y w z v u ... a X Y W Z V U ... A. The name of a symbolic
> variable cannot begin with a number.
> 2. For all subsequent letters, the ordering is alphabetical, with all
> uppercase letters having precedence over lowercase: 0 1 ... 9 A B ... Z a b ...z.
>
>
> Thus, the n variables determined by applying symvar are not necessarily going
> to be in standard alphanumeric order; once those variables are chosen, the
> multiple-output clause you quoted will take effect causing those variables to
> be sorted alphabetically for the purposes of the assignment to the output
> arguments.
>
> If I interpret the symvar documentation correctly, then with this input system
> and with 6 outputs, it would choose the 6 X variables as the variables to
> solve for.
>
>
> > This is why I recommend that if you call SOLVE, you call it with one output
> > as in example 4 on that page.
>
> That example shows the structure output format. On the other hand, that
> example also happens to want to solve for all of the input symbolic variables
> simultaneously. In the case of this input system, it would at the very least
> result in a waste of time, and would quite possibly result in a useless set of
> answers. I thus recommend structure output together with explicit
> specification of the variables to solve for.

Subject: Limits of Symbolic Toolbox

From: Walter Roberson

Date: 1 Oct, 2010 14:41:10

Message: 10 of 10

On 01/10/10 6:02 AM, Perry wrote:

> I have yet to ascertain from the documentation how to declare what
> variables to solve for. How would I structure the problem to solve for
> only the 6 variables that I have declared in my output matrix?

http://www.mathworks.com/help/toolbox/symbolic/solve.html

g = solve(eq1, eq2, ..., eqn, var1, var2, ..., varn)

g = solve(eq1, eq2, ..., eqn, var1, var2, ..., varn) finds the zeros for
the system of equations for the variables specified as inputs.

Tags for 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