Post Reply 
Benchmark: Savage
09-28-2018, 07:20 PM (This post was last modified: 11-01-2018 02:36 PM by StephenG1CMZ.)
Post: #5
RE: Benchmark: Savage
Version 0.3 Beta adds an implementation of the Savage benchmark using Python-syntax-in-CAS.

That specific implementation is less accurate than the PPL version, hence the Beta release in case I have mis-coded something.
Other timings should be unaffected.

Code:

//Benchmark: Savage 
 LOCAL CRID:="Savage Benchmark (Prime) V0.3 Beta"; 
 //Beta in respect of Pythonesque results

 //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,2499):
     #aa= tan(atan(exp(math.log(sqrt(aa*aa)))))+1
     aa= math.tan(math.atan(math.exp(math.log(math.sqrt(aa*aa)))))+1

#END

 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: Accuracy in Python solved...I had the range wrong...Corrected v0.4 follows.
Note that the Python-in-CAS code can affect indexing.

Stephen Lewkowicz (G1CMZ)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


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)