Title: How do I approach programming
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER

How Do I Approach Programming

In this unit we are going to come up with a way to mathematically compute the Sine function. A description of the algorithm is shown below under the "Sine Calculation" label.

Click on the following link to see how to solve this problem:
Jack and Jill solve the Sine Calculation Problem

Sine Calculation

In this problem you will see that you can create a series of approximations for the Trigonometric SINE function. If you are a Mathematician, you might recognize this as the "Taylor Series" which looks like the following:

To use this approach we need to express our angles in Radians. Most of us express angles in Degrees.

To convert from Degrees to Radians you can use the following:

angle_in_radians = angle_in_degrees * PI /180.

PI is 3.14.....

let "x" be the angle of interest in radians. Then our first approximation is:

sin(x) = x

Our next approximation is

sin(x) = x - x^3 / 3!

Each approximation is closer to the true value of sin(x). You want to continue approximations until you find that the difference between successive approximations is sufficiently small.

The following table contains the first 5 approximations that you compute until your program decides that it has found a good enough answer. See if you can figure out the additional approximations if your program needed to go further to get a good enough answer:

Approximation Name | Formula
sin_answer1 | x
sin_answer2 | x - x^3/3!
sin_answer3 | x - x^3/3! +x^5/5!
sin_answer4 | x - x^3/3! +x^5/5! -x^7/7!
sin_answer5 | x - x^3/3! +x^5/5! -x^7/7! +x^9/9!

September 19, 2015 11:29 AM