Post Reply 
Python to FOCAL Compiler
10-06-2015, 03:58 PM
Post: #5
RE: Python to FOCAL Compiler
(10-06-2015 11:16 AM)Ángel Martin Wrote:  Dont mean to hijaak this thread but the attached code does the calculation of the mutual inductance example using the SandMath's versions of the eliptic integrals (see lines 28 and 32) - just thought it would be fun to try and sure enough works as advertised.

Hola, Ángel, ¿Qué tal?

Wonderful work Thomas Klemm has done! Alas for me python is just a snake. Basic to FOCAL or Pascal to FOCAL would be great, but who cares about these archaic programming languages (going dead?) nowadays?
I don't mean to hijack this thread either, but since you've talked about elliptic integrals and you appear to be in the mood, what about converting the fast algorithm presented by Hugh Steers here to RPN? I should have done this already, but I left it aside for some reason. Perhaps it might be easier from the BASIC version (it's MSX BASIC, where all variables are double precision by default). The FreePascal version was intended to the RPL conversion, which I haven't done yet either.

Thanks,

Gerson.

Code:

10 CLS
15 INPUT "A, B "; A,B
20 W=A
25 B=B/A: S=(1+B*B)/2: A=1: T=1
30 A1=(A+B)/2
35 IF A=A1 THEN 65
40 C=(A-B)/2
45 B=SQR(A*B)
50 A=A1
55 S=S-T*C*C: T=T+T
60 GOTO 30
65 PI=4*ATN(1)
70 PRINT 2*W*PI*S/A

Code:

Program Ellipse;                                                               
 Uses Crt;                                                                      
 const PI = 3.14159265358979324;                                                
 var a, a1, b, c, s, t, w: double;                                              
 begin                                                                          
   ClrScr;                                                                      
   Write('a b: ');                                                              
   ReadLn(a, b);                                                                
   w := a;                                                                      
   b := b/a;                                                                    
   s := (1 + b*b)/2;                                                            
   a := 1;                                                                      
   t := 1;                                                                      
   repeat                                                                       
     a1 := (a + b)/2;                                                           
     c := (a - b)/2;                                                            
     b := Sqrt(a*b);                                                            
     a := a1;                                                                   
     s := s - t*c*c;                                                            
     t := t + t                                                                 
   until c = 0;
   WriteLn(2*w*PI*s/a:22:16);                                                   
   ReadKey;                                                                     
 end.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Python to FOCAL Compiler - Thomas Klemm - 10-05-2015, 10:58 PM
RE: Python to FOCAL Compiler - Sukiari - 10-06-2015, 03:36 AM
RE: Python to FOCAL Compiler - Gerson W. Barbosa - 10-06-2015 03:58 PM
Java to FOCAL Compiler - Thomas Klemm - 10-07-2015, 04:38 PM



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