0% found this document useful (0 votes)
76 views

Sine Function Computation Algorithms: Sin (X) (x/1!) - ( (X 3) /3!) + ( (X 5) /5!) - ( (X 7) /7!) +.........

The document describes algorithms for computing the sine function using its power series expansion. It presents the sine series and examines the patterns in the exponents and factorials. It then describes an algorithm that: 1) Initializes values for the first term, 2) Iteratively computes each subsequent term based on the previous term and factors of x and i, alternating the sign of terms, until the absolute value of the current term is below an error threshold. Each new term is generated by multiplying the previous term by (x^2)/i(i-1). The algorithm efficiently computes sine function values using the power series representation.

Uploaded by

bhariprasad_msc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Sine Function Computation Algorithms: Sin (X) (x/1!) - ( (X 3) /3!) + ( (X 5) /5!) - ( (X 7) /7!) +.........

The document describes algorithms for computing the sine function using its power series expansion. It presents the sine series and examines the patterns in the exponents and factorials. It then describes an algorithm that: 1) Initializes values for the first term, 2) Iteratively computes each subsequent term based on the previous term and factors of x and i, alternating the sign of terms, until the absolute value of the current term is below an error threshold. Each new term is generated by multiplying the previous term by (x^2)/i(i-1). The algorithm efficiently computes sine function values using the power series representation.

Uploaded by

bhariprasad_msc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sine Function Computation Algorithms

Sine series is given ;



sin(x) = (x/1!)-((x^3)/3!)+((x^5)/5!) -((x^7)/7!)+..........

Algorithm development:

Studying the expression for sin(x) we see the powers and factorials of following sequences

1,3,5,7..................

are required. We can easily generate this odd sequence by starting with 1 and successively
adding 2. Our other problem is to compute the general term (x^i)/i! which can expressed as

(x^i)/i! = (x/1)*(x/2)*(x/3)*.......*(x/i) for i>=1

and it can done following loop

fp := 1;
j := 0;
while j<i do
begin
j := j +1;
fp := fp*(x/j);
end

The program can be completed by implementing the additions and subtraction and
appropriate termination. With this approach each term (x^i)/i! is computed by smallest j value
and working upward . To calculating n! we used the efficient approach of calculating each term
from its predecessors .
To determine algorithm we examine specific series for example,

(x^3)/3! = (x*x*x)/(3*2*1) = (x^2)/(3*2) * (x^1)/1! i =3
(x^3)/3! = (x*x*x*x*x)/(5*4*3*2*1) = (x^2)/(5*4) * (x^3)/3! i =5
(x^3)/3! = (x*x*x)/(7*6*5*4*3*2*1) = (x^2)/(7*6) * (x^5)/5! i =7

In each term (x^2)/(3*2) , (x^2)/(5*4) ,(x^2)/(7*6) has a general term :

(x^2)/i(i - 1) for i= 3,5,7,....

i.e. generalized form of each term is:

current ith term = [ (x^2)/i(i - 1) ] * (previous term)
To get the terms to alternate in sign we can use
sign := -sign

algorithm description
1. setup initial conditions for the first term that cannot be computed iterativley .
2. while the absolute value of current term is greater than the acceptable error do
(a). identify the current ith term,
(b). generate current term from its predecessor,
(c). add current term with appropriate sign to the accumulated sum for sine function.

You might also like