Benchmark: Savage
09-29-2018, 08:16 AM (This post was last modified: 11-01-2018 08:25 AM by StephenG1CMZ.)
Post: #6
 StephenG1CMZ Senior Member Posts: 1,033 Joined: May 2015
RE: Benchmark: Savage
Version 0.4 adds a Python-syntax-in-CAS implementation.
This corrects the bug in my earlier beta version. Now, the accuracy SEEMS better than PPL, although since less bits are used in CAS floats I presume that is a fluke of these specific calculations (bits: see http://www.hpmuseum.org/forum/thread-11484.html)
The CAS2 procedure is now exported for improved visibility from the Run menu.

Removing the "math" references present in my V0.3Beta significantly improves timings.
Indeed, the Pythonesque timings now seem faster than the PPL version.
Code:
 //Benchmark: Savage   LOCAL CRID:="Savage Benchmark (Prime) V0.4";   //OMITTED: "RAD" in the original:  //User must select Radians  LOCAL AA;  EXPORT SavagePPL()  BEGIN   LOCAL AA;   AA:=1;   FOR I FROM 1 TO 2499 DO     AA:=TAN(ATAN(EXP(LN(√(AA*AA)))))+1   END;   RETURN AA;  END;  MLFOR ()  BEGIN   //LOCAL AA;   RETURN AA:=TAN(ATAN(EXP(LN(√(AA*AA)))))+1;  END;    EXPORT SavageMAKE()  BEGIN   //LOCAL AA;   AA:=1;   MAKELIST(MLFOR(),AA,1,2499);   RETURN AA;  END; #CAS  SavageCAS1(f):=  BEGIN   LOCAL aa;   aa:=1;   FOR I FROM 1 TO 2499 DO     aa:=TAN(ATAN(EXP(LN(√(aa*aa)))))+1   END;   RETURN (aa);  END; def savagepysyn() :    local ii,aa    aa=1    for ii in range(1,2500):      aa= tan(atan(exp(log(sqrt(aa*aa)))))+1 #END  EXPORT SavageCAS2()  BEGIN   LOCAL aa;   aa:=1;   FOR I FROM 1 TO 2499 DO     aa:=CAS(TAN(ATAN(EXP(LN(√(aa*aa))))))+1;   END;   RETURN (aa);  END;  RRR(RR)  //REPORT RESULT,RELATIVE ERROR  BEGIN   RETURN {RR,((2500-RR)/2500)};  END;  //APPROX:  //I FIND NO CLEAR WINNER BETWEEN PPL AND MAKE.  //EXACT:  //I FIND CAS2 CONSISTENTLY FASTER THAN CAS1  EXPORT SAVAGE()  BEGIN   //LOCAL aa;   LOCAL RR;     PRINT();   PRINT(CRID);   PRINT({" PPL1  : ",TEVAL(RR:=SavagePPL()),RRR(RR)});   PRINT({" MAKE  : ",TEVAL(RR:=SavageMAKE()),RRR(RR)});     PRINT({" CAS1  : ",TEVAL(RR:=SavageCAS1("")),RRR(RR)});   PRINT({" CAS2  : ",TEVAL(RR:=SavageCAS2()),RRR(RR)});   PRINT({" PySyn : ",TEVAL(savagepysyn()),RRR(aa)});   PRINT(CRID);  END;
Update: See note regarding Python-in-CAS affecting indexing.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
 « Next Oldest | Next Newest »

 Messages In This Thread Benchmark: Savage - StephenG1CMZ - 12-03-2017, 11:40 PM RE: Benchmark: Savage - StephenG1CMZ - 12-03-2017, 11:42 PM RE: Benchmark: Savage - StephenG1CMZ - 12-05-2017, 10:51 PM RE: Benchmark: Savage - StephenG1CMZ - 08-29-2018, 07:37 AM RE: Benchmark: Savage - StephenG1CMZ - 09-28-2018, 07:20 PM RE: Benchmark: Savage - StephenG1CMZ - 09-29-2018 08:16 AM RE: Benchmark: Savage - Albert Chan - 09-29-2018, 10:47 PM RE: Benchmark: Savage - StephenG1CMZ - 09-30-2018, 07:20 AM RE: Benchmark: Savage - Albert Chan - 09-30-2018, 11:15 AM RE: Benchmark: Savage - Albert Chan - 09-30-2018, 02:13 PM RE: Benchmark: Savage - StephenG1CMZ - 09-30-2018, 04:54 PM RE: Benchmark: Savage - StephenG1CMZ - 10-12-2018, 09:51 AM RE: Benchmark: Savage - StephenG1CMZ - 10-12-2018, 10:46 AM RE: Benchmark: Savage - StephenG1CMZ - 11-01-2018, 08:20 AM

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