Post Reply 
Perimeter of Ellipse
12-05-2019, 03:17 PM
Post: #14
RE: Perimeter of Ellipse
This is an equivalent Decimal BASIC program of a C-program by Hugh Steers here. The port of this one or the original C-program to the Prime should be straightforward. The computational effort is a fraction of that involved in the computation of the elliptic integral, but that may not make a significant difference in fast calculators like the Prime.

OPTION ARITHMETIC DECIMAL_HIGH
INPUT  PROMPT "a, b: ":ae,be
LET nd = 1000
LET tm = TIME 
LET b = be/ae
LET s = (1 + b*b)/2
LET a = 1 
LET t = 1
DO
   LET a1 = (a + b)/2
   IF a = a1 THEN EXIT DO
   LET c = (a - b)/2
   LET b = SQR(a*b)
   LET a = a1
   LET s = s - t*c*c
   LET t = t + t
LOOP
LET p = 2*PI*ae*s/a
LET r = TIME - tm
LET r$ = STR$(p - INT(p))                           
PRINT
PRINT STR$(INT(p));
PRINT r$(0:1);
FOR i = 2 TO nd + 1
   PRINT r$(i:i);
   IF MOD((i - 1),10) = 0 THEN PRINT " ";
   IF MOD((i - 1),50) = 0 THEN 
      PRINT
      PRINT REPEAT$(" ",1 + LEN(STR$(INT(p))));
   END IF
NEXT i
IF MOD (i - 2,50) <> 0  OR nd = 0 THEN PRINT
PRINT 
PRINT "Runtime: ";
PRINT  USING "0.##": r;
PRINT " seconds"
END


---------------


a, b: 3,4

22.1034921607 0950504528 5586463872 4607782782 8910007059 
   3992632612 5910396946 4959177286 6218309324 0390352083 
   5815953162 7467734138 2129000335 3896736622 8442994174 
   6192287204 5014970302 5317033312 3929977604 0095275908 
   3220930141 4469558250 9419563787 3762863238 9667370976 
   2571981363 4931419230 9352895844 1906042118 2907229022 
   9686418117 2635887950 2052296943 0126681600 8830044762 
   7954774028 4076289798 3279618691 9046286983 5594397451 
   2356208773 7408645009 3309824766 6784863302 2726732463 
   0516083153 4972329406 0801844377 6345370790 6974256179 
   0156140823 0342896177 6736816934 6443281912 6179659392 
   2331855348 5127216985 8740979075 6632664289 7373983969 
   0524635361 8083080355 2201668145 2949128953 8470111771 
   1967401421 1827316426 8227257828 0215582400 2244838587 
   9322889687 7768410992 9363265305 7955533884 5140145875 
   1572214188 4766228802 8889719384 4198561575 6084702523 
   4710513780 8869298904 8167827143 0007524734 3709238837 
   9951007032 1404352133 5658034012 3750989012 2020953649 
   3147176616 2140936028 0496095218 3637964950 6346311041 
   3538836238 7660229689 7814732208 7377779791 016495137 
   
Runtime: 0.05 seconds
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 - 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 - Gerson W. Barbosa - 12-05-2019 03:17 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: 1 Guest(s)