Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!cs.umn.edu!uc!noc.MR.NET!gacvx2.gac.edu!hhdist From: CW%APG.PH.UCL.AC.UK@pucc.PRINCETON.EDU Newsgroups: comp.sys.handhelds Subject: LSQ etc... Message-ID: Date: 13 Apr 91 11:31:01 GMT Lines: 84 Return-path: <@pucc.PRINCETON.EDU:CW@APG.PH.UCL.AC.UK> To: HANDHELDS@gac.edu Via: UK.AC.UCL.PH.APG; 13 APR 91 11:28:55 BST APOLOGY: Sorry about sending this to the net but I haven't been able to contactHenrik directly. I t might actually be of use to somebody anyway! Dear Hekrik, I will try to be breif because I'm in a hurry. I'm very happy with your least squares routine LSQ. I have needed one of these ever since I have had my 48sx!!! There is only one thing I think might make it a bit better. Instead of EVAL at a certain point I have used ->NUM (see listing below), this means that algebraics like 'eX' will work in the list (in the eval form a number is not returned by EVAL for algebraics using things like 'e'), and it forces a number to be returned (if possible) whatever the form of the equation. This is in no way a criticism, but rather my experience with the routine (I never use the EXP() form to enter exponentials). Here is the one simple change.... %%HP: T(3)A(R)F(.); \<< \<< IF DUP SIZE SIZE 1 == THEN OBJ\-> 1 SWAP + \->ARRY TRN CONJ END \>> \-> fix \<< IF DUP TYPE 5 \=/ THEN 1 \->LIST END 4 ROLL fix EVAL DUP SIZE OBJ\-> DROP \-> yv fv vv xv r c \<< IF r yv SIZE 1 GET - c vv SIZE - OR THEN "Size(s) mismatch" DOERR END 1 fv SIZE FOR I xv OBJ\-> DROP fv I GET \-> f \<< r 1 FOR J vv OBJ\-> DROP 1 c FOR K c 2 + K - ROLL SWAP STO NEXT f \->NUM J 1 - c * 1 + @CHANGED IT HERE r + J - ROLLD -1 STEP \>> NEXT fv SIZE r 2 \->LIST \->ARRY DUP yv fix EVAL DUP 4 ROLLD * DUP 4 ROLLD SWAP DUP TRN CONJ * / DUP 4 ROLLD TRN CONJ SWAP 3 ROLLD SWAP * OBJ\-> DROP SWAP DUP 1 CON TRN SWAP * OBJ\-> DROP SQ r / SWAP OVER - SWAP yv DUP DOT - NEG / SWAP IF -3 FC? THEN \-> cv \<< 0 1 fv SIZE FOR I cv I 1 2 \->LIST GET fv I GET * + NEXT \>> END \>> \>> \>> Do you think this changes the results in any erroneous way? Thankyou for an excellent routine that I have already found very useful, Conrad