Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s)
01-18-2020, 03:41 PM (This post was last modified: 01-19-2020 02:09 AM by Gerson W. Barbosa.)
Post: #13
 Gerson W. Barbosa Senior Member Posts: 1,429 Joined: Dec 2013
RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s)
(01-18-2020 10:25 AM)grsbanks Wrote:  Could you enclose your listings in "code" tags? It makes the whole post shorter and tidier.

As you please, but you’ll have to scroll down to see the new HP-42S/Free42 version is now 36 steps long, LBL and END included :-)

Code:
 00 { 73-Byte Prgm } 01▸LBL "EL" 02 RCL- ST Y 03 X<>Y 04 RCL+ ST L 05 STO 01 06 ÷ 07 X↑2 08 ENTER 09 ENTER 10 ENTER 11 7 12 × 13 544 14 - 15 × 16 3328 17 + 18 × 19 4096 20 - 21 STO÷ 01 22 R↓ 23 -93 24 × 25 224 26 + 27 × 28 2304 29 + 30 × 31 4096 32 - 33 RCL× 01 34 PI 35 × 36 END

The corresponding wp34s version is 41 steps longs – too many constants, remove a few and it will be perfect! :-)
Perhaps someone has a trick to save a step or two...

wp34s version:

Code:
 001:LBL A 002:⇆ XYYY 003:STO+ Y 004:©- 005:RCL/ I 006:x² 007:FILL 008:# 007 009:× 010:# 032 011:STO J 012:# 017 013:× 014:-   015:×   016:# 104 017:RCL× J 018:+ 019:× 020:# 128 021:RCL× J 022:- 023:STO/ I 024:R↓ 025:# 007 026:RCL× J 027:# 093 028:RCL× Z 029:- 030:× 031:# 072 032:RCL× J 033:+ 034:× 035:# 128 036:RCL× J 037:- 038:RCL× I 039:# π  040:× 041:END

p ≈ π(a + b){h²[h²(-93h² + 224) + 2304] - 4096}/{h²[h²(7h² - 544) + 3328] - 4096}

where

h = [(a - b)/(a + b)]

Thanks for your suggestion. This indeed looks cleaner now.

Edited after saving one step in the wp34s program.

PS:

1) The wp34s program can fit in 40 steps, including LBL and END;

2) The following is even more accurate, giving an error of only 116.385 km for our usual example – that’s about the distance from Milan to Parma.

p ≈ π(a + b){h²[h²(-381h² + 548) + 8448] - 13312}/{h²[h²(34h² - 2188) + 11776] - 13312}

Same number of steps on Free42/HP-42S, taking up a few more bytes.

Code:
 00 { 79-Byte Prgm } 01▸LBL "EL" 02 RCL- ST Y 03 X<>Y 04 RCL+ ST L 05 STO 01 06 ÷ 07 X↑2 08 ENTER 09 ENTER 10 ENTER 11 34 12 × 13 2188 14 - 15 × 16 11776 17 + 18 × 19 13312 20 - 21 STO÷ 01 22 R↓ 23 -381 24 × 25 548 26 + 27 × 28 8448 29 + 30 × 31 13312 32 - 33 RCL× 01 34 PI 35 × 36 END
 « Next Oldest | Next Newest »

 Messages In This Thread Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 12-10-2019, 11:50 PM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Paul Dale - 12-11-2019, 01:47 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 12-13-2019, 04:08 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Ángel Martin - 01-29-2020, 11:44 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Paul Dale - 12-13-2019, 05:04 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 12-13-2019, 05:16 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-11-2020, 01:20 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-14-2020, 05:23 PM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Albert Chan - 01-14-2020, 11:47 PM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-15-2020, 12:59 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-16-2020, 04:18 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-18-2020, 01:14 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - grsbanks - 01-18-2020, 10:25 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-18-2020 03:41 PM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-21-2020, 09:01 PM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 01-25-2020, 02:53 AM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Paul Dale - 01-29-2020, 12:29 PM RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s) - Gerson W. Barbosa - 02-08-2020, 11:17 PM

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