# How to compute the inverse of a matrix in matlab?

I have a matrix $$X=\int_{0}^{2}\begin{bmatrix}P_1^2&-P_1P_2\\ -P_2P_1& P_2^2 \end{bmatrix}ds+\int_{0}^{1}(2-s)^{-0.5}(1-s)^{0.5}\begin{bmatrix}P_1Q_2& P_1Q_1\\-P_2Q_2& -P_2Q_1\end{bmatrix}ds+\int_{0}^{1}(2-s)^{0.5}(1-s)^{-0.5}\begin{bmatrix}Q_2P_1&-Q_2P_2\\Q_1P_1&-Q_1P_2 \end{bmatrix}ds+\int_{0}^{1}\begin{bmatrix}Q_2^2& Q_2Q_1\\Q_1Q_2&Q_1^2\end{bmatrix}ds$$ where $$P_1=1-\frac{(2-s)^{2\alpha}}{\Gamma(2\alpha+1)}+\frac{(2-s)^{4\alpha}}{\Gamma(4\alpha+1)} -\frac{(2-s)^{6\alpha}}{\Gamma(6\alpha+1)}+\cdots\hspace{0.2 cm} \\ P_2=\frac{(2-s)^\alpha}{\Gamma(\alpha+1)}-\frac{(2-s)^{3\alpha}}{\Gamma(3\alpha+1)}+\frac{(2-s)^{5\alpha}}{\Gamma(5\alpha+1)}-\cdots$$ Similarly $Q_1$ and $Q_2$ by replacing $(2-s)$ by $(1-s)$. Then how to compute the inverse of $X$ in matlab? Here $\alpha=0.5$.

• Why can't you use inv(X)? – John Alexiou Jan 20 '17 at 6:10

Once you have grouped all your terms into a $2 \times 2$ matrix, whatever the programming language, you don't need to use the inverse, because there is, in this case, an explicit formula:

$$\pmatrix{a&c\\b&d}^{-1}=\dfrac{1}{\Delta}\pmatrix{d&-b\\-c&a}$$

where $\Delta=ad-bc$ (determinant).

Nevertheless, it will remain a certain number of computations...

Remark: with $\alpha=1/2$, $P_1(s)=\exp(s-2)$, isn't it ? (thanks to Bartgol for the correction).

• See the remark I have added at the end of my answer. I think an equivalent expression could be found for $P_2$. – Jean Marie Jan 20 '17 at 5:33
• Uhm, I think for $\alpha=0.5$ you get $P_1(s)=exp(s-2)$... Perhaps you meant $P_2$? But even then, I would say $P_2(s)=\sin\sqrt{2-s}$. – bartgol Jan 20 '17 at 5:37
• @bartgol you are right. I correct it. – Jean Marie Jan 20 '17 at 5:38
• how $P_2(s)=sin\sqrt{(2-s)}?$ In the denominator gamma function is there. – thomus Jan 20 '17 at 6:17