@eval function, interesting results any explanation?

Playing with the @eval function just to see if there are any round up/down errors with the high precision. The results were interesting. In each case the answer, namely sin(pi/4)- 2**.5/2 =0. Damn close in many, spot on for others.

rem alias k=set s=%@eval[%$] & echo %@eval[%$]

k 2**.5/2-sin(pi/4)=e1
k 2**.5/2-sin(pi/4)=e2
k 2**.5/2-sin(pi/4)=e3
k 2**.5/2-sin(pi/4)=e4
k 2**.5/2-sin(pi/4)=e5
k 2**.5/2-sin(pi/4)=e6
k 2**.5/2-sin(pi/4)=e7
k 2**.5/2-sin(pi/4)=e8
k 2**.5/2-sin(pi/4)=e9
k 2**.5/2-sin(pi/4)=e10
k 2**.5/2-sin(pi/4)=e11
k 2**.5/2-sin(pi/4)=e12
k 2**.5/2-sin(pi/4)=e13
k 2**.5/2-sin(pi/4)=e14
k 2**.5/2-sin(pi/4)=e15
k 2**.5/2-sin(pi/4)=e16
k 2**.5/2-sin(pi/4)=e17
k 2**.5/2-sin(pi/4)=e18
k 2**.5/2-sin(pi/4)=e19
k 2**.5/2-sin(pi/4)=e20
k 2**.5/2-sin(pi/4)=e21
k 2**.5/2-sin(pi/4)=e22
k 2**.5/2-sin(pi/4)=e23
k 2**.5/2-sin(pi/4)=e24
k 2**.5/2-sin(pi/4)=e25
k 2**.5/2-sin(pi/4)=e26
k 2**.5/2-sin(pi/4)=e27
k 2**.5/2-sin(pi/4)=e28
k 2**.5/2-sin(pi/4)=e29
k 2**.5/2-sin(pi/4)=e30
k 2**.5/2-sin(pi/4)=e31
k 2**.5/2-sin(pi/4)=e32
k 2**.5/2-sin(pi/4)=e33
k 2**.5/2-sin(pi/4)=e34
k 2**.5/2-sin(pi/4)=e35
k 2**.5/2-sin(pi/4)=e36
k 2**.5/2-sin(pi/4)=e37
k 2**.5/2-sin(pi/4)=e38
k 2**.5/2-sin(pi/4)=e39
k 2**.5/2-sin(pi/4)=e40
k 2**.5/2-sin(pi/4)=e41
k 2**.5/2-sin(pi/4)=e42
k 2**.5/2-sin(pi/4)=e43
k 2**.5/2-sin(pi/4)=e44
k 2**.5/2-sin(pi/4)=e45
====================

the results

0.0E+0
5.00E-23
5.000E-24
5.0000E-25
-5.00000E-26
0.000000E+0
0.0000000E+0
0.00000000E+0
-5.000000000E-30
0.0000000000E+0
5.00000000000E-32
0.000000000000E+0
0.0000000000000E+0
5.00000000000000E-35
0.000000000000000E+0
5.0000000000000000E-37
0.00000000000000000E+0
-5.000000000000000000E-39
0.0000000000000000000E+0
5.00000000000000000000E-41
-5.000000000000000000000E-42
0.0000000000000000000000E+0
5.00000000000000000000000E-44
0.000000000000000000000000E+0
-5.0000000000000000000000000E-46
0.00000000000000000000000000E+0
0.000000000000000000000000000E+0
5.0000000000000000000000000000E-49
-5.00000000000000000000000000000E-50
5.000000000000000000000000000000E-51
0.0000000000000000000000000000000E+0
5.00000000000000000000000000000000E-53
-5.000000000000000000000000000000000E-54
-5.0000000000000000000000000000000000E-55
0.00000000000000000000000000000000000E+0
0.000000000000000000000000000000000000E+0
5.0000000000000000000000000000000000000E-58
5.00000000000000000000000000000000000000E-59
0.000000000000000000000000000000000000000E+0
0.0000000000000000000000000000000000000000E+0
-5.00000000000000000000000000000000000000000E-62
0.000000000000000000000000000000000000000000E+0
0.0000000000000000000000000000000000000000000E+0
0.00000000000000000000000000000000000000000000E+0
-5.000000000000000000000000000000000000000000000E-66
 
