0
$\begingroup$

(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?

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

1 Answer 1

2
$\begingroup$

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 .

$\endgroup$
9
  • $\begingroup$ ...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: LinearAlgebra`MatrixConditionNumber[mat] gives the result 36250.4, which is why I chose that particular matrix. $\endgroup$ Aug 1, 2016 at 13:12
  • $\begingroup$ @MichleJordan lines three and four, a - before the 4, $\endgroup$
    – Feyre
    Aug 1, 2016 at 13:18
  • $\begingroup$ @MichleJordan I can't show anything on a cloud object I have no permission to access. $\endgroup$
    – Feyre
    Aug 1, 2016 at 13:20
  • $\begingroup$ @MichleJordan That's the way the line should be. $\endgroup$
    – Feyre
    Aug 1, 2016 at 13:24
  • 1
    $\begingroup$ @Mic, again, the condition number cannot be less than $1$; so setting it to $10^{-4}$ doesn't make any sense. $\endgroup$ Aug 1, 2016 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.