# Solving $X^{T}Xw = X^{T}y$ for $w$ in Octave / MATLAB

I have a matrix $X$ and a vector $y$, how do I solve the following equation for $w$:

$$X^{T}Xw = X^{T}y$$

in Octave and/or MATLAB?

-
@Landscape It is useful to have correct tags, but please, do not retag too many questions at once, since then the front page of the active tab is overfilled with old questions, bumped by your edits. See, for example, this question meta. Several questions in the linked tab there are related to this problem, too. –  Martin Sleziak May 17 '13 at 8:11
ok, now I've noticed that you were only doing rollbacks @Landscape. But I think that the concern that not too many old questions should be bumped still stands. –  Martin Sleziak May 17 '13 at 8:13
@MartinSleziak: Thank you for your kindly reminding. Yes, I was just rollbacking the retagging by doraemonpaul to their original status. It is my fault that I didn't realize that my behavior would lead to the bad result mentioned by you. –  23rd May 17 '13 at 8:20
@Landscape I have posted a question on meta. Perhaps it would be better to discuss the issue there before starting some kind of editing/retagging war between several users. –  Martin Sleziak May 17 '13 at 8:25

You don't have to worry about multiplying by $X^T$ to get a square matrix. Just type "X\y"
The literal translation of $$w = (X^{T}X)^{-1}X^{T}y$$ is