Is it possible to solve for a directly without using the inverse?

  • Context: MATLAB 
  • Thread starter Thread starter feenaboccles
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around the mathematical problem of solving for a vector \( a \) in the context of linear algebra, specifically regarding the expression \( a = x' * inv(X * X') * X \). Participants explore whether there are alternative methods or decompositions that could expedite the calculation in Matlab, particularly when the matrix \( X \) is updated frequently.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant suggests writing a custom Matlab function to solve the equation, implying that a tailored approach might be beneficial.
  • Another participant emphasizes that the original question is not strictly about Matlab but rather about rephrasing the problem to utilize optimized solvers available in linear algebra libraries.
  • A participant proposes taking the transpose of the matrices involved, suggesting it might simplify the problem, but later indicates that this approach does not resolve the issue.
  • Discussion includes a comparison to standard linear regression problems, highlighting differences in dimensionality and arrangement of data points, which complicates the direct application of typical solutions.
  • There is a focus on minimizing the norm of \( a \) subject to certain constraints, questioning if there are ways to avoid using the inverse in the calculations.

Areas of Agreement / Disagreement

Participants do not reach a consensus on whether a method exists to solve the problem without using the inverse. Multiple competing views and approaches are presented, indicating that the discussion remains unresolved.

Contextual Notes

Participants note the specific arrangement of data points (column-wise vs. row-wise) and the implications this has on the formulation of the problem. There are also references to the limitations of standard regression equations in the context of the problem being discussed.

feenaboccles
Messages
3
Reaction score
0
I'm working on a project where the following has to be solved on a regular basis, as new column vectors are added to the matrix X.

a = x' * inv (X * X') * X

where
m is the number of examples
d is the dimensionality of the vector x
x is d x 1 and norm2(x) <= 1
X is d x m, consisting of m "x" vectors arranged column-wise (not row-wise as is typically the case)
and
a should be m x 1

I'm wondering is there a faster way to calculate in Matlab, other than a direct implementation of the above. It's not an equation in the usual form Xw = y, so the built-in solver won't work. I'm wondering are there any decompositions that might help, but bear in mind that the equation is solved, then X is changed, then we return to solve the equation once more for a different x.

Thanks
 
Physics news on Phys.org
Why don't you write your own Matlab function?
 
whs said:
Why don't you write your own Matlab function?

The code in my original post is Matlab code which does solve the equation. My question is not particularly Matlab-centric: it's whether the problem can be re-phrased, through some factorisation or decomposition, which would expedite its solution. Particularly, I'm wondering can it be rephrased in such as way that I can employ the heavily optimised solvers one finds in Matlab and various lin alg libraries like BLAS.
 
Ah, I don't know the answer, but you might want to try posting this (or getting it moved) to the computers/math software section where there are lots of matlab/mathematica type questions.
 
why don't you just take the transpose, then everything goes back to normal ?
 
trambolin said:
why don't you just take the transpose, then everything goes back to normal ?

Actually it won't.

Take a standard linear regression problem
X * w = y
where
m is the number of training samples
d is the dimensionality of each training sample xm
X is m x d the datapoints xm arranged row-wise
y is m x 1
w is d x 1

The standard equations are (less regularization) are
w = inv(X' * X) * X' * y

Or

w' = y' * X * inv (X' * X)'

If you say Z = X' (i.e datapoints are arranged column wise, rather than row-wise), you get

w' = y * Z' * inv (Z * Z')'Now consider my example. In my example I'm expression a new datapoint as a linear combination (the vector a) of all previous datapoints. This is different to the standard regression problem. Hence, whereas w above is d x 1, a is m x 1. So, if we have a new datapoint z, and we want to express it as a linear combination of previous datapoints arranged column-wise in Z. We minimise ||a||2 subject to z = Z * a and thereby get

a = z' * inv (Z * Z') * Z

My question is is there any way of rephrasing this so the inverse can be avoided, and the problem solved directly.

The key diffence in the equations for a and w' is the first term, y is m x 1, but z is d x 1
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 16 ·
Replies
16
Views
15K