6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 10:06 am

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Wed Oct 03, 2012 9:14 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Quote:
I had formed the impression that a sine table
with quadratic interpolation is generally faster
and less resource-intensive than CORDIC
(but I never really compared the two myself)

The tables I supply don't need any interpolation, since there are 65,536 entries of 16 bits each, meaning most tables are 128KB; so a 16-bit input number gives a 16-bit output that is as accurate as 16 bits allows. Tables can be made for any function, not just trig functions.

Quote:
There's also series expansion:

Sin(z) = z - (z^3/3!) + (z^5/5!) - (z^7/7!) ...

I think you need about four terms to get 16 bits
(actually more like 20 bits)

Four is enough if you tweak the coefficients to make up. The sin & cos routines I had written in Forth only use four terms, and I experimented with the coefficients and got it such that the answer is usually correct in all bits, and in the few times it's not correct, it was only one lsb high. It's possible I did not arrive at the best set of coefficients.

My tables were not calculated this way though. For those, I used an HP hand-held computer that does it in 15 decimal digits, and rounded to the nearest answer representable in 16 bits.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 05, 2012 12:56 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
When multiplication is cheap (as on an FPGA) the polynomial methods become quite respectable. Cody & Waite's "Software Manual For The Elementary Functions" is, I think, a standard reference. There's a technique by Padé which is better than truncating power series (edit: but it costs a division, which is not so cheap as a multiplication)
(I thought this is what later versions of BBC BASIC use, but this annotated disassembly suggests "continued-fraction expansion series" - the base routine being here and called for example by the ArcTan routine.

Edit: some coefficients from Cody and Waite are tabulated here


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 05, 2012 1:13 pm 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
Another good source of trig function algorithms is Jack Crenshaw's book for real-time embedded systems. If I recall correctly, they are based on Tschebychef (some letters may be swapped without loss of significance) polynomials. I have it around here somewhere, but it's not exactly at hand.

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 05, 2012 2:40 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Quote:
(edit: but it costs a division, which is not so cheap as a multiplication)

My set of look-up tables includes a 256KB table of inverses for that reason-- you can multiply by the inverse. The table has 32-bit inverses of all 16-bit unsigned numbers, so there's at least 16-bit resolution and accuracy even at the ends. If you can just look up the function though, there's no need to multiply or divide to get it.

Quote:
Another good source of trig function algorithms is Jack Crenshaw's book for real-time embedded systems. If I recall correctly, they are based on Tschebychef (some letters may be swapped without loss of significance) polynomials. I have it around here somewhere, but it's not exactly at hand.

That's the one we discussed at viewtopic.php?f=2&t=1971. I have since gotten it in the paper version. (Actually our new computer-science daughter-in-law got it for me.)

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: