Post Reply 
Can my CAS Savage benchmark be improved? CAS newbie
04-03-2017, 02:44 PM (This post was last modified: 12-04-2017 08:11 AM by StephenG1CMZ.)
Post: #1
Can my CAS Savage benchmark be improved? CAS newbie
When I first got my HP Prime, I implemented the Savage benchmark and then unsuccessfully tried to implement it in CAS, but never got to see the perfect 2500 result...
I was busy learning about my new Prime rather than the CAS, and somewhat put off further experimentation by the corruption referred to in this old thread - I didn't want to risk my new toy Smile: (the corruption referred to is long gone).

http://www.hpmuseum.org/forum/thread-195...ght=savage

I've just tried again and now see the perfect 2500 result, but wonder if the time can be improved.

Corrected code: (updated. To fix bad syntax)

Code:

SAVAGED()
 BEGIN
  A:=1;
  FOR I FROM 1 TO 2499 DO
    A:=TAN(ATAN(e^(LN(√(A*A)))))+1
  END;
 END;

#CAS
SAVAGEDCAS1(f):=
 BEGIN
  A:=1;
  FOR I FROM 1 TO 2499 DO
    A:=TAN(ATAN(e^(LN(√(A*A)))))+1
  END;
  RETURN (A);
 END;
#END

SAVAGEDCAS2()
 BEGIN
  A:=1;
  FOR I FROM 1 TO 2499 DO
    A:=CAS(TAN(ATAN(e^(LN(√(A*A))))))+1;
    //RECT_P();
    //TEXTOUT_P(A,0,100)
  END;
  //WAIT;
  RETURN A;
 END;

EXPORT SAVAGE()
 BEGIN
  LOCAL RR;
  PRINT();
  PRINT({"Prime: ",TEVAL(RR:=SAVAGED()),RR});
  PRINT({" CAS1 : ",TEVAL(RR:=SAVAGEDCAS1("")),RR});
 
  PRINT({" CAS2 : ",TEVAL(RR:=SAVAGEDCAS2()),RR});
 //RETURN {TEVAL(RR:=SAVAGED()),RR,TEVAL(RR:=SAVAGEDCAS()),RR};
 END;

My working code (CAS2) runs a FOR loop repeatedly calling CAS and I thought that taking the CAS out of the FOR loop ought to speed things up.

But my #CAS (CAS1) version is consistently slower.

I haven't used #CAS much yet, so I'm probably not doing it right.
Can #CAS1 be made faster than CAS2?

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Can my CAS Savage benchmark be improved? CAS newbie - StephenG1CMZ - 04-03-2017 02:44 PM



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