Bug in MATH ROM of the TI95

03082023, 07:46 PM
(This post was last modified: 03082023 11:08 PM by Namir.)
Post: #1




Bug in MATH ROM of the TI95
I have been tinkering with the TI95 and its MATH and STAT ROMs. I discovered that the Newtons Root method (option NTN in option ZRO) has a bug that causes the solution FOR ANY FUNCTION to jump to huge numbers and then overflow. I tested my fx(x)=exp(x)3*x^2 and fx(x)=x^25*x+6 functions and both bombed out. I inserted a pause (PAU) command in my function code to trace the values used by NTN and found that it does the following:
1) Evaluate fx at you initial guess (call it X). 2) Evaluate fx at X plus a small increment. 3) Evaluate fx at X minus a small increment. 4) Evaluate fx at a large number. 5) Repeat step 4 with different large numbers until the calculations overflow. I also noticed that the TI95 emulator by HrastProgrammer has the same bug in his port of the MATH ROM! I guess his ported the binary image of the MATH ROM. Anyone else out there has seen this bug? The Bisection method in the MATH ROM works fine! Namir 

03092023, 02:57 PM
Post: #2




RE: Bug in MATH ROM of the TI95
Weird! The ROM listing is available here via the "TI95 Mathematics Module" link if anybody wants to reverse engineer what's going on:
http://www.rskey.org/CMS/index.php/thelibrary/12 

03092023, 06:30 PM
(This post was last modified: 03092023 06:54 PM by Thomas Klemm.)
Post: #3




RE: Bug in MATH ROM of the TI95
Based on the source code of NTN starting at line 683A I wrote these functions in Python:
Code: from math import exp, hypot This is the mapping of the variables to the registers:
Examples \( \begin{align} f(x) &= e^x  3x^2 \\ x &= 0.458962 \\ x &= 0.910008 \\ x &= 3.73308 \\ \end{align} \) Code: ntn(f, 1, 1e10, 10) 0.45896226753694863 Code: ntn(f, 1, 1e10, 10) 0.9100075724887092 Code: ntn(f, 4, 1e10, 10) 3.7330790286328144 \( \begin{align} g(x) &= x^2  5 x + 6 \\ x &= 2 \\ x &= 3 \\ \end{align} \) Code: ntn(g, 0, 1e10, 10) 1.9999999999942588 Code: ntn(g, 4, 1e10, 10) 3.0000000000000013 To me the implementation in the MATH ROM looks solid. However, I was able to get nonsensical results if the starting value was close to a critical point where the derivative is 0. Examples Code: ntn(f, 2.833, 1e10, 5) #it REACHED 271.9295080855029 Code: ntn(g, 2.5, 1e10, 10) #it REACHED 2746.2796055906856 Though I haven't tried it in an emulator, I assume that both the accuracy \(\delta\) and the maximal number of iterations \(n\) have to be stored in registers 0009 and 0010 respectively. Also if the value in register 0010 is 0, the default value 10 is used instead. Maybe you can check if the value in register 0009 is not 0? It should be a fairly small value, like maybe \(10^{5}\). But I'm not sure if that helps. 

03102023, 12:16 PM
(This post was last modified: 03102023 12:17 PM by Namir.)
Post: #4




RE: Bug in MATH ROM of the TI95
Thanks Thomas.
I used the PoketEmul simulator on my iPhone torun the TI95 emulator and loaeded the MATH rom. I GOT THE SAME OVERFLOW ERROR WITH THE NEWTON METHOD! My conclusion is that while the listing you provided me is correct (and the Python code your provided runs correctly), there may be a last minute bug introduced in the ROM (kind of remind us with the last minute code change for the HP15LE firmware that caused the famous and annoying PAUSE bug!). I recieved another MATH rom pack yesterday. So I will test that ROM on my TI95. Namir 

03102023, 01:13 PM
Post: #5




RE: Bug in MATH ROM of the TI95
I used the TI95E MicroCode Emulator by HrastProgrammer and followed the instructions of the TI95 MATHEMATICS LIBRARY GUIDE BOOK to create the following programm:
Code: LBL fx ( RCL A INV LN 3* RCL A x^2 ) RTN I've set: x0 = 1 err = 1EE5 #it = 10 And then got the following result: It also works for the other initial values. 

03102023, 02:07 PM
Post: #6




RE: Bug in MATH ROM of the TI95
Thank you Thomas for solving the riddle. I was NOT enclosing the expression for fx in parentheses!! When I coded fx like you did on the TI95 emulator and a real TI95, it worked in both cases!!!
Thank you for helping solve the mystery!!! Namir 

« Next Oldest  Next Newest »

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