The answer you listed from the web is not correct. It's correct only to
the number of digits listed. The number below is not correct either,
but it's a lot closer.
0j200":(10x^500)%~(<[EMAIL PROTECTED]:)2x*10x^1000
1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993583141322266592750559275579995050115278206057147
Now, after looking at the following I would suspect that if I carried
the square root of two out more places that I would just extend the
string of twos. I can manage to understand that those strange numbers
after the string of twos is just noise.
list cf (10x^500)%~(<[EMAIL PROTECTED]:)2x*10x^1000
1 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 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 59 1 2 5
103 4 1 2 1 19 5 28 1 6 1 6 1
392 1 3 1 7 1 1 1 11 1 8 1 3
1 1 3 3 2 1 2 6 2 1 1 9 1
12 15 4 1 6 1 9 3 15 1 1 9 1
3 2 1 3 2 1 24 2 3 1 2 7 1
5 7 1 2 1 7 1 1 1 5 12 2 1
1 1 5 688 1 4 1 1 7 1 1 5 1
1 1 1 5 1 1 13 2 1 1 6 148 1
1 1 1 1 80 1 2 1 7 2 5 9 1
10 1 1 5 1 2 5 1 29 5 1 5 1
4 4 2 1 1 3 1 1 8 9 13 7 4
11 1 1 2 1 1 1 4 11 1 2 11 2
3 1 3 7 3 1 3 1 5 1 3 2 3
1 44 4 1 3 1 1 5 2 1 1 1 3
22 1 1 2 1 3 1 1 1 3 3 3 1
14 1 1 8 2 2 1 3 2 6 1 1 1
4 3 2 4 3 1 3 2 24 2 1 3 2
3 10 1 5 21 5 5 1 1 1 5 10 3
p j wrote:
">>J has finite memory. Precise representation of an
irrational number using a rational representation
would require infinite memory.
Although it would be great if there was a switch to
get "bignumber" extremely high precision that's not
what I'm requesting here.
I would like a switch that makes J either print the
right digits or no digits at all.
61j59 ": x:!.0 %:2
1.41421356237309536751922678377013653516769409179687500000000
61j59 ": x: %:2
1.41421356237313909704121810319897219048636704119254805757362
from web, real answer
1.4142135623 7309504880 1688724209 6980785696
7187537694
Even with x:!.0 the 15th digit on is crap. At least,
around the 50th digit on gets zero'ed out, so you at
least have a clue that using expansion that high is
not accurate.
Basically I would like a switch that forces J to not
print anything past the 15th digit if it won't be
accurate. If the only benefit is teaching the user
exactly where the lies begin, its a huge gain, as that
beats loading the web and comparing digits side by
side.
From a programming perspective it is very difficult to
debug errors that occur on the 2^64th loop iteration.
--- "Miller, Raul D" <[EMAIL PROTECTED]> wrote:
p j wrote:
The main problem,
cf x: %: 2
1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 45 2 1 2 11 1
3 6
cf x:!.0 %: 2
1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 1 4 2
5 9
3 3 1 11 57 2
Why is this a problem?
J has finite memory. Precise representation of an
irrational number using a rational representation
would require infinite memory.
Which is why we get rational approximations as
results from functions which we think of as
irrational:
%: 2
1.41421
x: %: 2x
431273813145r304956637823
It's also possible to look at the gory internal
details of these numbers.
3!:3 %: 2
e1000000
08000000
01000000
00000000
cd3b7f66
9ea0f63f
%: 2 is represented as an ieee floating point
number.
But, perhaps, the numeric headers are distracting:
hexRepresentation=: (#3!:3 i.0) ,@}. 3!:3@,
hexRepresentation %:2
cd3b7f669ea0f63f
On the other hand:
hexRepresentation x:%:2x
1c0000003c000000e100000004000000030000000100000003000000490c0000d51c0000d8100000e1000000040000000300000001000000030000008f1e00001f160000e90b0000
431273813145r304956637823 is represented using what
looks like a pair of numeric vectors of some sort.
--
Raul
----------------------------------------------------------------------
For information about J forums see
http://www.jsoftware.com/forums.htm
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm