# Finding the condition number of a matrix $A$, and the values of b such that $A$ is ill-conditioned

Let $$A=\begin{pmatrix} 1 & b \\ 0 & 1\\\end{pmatrix}$$, what is the condition number of A, for which values of b the matrix A is ill-conditioned.

My trial: Since it does not specify in which norm to calculate the cond number, therefore I computed it for the $$l^1, l^{\infty}, l^2$$ norms, using the formula : $$cond(A)= ||A|| ||A^{-1}||$$.

I got

For $$l^1$$ $$cond_1(A)= (1+|a|)^2$$

For $$l^{\infty}$$ $$cond_{\infty}(A)= (1+|a|)^2$$

For $$l^2$$ $$cond_2(A)\leq (2+a^2)$$

And the

I don't know if this is what I shoud compute, or there are more options that I shoud consider.

For the second part, i am not sure about it but I think that the matrix would be ill-conditioned when it has a big or large condition number so it happens for big values of b.

Can you correct me, or give any tips.

You computed correctly $$K_1(A)$$ and $$K_{\infty}(A)$$.

Try to solve $$A x=c$$ when $$c=[1,1]$$ and then compute it for a perturbed r.h.s. $$\tilde{c} = c + \delta c$$. The key thing point in this case is that $$\frac{||\delta x||}{||x||} \leq K(A) \frac{||\delta c||}{||c||}$$ i.e. the condition number is a magnification factor for the relative error. Note also that it's not so important in this case which norm you use to compute $$K(A)$$.

• For $$b=2 \cdot 10^{6}$$ you obtain $$x=[-1999999,1]$$ to be the exact solution.

• Let's perturb of the r.h.s. $$c$$ with a $$\delta c$$ s.t. $$||\delta c||=10^{-3}$$: the solution is

$$\tilde{x} =x + \delta x=[-2.001998999000000\cdot 10^{6},1+10^{-3}]$$ where the first component is dramatically different from the first one of $$x$$. Thus your linear system has an high sensitivity to a small variation of the data, and this behaviour is justified by the large condition number you got in this case: $$K_\infty(A)=(1+2 \cdot 10^{6})^2$$.

You can try by yourself playing with the following Python snippet

    import numpy as np

b = 1e6;
A = np.array([[1,b],[0,1]])
print("Condition number compute with linalg",np.linalg.cond(A))
c = np.array([1,1])

deltac = np.array([1e-3,1e-3]) #perturbation
cc = c + deltac #perturbed r.h.s.

x = np.linalg.solve(A,c)
xx = np.linalg.solve(A,cc)

print("Solution of original system is",x)
print("Solution with perturbed r.h.s.",xx)

• Hi @VoB ,thanks for your answer, indeed I have no idea how to use python, but the code seems understandable, so when the ased for the valued of b such the tbthe matrix A is ill-conditioned I have to look at $Ax=c$ and consider errors? Sorry but I really don't know how it works. Dec 4, 2020 at 16:02
• To answer your question all you have to say is that $K(A)$ is large when $b$ is large. What I just proposed in my answer was just a possible example of what happens when your problem as a huge $b$, i.e. when it's ill-conditioned. @user726608 Have a look at this also: it contains some theory and also easy examples: blogs.mathworks.com/cleve/2017/07/17/…
– VoB
Dec 4, 2020 at 23:47