The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Writing Trig Functions in x-Base

Date: 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,

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

Associated Topics:
College Trigonometry

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.