views:

313

answers:

4

I want to solve these equations using MATLAB and I am sure there is a non zero solution. The equations are:

0.7071*x            + 0.7071*z = x 
  -0.5*x + 0.7071*y +    0.5*z = y
  -0.5*x - 0.7071*y +    0.5*z = z

I wrote in MATLAB:

[x,y,z]=solve('0.7071 * x+0.7071 * z=x','-0.5 * x+0.7071 * y+0.5 * z=y','-0.5 * x-0.7071 * y+0.5 * z=z');

But the result is x = y = z = 0. As I said I am sure that there is a solution. Can any one help?

+4  A: 

I don't think you need to use the solve function as your equations is a system of linear equations.

Recast as a matrix equation:

Ax = B

In your case:

    | -0.2929   0.0      0.7071  |  | x |     | 0 |
    | -0.5     -0.2929   0.5     |  | y |  =  | 0 |
    | -0.5     -0.7071  -0.5     |  | z |     | 0 |

Use the built-in functionally of MATLAB to solve it. See e.g. MATLAB: Solution of Linear Systems of Equations.

The core of MATLAB is to solve this kind of equation.


Using FreeMat (an open-source MATLAB-like environment with a GPL license; direct download URL for Windows installer):

   A = [ -0.2929 0.0 0.7071; -0.5 -0.2929 0.5; -0.5 -0.7071 -0.5 ]

   B = [0.0; 0.0; 0.0]

   A\B

   ans =
    0
    0
    0

So the solution is: x = 0, y = 0, z = 0


The solution can also be derived by hand. Starting from the last two equations:

    -0.5*x + 0.7071*y +    0.5*z = y
    -0.5*x - 0.7071*y +    0.5*z = z

    0.2929*y =  -0.5*x + 0.5*z
    0.7071*y =  -0.5*x + 0.5*z

    0.2929*y = 0.7071*y

Thus y = 0.0 and:

    0.7071*y =  -0.5*x + 0.5*z

    0 =  -0.5*x + 0.5*z

    0 =  -0.5*x + 0.5*z

    0.5*x = 0.5*z

    x = z

Inserting in the first equation:

    0.7071*x + 0.7071*z = x 

    0.7071*x + 0.7071*x = x 

    1.4142*x = x

Thus x = 0.0. And as x = z, then z = 0.0.

Peter Mortensen
I wrote A=[0.7071 0 0.7071;-0.5 0.7071 0.5; -0.5 -0.7071 0.5]<br/>[x;y;z]=A*[x;y;z]<br/>but it gives error. Note that the right hand side are x,y,z not zeros.Please could you write it in Matlab for me.
Hani
I have updated the question with code that should run in MATLAB.
Peter Mortensen
Thanks for your interest but the B array should be [x;y;z] and the equation you wrote are not like the equations which i wrote in the questions.
Hani
yes but send B to the other side, and you get the form above
Amro
-1 You messed up somewhere. There *is* a nontrivial solution. In fact, there are infinitely many because the matrix T of your Tv=0 system is singular.
sellibitze
A: 

x = 0, y = 0, z = 0 is the correct solution. This problem can be easily worked by hand.

Jeffrey L Whitledge
It is A solution. It is NOT the solution desired by the question. Null gives the non-trivial solution.
woodchips
A: 
A = [ 0.7071 0 0.7071 ;
      -0.5 0.7071 0.5 ;
    -0.5 -0.7071 0.5 ];
B = [1 ; 1 ; 1];

AA = A-diag(B)

      -0.2929            0       0.7071
         -0.5      -0.2929          0.5
         -0.5      -0.7071         -0.5

BB = B-B

     0
     0
     0

AA\BB

     0
     0
     0
Amro
+3  A: 

You're looking for a non-trivial solution v to A*v=v with v=[x;y;z] and...

A =
   0.70710678118655                  0   0.70710678118655
  -0.50000000000000   0.70710678118655   0.50000000000000
  -0.50000000000000  -0.70710678118655   0.50000000000000

You can transform this into (A-I)v=0 where I is the 3x3 identity matrix. What you have to do to find a nontrivial solution is checking the null space of A-I:

>> null(A-eye(3))

ans =

   0.67859834454585
  -0.67859834454585
   0.28108463771482

So, you have a onedimensional nullspace. Otherwise you'd see more than one column. Every linear combination of the columns is a point in this null space that A-I maps to the null vector. So, every multiple of this vector is a solution to your problem.

Actually, your matrix A is a rotation matrix of the first kind because det(A)=1 and A'*A=identity. So it has an eigenvalue of 1 with the rotation axis as corresponding eigenvector. The vector I computed above is the normalized rotation axis.

Note: For this I replaced your 0.7071 with sqrt(0.5). If rounding errors are a concern but you know in advance that there has to be a nontrivial solution the best bet is to do a singular value decomposition of A-I and pick the right most right singular vector:

>> [u,s,v] = svd(A-eye(3));
>> v(:,end)

ans =

   0.67859834454585
  -0.67859834454585
   0.28108463771482

This way you can calculate a vector v that minimizes |A*v-v| under the constraint that |v|=1 where |.| is the Euclidean norm.

sellibitze
Thank you very much this is what exactly i want but frankly i could not understand how did you get it.Please could you advice me with a reference which describes this idea (not a fully Linear algebra book but only this idea ex: A chapter or a section from a book).
Hani
What exactly is it that you don't understand?
sellibitze
The null space, eigenvalue . Why A-I gives result although it is multiplied by v (A-I)v=0. I read what null function do in matlab but i could not understand it exactly. Why did you took the v only from svd result and what u and s represents. I really appreciate your description and your time spent to explain, but the problem lies beyond the fact that i learnt linear Algebra with out going deep in these topics and i dont have time now(just now) to read a full book for linear Algebra. With my grateful. Hani Almousli..
Hani
Forget about null. The important thing you should understand is what the SVD is and what the properties of these 3 matrices are. I suggest you do a little research on this topic on your own. Wikipedia is a good start, I suppose.
sellibitze
Basically you're computing the eigenvectors of the matrix A : AX=lambda*X with lambda=1. `[V D] = eig(A)` and pick the vector `V(:,3)` corresponding to the real eigenvalue 1 `D(3,3)`. This page is might have some explanations: http://en.wikipedia.org/wiki/Eigenvalue,_eigenvector_and_eigenspace
Amro
Another alternative for computing an eigenvector v for a given matrix A and eigenvalue lambda: `[Q,R]=qr(A'-lambda*eye(size(A))); v=Q(:,end)`. For 3x3 rotation matrices there is an even easier way to compute the rotation axis, though.
sellibitze

related questions