nkeck72
Member
Some talk about the speed of math functions in Commodore BASIC in another thread inspired me to write a quick-and-dirty implementation of the calculus concept of Newton's method in QBASIC as a sort of benchmark for DOS PCs this morning. If you're not familiar, Newton's method is an algorithmic method for estimating zeroes (where a graph crosses the x-axis), and requires a guess as to where this occurs. The definition of this method is:
x[SUB]n+1[/SUB]=x[SUB]n[/SUB]-(f(x[SUB]n[/SUB])/f'(x[SUB]n[/SUB]))
where f(x) is the function you wish to find the zero of, x[SUB]n[/SUB] is the current guess, x[SUB]n+1[/SUB] is the calculated next guess, and f'(x) is the derivative of f(x).
Feel free to try it out and report back. This is by no means a good example of BASIC or QBASIC code and could probably use some optimization and cleanup, I only wrote this in about an hour or so. Everything uses double-precision internally to prevent precision loss so I'd be interested in particular to see the differences with and without an FPU installed.
Full disclosure, I wrote this in Windows 98 so I don't know how well this will run on a pre-286. YMMV. Feel free to direct me to another forum category if QBASIC doesn't run on a < 386.
x[SUB]n+1[/SUB]=x[SUB]n[/SUB]-(f(x[SUB]n[/SUB])/f'(x[SUB]n[/SUB]))
where f(x) is the function you wish to find the zero of, x[SUB]n[/SUB] is the current guess, x[SUB]n+1[/SUB] is the calculated next guess, and f'(x) is the derivative of f(x).
Feel free to try it out and report back. This is by no means a good example of BASIC or QBASIC code and could probably use some optimization and cleanup, I only wrote this in about an hour or so. Everything uses double-precision internally to prevent precision loss so I'd be interested in particular to see the differences with and without an FPU installed.
Full disclosure, I wrote this in Windows 98 so I don't know how well this will run on a pre-286. YMMV. Feel free to direct me to another forum category if QBASIC doesn't run on a < 386.