
Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc. 

Thread Tools  Display Modes 
#1




C program for sine series
1)I am unable to write a C program to find the sum to n terms of a sine series. The concept used to find the sum to n terms of a cosine series is as follows:
First take Sum=1,t=1,i=1 So we have the first term. Now the second term is got by t=(t*M) (where M= x*x/(2i1)*2i) t= (t*x*x/(2i1)*2i So we get the second term as, t= (1)*x*x/1*2 = x^2/2 The multiplying term M can be got by dividing the (n+1)th term of the series by the nth term of the series. I applied the same method for sine series also and I got M as: M=t(n+1)/t(n) = x^2/2n(2n+1) Or, M= x^2/2i(2i+1) But using this expression of M, I am unable to generate the sine series. The nth term of sine series is (1)^(i+1)*x^(2i1)/(2i1)! But no factorial function is available in C. So what is the way to write this program? 
#2




i know one thing abt factorials
u will have to define a function factorial by using for loop. and call this function by the main function at the same time sending the arguments. i hope u have learned abt functions ,if not try reading from some book it will certainly have an example of the kind where call to a function is made the function then returns the value to the main function. 
#3




Quote:
N.B. Try Ackermann's function for a really wicked example of runaway recursion.
__________________
We never have time to do it right, But we always have time to do it over. 
#4




well i did mean recursive function,
i just wasnt able to recall the case correctly, i dont deal with c programming that much. 
#5




Now, I have only one way of solving it. I will have to write the program for cosine series and then adding an extra instruction sinx=sqrt(1 cosx*cosx). Anyway, thanx guys.

Tags 
program, series, sine 
Related Site Pages  
Section  Title  
Textbook  Selsyn (synchro) motors : Ac Motors  
Worksheet  Mixedfrequency signals  
Worksheet  Phasor mathematics  
Worksheet  Trigonometry for AC circuits 
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
need to program PIC16F676 and how to program read and write by which kind of tools  kazi2207  Embedded Systems and Microcontrollers  4  01032013 11:57 PM 
help with Traffic light program  jacobh213  Programmer's Corner  0  02222012 05:12 PM 
Written Program Size: A Comparison of C vs. Assembly  ke5nnt  Embedded Systems and Microcontrollers  35  12312011 05:29 AM 
Programming PIC18F**K** Series  FunkiiMunkii  Embedded Systems and Microcontrollers  1  10092008 03:58 PM 
Fourier series coefficients  whoozit  Homework Help  2  02292008 09:17 AM 
Thread Tools  
Display Modes  

