# How to solve this linear equation?

How is it possible to find $\gamma$ from the following equation?

$\omega^T (x − γ\frac{w}{||w||}) + b = 0$

note that x,w are vectors and b,γ are scalar.

I have read that the solution is:

$γ = \frac{(w^Tx) + b}{||w||}$

However, I do not know how it is computed. I tried to remove $\omega^T$ using $\omega^{T^{-1}}$ , but things got worse.

Edit: fixed a mistake: γ is scalar. Thanks.

• what is $y$ here? – James S. Cook Aug 30 '13 at 9:45
• What would $w^{T^{-1}}$ even be, considering that $w$ is a scalar? – lokodiz Aug 30 '13 at 9:46

$0=\omega^{T}(x-\gamma\frac{\omega}{\|\omega\|})+b=\omega^{T}x-\gamma\frac{\omega^{T}\omega}{\|\omega\|}+b$

So $\gamma\frac{\omega^{T}\omega}{\|\omega\|}=\omega^{T}x+b$.

Note that $\omega^{T}\omega=\|\omega\|^{2}$ so the above reduces to

$\gamma\|\omega\|=\omega^{T}x+b$ so

$\gamma=\frac{\omega^{T}x+b}{\|\omega\|}$.

You cannot premultiply with $(\omega^T)^{-1}$, because $\omega^T$ is a row-vector and it generally doesn't have an inverse.

Do this:

$$0 = \omega^T \left(x − γ\frac{\omega}{||\omega||}\right) + b = \omega^T x − γ\frac{\omega^T \omega}{||\omega||} + b$$

and then use the fact that $a^Ta = \|a\|^2$ for all vectors $a$.

P.S. $γ$ is obviously a scalar, and you're mixing $w$ and $\omega$.

You need to use the distributive property over vector addition of the dot product: $$a(b+c)=ab+ac$$ and notice that: $$\frac{a^Ta}{\|a\|} = \|a\|$$