May 20, 2008
11,437
99
Syracuse, NY, USA
They're certainly accurate enough for me. Any speculation on what's happening below? Using sin() I get exactly 0 every time. With cos() I see behavior similar to what thorntonpg observed.

Code:
v:\> do i=46 to 50 ( echo %@eval[1/2-sin(pi/6)=E%i] )
0.0000000000000000000000000000000000000000000000E+0
0.00000000000000000000000000000000000000000000000E+0
0.000000000000000000000000000000000000000000000000E+0
0.0000000000000000000000000000000000000000000000000E+0
0.00000000000000000000000000000000000000000000000000E+0

v:\> do i=46 to 50 ( echo %@eval[1/2-cos(pi/3)=E%i] )
-1.0000000000000000000000000000000000000000000000E-66
0.00000000000000000000000000000000000000000000000E+0
-1.000000000000000000000000000000000000000000000000E-68
0.0000000000000000000000000000000000000000000000000E+0
-1.00000000000000000000000000000000000000000000000000E-70
 
A do loop is certainly a more elegant way of demonstrating this. I doubt whether real world application makes a great deal of difference, quantum physics perhaps. It is a curiosity though. I found a site with pi to 100,000 decimals. Was going to compare them to pi generated by tcc, first 20,000 anyway.
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Using @PSHELL from @EVAL Support 8
vefatica @EVAL's precision and significant digits Support 10
vefatica @EVAL's internal precision? Support 9
vefatica WAD @EVAL Support 7
vefatica @eval[2**64-1] Support 14
D Syntax error when redirecting eval Support 5
T eval[] crashes with negative binary output Support 1
M erroneous @eval[]? Support 1
vefatica @EVAL, "AND" vs. "&" Support 6
dcantor Problem with @EVAL, TCC12 Support 7
E Problem with @eval[sin(0)] and similar Support 7
timo @eval question Support 3
vefatica Documentation Function parameters Support 0
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
Joe Caverly How to? Get name of current LIBRARY function? Support 4
x13 WeekNum function? Support 3
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
cgunhouse Ctrl-C from within a library function Support 6
C email[string] function Support 10
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
Dick Johnson Using the @instr function Support 5
vefatica '}' in a library function? Support 3
D Can the argument to RETURN be a function expansion? Support 3
J Trouble with @full[] function. Support 3
Fross Quick Function Question Support 17
vefatica Quoting @Function parameters? Support 0
Joe Caverly Debugging a LIBRARY function Support 10
Steve Pitts Documentation @CAPI function summary Support 0
x13 %x$ in function Support 3
x13 Function to get interface user-defined name? Support 10
vefatica Fixed Help @FUNCTION, missing paragraph Support 8
Mordachai Variable followed by function constantly failing... Support 5
nickles Call a complex function Support 13
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
R Function #IDOW returns only 2 characters Support 10
T scrput `` in alias or function Support 2
S International characters - TYPE vs %@LINE function Support 5
JohnQSmith WAD @REPEAT function Support 15
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
A pdir function usage Support 3
nikbackm FUNCTION with variable number of arguments Support 17
S %@REGQUERY function Support 1
Dan Glynhampton Documentation v15 help: Error on @TRIMALL function page Support 0
M Why doesn't this @Field function work? Support 0
fpefpe How to? user function Support 1
M Why is this function getting these results in these circumstances? Support 6
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
M How to? Just verification for what I think I know regarding "Function"... Support 4

Similar threads