# find inverse of a matrix with one value on the diagonal and otherwise [duplicate]

Let us look at the the matrix

$M =\begin{bmatrix} a & b & \dots & b \\ b & a & \dots & b \\ \vdots & b & \ddots & \vdots \\ b & \dots & b & a \end{bmatrix}$

It has one value $a$ on the main diagonal, and another value $b$ everywhere else. Let us assume that $a \neq b$. I wish to find the inverse of every $n\times n$ matrix of this form ($a$ on the diagonal, $b$ everywhere else).

## marked as duplicate by amd, mrp, Namaste linear-algebra StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jun 10 '17 at 12:23

• There is probably a popular post asking the same question. – StubbornAtom May 28 '17 at 12:00
• give me a link of that post? – jadey May 28 '17 at 12:07
• Just look to the right. It’s the very first related question. – amd May 28 '17 at 18:11

Write $M=(a-b)I+bJ$ where $J$ is the all-one matrix. Try an inverse also of this form $N=xI+yJ$. Taking $I=MN$ will give you two equations in $x$ and $y$ which should be easily soluble.
• What do you get when you expand out $((a-b)I+bJ)(xI+yJ)$? @jadey – Lord Shark the Unknown May 28 '17 at 12:10
• @jadey Note that $J^2=nJ$. – egreg May 28 '17 at 13:07