Post Reply 
Perimeter of Ellipse
12-04-2019, 05:30 PM
Post: #11
RE: Perimeter of Ellipse
(03-24-2019 12:42 PM)Albert Chan Wrote:  From HP Forum Archive 21, message 5, and some optimizations, I get:

Quote:local sqrt, pi = math.sqrt, math.pi

function ellipsePerimeter(a, b) -- agm2 method
    local s = 0.5 * (a*a+b*b)
    local t = 0.25
    while true do
        local k = b - a
        local s1 = s - t*k*k
        if s == s1 then return 2*pi*s/(a+0.5*k) end
        b = sqrt(a*b)
        a = a + 0.5*k
        s = s1
        t = t + t
    end
end

Example:

lua> ellipsePerimeter(1, 2) --> 9.688448220547675
lua> ellipsePerimeter(2, 3) --> 15.86543958929059
lua> ellipsePerimeter(3, 4) --> 22.103492160709504

On Free42 using Hugh Steers’s original algorithm I get

1 ENTER 2 XEQ PEL -> 9.688448220547676198428503196391833

2 ENTER 3 XEQ PEL -> 15.86543958929058979133166302778308

3 ENTER 4 XEQ PEL -> 22.10349216070950504528558646387247

Code:


00 { 75-Byte Prgm }
01▸LBL "PEL"
02 RCL÷ ST Y
03 RCL ST X
04 X↑2
05 1
06 STO 01
07 STO 02
08 +
09 2
10 ÷
11 STO 03
12 SIGN
13▸LBL 00
14 RCL+ ST Y
15 2
16 ÷
17 X<> 02
18 RCL 02
19 X=Y?
20 GTO 01
21 R↓
22 RCL× ST Y
23 LASTX
24 X<>Y
25 SQRT
26 X<> ST Z
27 -
28 2
29 ÷
30 X↑2
31 RCL× 01
32 STO- 03
33 R↓
34 2
35 STO× 01
36 CLX
37 RCL 02
38 GTO 00
39▸LBL 01
40 STO÷ 03
41 R↑
42 PI
43 ×
44 STO+ ST X
45 RCL× 03
46 END

On the wp34s, for low-eccentricity ellipses, the following approximation might be handy, since no programming is required:

2\(\pi\)[3*agm(a,b) - 2√(a*b)]

The error in the lenght of the orbit of Pluto should be less than 5 meters when using that approximation, if my calculation is correct.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Perimeter of Ellipse - Joe Horn - 03-05-2016, 04:19 PM
RE: Perimeter of Ellipse - Wes Loewer - 03-06-2016, 11:55 AM
RE: Perimeter of Ellipse - Wes Loewer - 03-06-2016, 02:16 PM
RE: Perimeter of Ellipse - Joe Horn - 03-07-2016, 03:34 PM
RE: Perimeter of Ellipse - ggauny@live.fr - 07-11-2019, 05:02 PM
RE: Perimeter of Ellipse - TASP - 03-06-2016, 02:40 PM
RE: Perimeter of Ellipse - parisse - 03-06-2016, 06:42 PM
RE: Perimeter of Ellipse - SlideRule - 03-07-2016, 01:16 PM
RE: Perimeter of Ellipse - parisse - 03-09-2016, 08:39 AM
RE: Perimeter of Ellipse - Albert Chan - 03-24-2019, 12:42 PM
RE: Perimeter of Ellipse - Gerson W. Barbosa - 12-04-2019 05:30 PM
RE: Perimeter of Ellipse - Albert Chan - 01-19-2020, 03:56 AM
RE: Perimeter of Ellipse - Albert Chan - 01-19-2020, 11:00 PM
RE: Perimeter of Ellipse - Albert Chan - 01-21-2020, 05:16 PM
RE: Perimeter of Ellipse - Albert Chan - 01-23-2020, 01:40 PM
RE: Perimeter of Ellipse - Albert Chan - 06-05-2020, 03:28 AM
RE: Perimeter of Ellipse - Albert Chan - 08-01-2020, 12:31 PM
RE: Perimeter of Ellipse - Albert Chan - 06-06-2020, 05:12 PM
RE: Perimeter of Ellipse - hazem - 04-11-2023, 09:43 PM
RE: Perimeter of Ellipse - rprosperi - 04-12-2023, 01:53 AM
RE: Perimeter of Ellipse - hazem - 04-13-2023, 02:06 PM
RE: Perimeter of Ellipse - floppy - 04-13-2023, 02:20 PM
RE: Perimeter of Ellipse - Werner - 04-12-2023, 05:43 AM
RE: Perimeter of Ellipse - rprosperi - 04-12-2023, 12:44 PM
RE: Perimeter of Ellipse - floppy - 04-12-2023, 07:22 PM
RE: Perimeter of Ellipse - Albert Chan - 04-13-2023, 05:23 PM
RE: Perimeter of Ellipse - floppy - 04-15-2023, 06:21 PM



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