Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s)
|
01-14-2020, 05:23 PM
(This post was last modified: 01-15-2020 12:17 AM by Gerson W. Barbosa.)
Post: #7
|
|||
|
|||
RE: Hypergeometric function – Perimeter of an Ellipse and other applications (wp34s)
Here is still another approximation to the perimeter of the ellipse:
p ≈ 2π[(aˢ + bˢ)/2]¹ᐟˢ where s = 3/2 + 1/(32/h² - ⅗h² - 4) and where h = [(a - b)/(a + b)] That’s Thomas Muir’s approximation, I’ve only added an empirical correction term to his s = 3/2 parameter. The precision quite matches that of Ramanujan’s second approximation, the results being slightly above or below depending on the h parameter. In the case of the orbit of Halley’s comet, for instance, the absolute value of the difference is about three times less: 920.378 km. That’s about the flight distance from Warsaw to Stuttgart. The wp34s program should be smaller (I’ll see to that later), but for convenience I will shift to Free42: 00 { 61-Byte Prgm } 01▸LBL "MB" 02 COMPLEX 03 ENTER 04 COMPLEX 05 ENTER 06 X<> ST Z 07 STO- ST Z 08 + 09 ÷ 10 X↑2 11 32 12 X<>Y 13 ÷ 14 0.6 15 RCL× ST L 16 - 17 4 18 - 19 1/X 20 1.5 21 + 22 X<>Y 23 COMPLEX 24 RCL ST Z 25 Y↑X 26 X<>Y 27 LASTX 28 Y↑X 29 + 30 2 31 ÷ 32 X<>Y 33 1/X 34 Y↑X 35 STO+ ST X 36 PI 37 × 38 END Examples: 9 ENTER 8 XEQ MB -> 53.45328500297186507413258774441006 2 ENTER 3 XEQ MB -> 15.86543958923382742479398274914387 4 ENTER 1 XEQ MB -> 17.15684512619729903456675762188867 For exact results, use the ELP and 2F1 programs below, the latter copied and pasted from Jean-Marc Baillard in the Old HP-41C Software Library 00 { 38-Byte Prgm } 01▸LBL "ELP" 02 RCL- ST Y 03 X<>Y 04 RCL+ ST L 05 STO 04 06 ÷ 07 X↑2 08 -0.5 09 RCL ST X 10 1 11 R↑ 12 XEQ " 2F1" 13 RCL× 04 14 PI 15 × 16 END 00 { 58-Byte Prgm } 01▸LBL " 2F1" 02 STO "Z" 03 R↓ 04 STO 03 05 R↓ 06 STO 02 07 R↓ 08 STO 01 09 CLST 10 SIGN 11 ENTER 12 ENTER 13▸LBL 01 14 R↓ 15 X<>Y 16 RCL 01 17 R↑ 18 STO+ ST Y 19 R↓ 20 × 21 RCL 02 22 R↑ 23 STO+ ST Y 24 R↓ 25 × 26 RCL 03 27 R↑ 28 STO+ ST Y 29 ISG ST X 30 CLX 31 STO× ST Y 32 R↓ 33 ÷ 34 RCL× "Z" 35 STO ST Z 36 X<>Y 37 STO+ ST Y 38 X≠Y? 39 GTO 01 40 END ——- PS: 01-15-2020, 00:17 AM wp34s 001:LBL A 002:©ENTER 003:STO- Y 004:RCL+ T 005:/ 006:x² 007:# 032 008:x⇆ Y 009:/ 010:# 003 011:RCL× L 012:SDR 001 013:STO+ X 014:- 015:# 004 016:- 017:1/x 018:# 015 019:SDR 001 020:+ 021:yᵡ 022:x⇆ Y 023:RCL L 024:yᵡ 025:STO+ Y 026:x⇆ L 027:# 002 028:STO/ Z 029:R↓ 030:ᵡ√y 031:STO+ X 032:# π 033:× 034:END If a = b, that is, when h = 0, the program will return “+∞ Error” (“Divide by 0” on the HP-42S). If this is an issue, just test for a = b in the beginning of the program and jump to current line # 31 if true. Or use this equivalent expression for s: s = [h²(9h² + 50) - 480]/[h²(6h² + 40) - 320] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)