Writing Trig Functions in x-BaseDate: 24 May 95 21:40:06 From: Anonymous Subject: Writing Trig Functions in x-Base I must write trig functions (sin(), cos(), etc) in xBase code as part of a project that I am working on (navigation bearing and distance calculations). I am aware that dBase itself includes trig functions, but for this project I must use a specific xBase implementation which doesn't include the necessary functions. Could you recommend any good reference books for this? An algorithmic approach would be preferred as it would be easier to convert into actual programming code. However, a mathematical approach would be acceptable too. Of course, if this request is considered trivial enough, please feel free to provide actual algorithms instead. Any assistance would be very much appreciated. Thank you. Andy Cornell, acorne1@ibm.net Date: 9 Jun 1995 10:53:11 -0400 From: Dr. Ken Subject: Writing Trig Functions in x-Base Hello there! I'm sorry it has taken us so long to get back to you on this. I don't know a whole lot about xBase, but if I were you, I'd probably be inclined to try the Taylor expansion for the trig functions, as long as the angles you're going to plug in to the functions don't get too far from your basepoint. For instance, if your angle is pretty close to zero, you could have your program use the approximation x - x^3/6 + x^5/120 for Sine. The approximation will stop being very good once you get outside the interval (-Pi/8, Pi/8), so outside that you'd probably want to use the Taylor expansion around a different base point like Pi/4 or something. You can do the same thing for Cosine, and then you can write the remaining trig functions in terms of Sin and Cosine, or you can use the Taylor expansions of the other functions. If efficiency and accuracy are important in your program, you'll probably want to use the Taylor expansion of each function rather than writing everything in terms of Sine and Cosine. If you need more help in actually figuring out the Taylor expansions, let us know. -K |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/