views:

1243

answers:

5

I'm trying to solve three simultaneous nonlinear equations in the unknowns x, y, z with Matlab's symbolic toolbox. What's wrong with the following code?

solve( '(x/4 + y/2 + z/4)*(1/(8*x) + 1/(16*y) + 1/(8*z))  = 0.5774',  ...
       '(x/4 + y/4 + z/2)*(1/(4*x) + 1/(16*y) + 1/(16*z)) = 0.5774',  ...
       '(x/2 + y/4 + z/4)*(1/(8*x) + 1/(8*y)  + 1/(16*z)) = 0.5774' )

I get the following error:

??? Error using ==> subsref
Index exceeds matrix dimensions.

Error in ==> sym.subsref at 16
  y = builtin('subsref',struct(x),a);

Error in ==> solve at 191
      S.(char(symvars(j))) = R(:,j);

I'm using Matlab version 7.7.0.471. I'm not familiar at all with the symbolic toolbox. What am I missing?

Am I expecting too much from a symbolic engine? Or, are there better ways to solve the above equations? (A numerical solution will do.)

+2  A: 

Hi

Your syntax is correct but I don't think that your system of equations has a solution. When I pushed them through Mathematica it returned an empty list which usually indicates that there is no solution.

The version of MATLAB you are using uses MuPad as it's symbolic computation engine but they used to use Maple. I have the most recent version of the Maple version of the symbolic toolbox and when I put your expression into it I get

Warning: Explicit solution could not be found.
 In solve at 140

ans =

[ empty sym ]

So I would suggest that there is no solution to this system of equations and the new Mupad symbolic engine simply doesn't handle this fact very elegantly.

Update: Attempting to solve this numerically in Mathematica results in complaints about a singular Jacobian no matter what starting values I choose. I simply do not know how to prove that your equations have no solution but I strongly suspect this is the case.

MikeCroucher
A: 

One way to check if what Mike suggested is happening in your code is to set a break point at the offending line in solve and check the sizes of the variables used there. Chances are, one or more has size 0. As to figuring out if there truly is no solution mathematically, I can't help you there. Find a math grad student.

Scottie T
A: 

It looks like it might be a bug. It looks the same as this:

http://www.mathworks.com/support/bugreports/details.html?rp=501052

ManWithSleeve
A: 

xx=[0:.1:5];yy=.2; for i=1:50; yy(i+1)= yy(i)+.1*yy(i)*(1-yy(i); end; plot(xx,yy)

learn how to format your posts.
SilentGhost
A: 

write your code like this

solve ('x+y+1','x+2*y-5');

that'll be alright

related questions