Group Abstract Group Abstract

Message Boards Message Boards

Code for verification of reliable digits ?

Posted 9 years ago
POSTED BY: Dr Muh Nikson
8 Replies
Posted 9 years ago

I got it, except your last statement "there are at most one digit or so correct." would you please wrote more simpler?

Thanks so much Teacher :)

POSTED BY: Dr Muh Nikson
Posted 9 years ago
POSTED BY: Dr Muh Nikson

The solution components all have size around 1. The norm of the error is also around 1. That gives some indication that there are at most one digit or so correct.

POSTED BY: Daniel Lichtblau
Posted 9 years ago

Thanks so much, very nice.

We have one approximation solution:

Out[53]= {1.01850881228, 0.783151176337, 1.53552721482, 0.645697515412}

with this code:

In[54]:= diff = approxsol - sol

we get a vector with difference between the solution with approximation solution.

but I couldn't get this code:

In[55]:= Norm[diff]
POSTED BY: Dr Muh Nikson
Posted 9 years ago

Were you not asking about $\|x^\ast-\bar{x}\|$? Norm[x]is just the Mathematica expression for $\|\mathtt x\|$.

POSTED BY: J. M.

Well, you could just print the intermediate results. That might make clear what are the vectors in use and what that norm is from.

In[53]:= approxsol = LinearSolve[mat, bv]

Out[53]= {1.01850881228, 0.783151176337, 1.53552721482, 0.645697515412}

In[54]:= diff = approxsol - sol

Out[54]= {0.0185088122791, -0.216848823663, 0.53552721482, \
-0.354302484588}

In[55]:= Norm[diff]

Out[55]= 0.678001207119

Numerically this is garbage anyway because the use of Round has made alterations a few digits in that, based on the conditioning, really should throw the result away from sol. To avoid this one might instead do as below.

mat = N[hm, 5]
bv = N[hm.sol, 5]

(* Out[56]= {{1.0000, 0.50000, 0.33333, 0.25000}, {0.50000, 0.33333, 
  0.25000, 0.20000}, {0.33333, 0.25000, 0.20000, 0.16667}, {0.25000, 
  0.20000, 0.16667, 0.14286}}

Out[57]= {2.0833, 1.2833, 0.95000, 0.75952} *)

approxsol = LinearSolve[mat, bv]

(* Out[47]= {1.0000, 1.0000, 1.000, 1.0000} *)

I should mention that, as on Mathematica.stackexchange.com, I was unable to make any sense of the initial paragraph in this query. Also it would be helpful to provide a link when cross-posting essentially the same query from a different forum.

POSTED BY: Daniel Lichtblau
Posted 9 years ago

"Numerically this is garbage anyway" - yes, that was the way of showing "the reliable digits... for solutions of this system of equation is 0". That was also why a matrix whose condition number is on the order of $10^4$ was chosen for that demo. (Otherwise, Norm[diff] should have been much tinier.)

(That is, assuming I had correctly divined the exercise's intent. But I really was hoping the kid had concluded for himself how far away the result from zero was.)

POSTED BY: J. M.

Probably you are right about the purpose of that forced rounding.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard