# Finding Reliable Digits in Mathematica?

(cross-posted on Community)

Example: the linear equation system $Ax=b$ has one approximation $\bar x$ and one exact $x^* \neq 0$ solutions. we also gives: $p>3, \|x^* - \bar x \| \leq 10^{-20} + \|A\| \|A^{-1}\| 10^{-p} \|x^*\|$ which $\|A\| \|A^{-1}\|=10^{4}$. The reliable digits of $\bar x$ for solutions of this system of equation is $0$.

How we can find the reliable digits of this equation in Mathematica? any idea?

This is written by J.M and one modification by me makes the code wrong, but I couldn't get the answer, when run it online.

hm = HilbertMatrix[4];
sol = {1, 1, 1, 1};
mat = Round[N[hm], 1.*^4];
bv = Round[N[hm.sol], 1.*^4];
s = LinearSolve[mat, bv];
Norm[sol - s]


Now the code is completed, but I couldn't interpret the result, i.e what is the result $0.6780$ means?

• You are trying to round values of $x\le 1$ to $\mathbb{O}4$, this doesn't make sense. Aug 1, 2016 at 13:04
• You didn't copy my snippet correctly. Did you not notice the negative signs in the exponent? Aug 1, 2016 at 13:06
• You say this is wrong, I removed "-" !! @J.M. Aug 1, 2016 at 13:07
• @Feyre would you please explain more? I didnt get the point. Aug 1, 2016 at 13:08
• hm produces values between $0\le x\le 1$, if you round this to 1*^4, it will produce nothing but zeroes. Aug 1, 2016 at 13:09

There's a mistake in the code, you are trying to round numbers $x<1$ to $\mathbb{O}(4)$ try this:

hm = HilbertMatrix[4];
sol = {1, 1, 1, 1};
mat = Round[N[hm], 1.*^-4];
bv = Round[N[hm.sol], 1.*^-4];
s = LinearSolve[mat, bv];
NumberForm[Norm[sol - s], 5]


0.6780

As @J.M. has pointed out, it makes no sense for the condition number to be $<1$. Round[N[hm], n>1] will always yield an array of zeroes.

This rounds hm to four significant digits after the .

• ...and that's exactly the code I gave the OP in his (now deleted) previous question. I'm not sure why he thought to remove the negative signs in the exponent... anyway, for reference: LinearAlgebraMatrixConditionNumber[mat] gives the result 36250.4, which is why I chose that particular matrix. Aug 1, 2016 at 13:12
• @MichleJordan lines three and four, a -` before the 4, Aug 1, 2016 at 13:18
• @MichleJordan I can't show anything on a cloud object I have no permission to access. Aug 1, 2016 at 13:20
• @MichleJordan That's the way the line should be. Aug 1, 2016 at 13:24
• @Mic, again, the condition number cannot be less than $1$; so setting it to $10^{-4}$ doesn't make any sense. Aug 1, 2016 at 13:28