Post Reply 
smallest |cos(x)| ?
10-07-2021, 03:40 PM (This post was last modified: 10-08-2021 06:57 AM by Werner.)
Post: #2
RE: smallest |cos(x)| ?
Quick hack (corrected):

Code:
00 { 145-Byte Prgm }
01▸LBL "EPS"
02 RAD
03 LSTO "X"
04 COS
05 LSTO "Y"
06 1ᴇ-33
07 LSTO "E"
08 LASTX
09 XEQ 14
10 LSTO "X2"
11 COS
12 LSTO "Y2"
13 ABS
14 RCL "Y"
15 ABS
16 X>Y?
17 GTO 10
18 RCL "X"
19 X<> "X2"
20 STO "X"
21 RCL "Y"
22 X<> "Y2"
23 STO "Y"
24 -1
25 STO× "E"
26▸LBL 10
27 RCL "Y"
28 RCL× "Y2"
29 X≤0?
30 GTO 00
31 RCL "X2"
32 STO "X"
33 XEQ 14
34 STO "X2"
35 COS
36 X<> "Y2"
37 STO "Y"
38 GTO 10
39▸LBL 00
40 LASTX
41 ABS
42 RCL "Y2"
43 ABS
44 X<Y?
45 GTO 00
46 RCL "X"
47 RCL "Y"
48 RTN
49▸LBL 00
50 RCL "X2"
51 LASTX
52 RTN
53▸LBL 14
54 ENTER
55 XEQ "MANT"
56 STO÷ ST Y
57 RCL+ "E"
58 ×
59 END

Of course, MANT has been coded long ago, thanks to Dieter:

Code:
00 { 25-Byte Prgm }
01*LBL "MANT"
02 ABS
03 1    @ avoid upper exponent limit. ONLY needed for 9.99999998854e499 < x < 1e500
04 X<Y?
05 10^X
06 /
07 ENTER
08 X#0?
09 LOG
10 INT
11 10^X
12 /
13 1    @ multiply by 10 for x < 1
14 X>Y?
15 10^X
16 *
17 END

Then, the loop, for k=1..10000:
Code:
00 { 84-Byte Prgm }
01▸LBL "ACH"
02 1
03 LSTO "Y"
04 CLX
05 LSTO "X"
06 LSTO "K"
07 LSTO "M"
08▸LBL 02
09 0.5
10 RCL+ "K"
11 PI
12 ×
13 XEQ "EPS"
14 ABS
15 RCL "Y"
16 X≤Y?
17 GTO 00
18 R↓
19 STO "Y"
20 R↓
21 STO "X"
22 RCL "K"
23 STO "M"
24▸LBL 00
25 ISG "K"
26 X<>Y
27 10000
28 RCL "K"
29 X<Y?
30 GTO 02
31 RCL "X"
32 RCL "Y"
33 RCL "M"
34 END

Which yields the smallest value for k=953, being 8.2E-35, for x=2995.508595197867852874130465957006
If I haven't made an error, that is ;-)

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
smallest |cos(x)| ? - Albert Chan - 10-07-2021, 12:14 PM
RE: smallest |cos(x)| ? - Werner - 10-07-2021 03:40 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-07-2021, 06:40 PM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 07:02 AM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 08:17 PM
RE: smallest |cos(x)| ? - ijabbott - 10-09-2021, 01:15 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 02:09 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 05:01 PM
RE: smallest |cos(x)| ? - EdS2 - 10-08-2021, 08:24 AM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 02:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 07:54 PM
RE: smallest |cos(x)| ? - Werner - 10-11-2021, 01:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 04:22 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-10-2021, 01:36 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 10:05 PM



User(s) browsing this thread: 3 Guest(s)