#include<stdio.h>
#include<math.h>
void main()
{
int i = 2, n, s = 1, x, pwr = 1, dr;
float nr = 1, x1, sum;
clrscr();
printf("\n\n\t ENTER THE ANGLE...: ");
scanf("%d", &x);
x1 = 3.142 * (x / 180.0);
sum = x1;
printf("\n\t ENTER THE NUMBER OF TERMS...: ");
scanf("%d", &n);
while(i <= n)
{
pwr = pwr + 2;
dr = dr * pwr * (pwr - 1);
sum = sum + (nr / dr) * s;
s = s * (-1);
nr = nr * x1 * x1;
i+= 2;
}
printf("\n\t THE SUM OF THE SINE SERIES IS..: %0.3f",sum);
getch();
}
To get all source codes for calculating sine,cose and tan through Taylor series in C++, visit:
http://bitsbyta.blogspot.com/2011/02/calculating-sine-in-radians-using_16.HTML
http://bitsbyta.blogspot.com/2011/02/calculating-cosine-in-radians-using.HTML
http://bitsbyta.blogspot.com/2011/02/calculating-tan-in-radians-using-Taylor.HTML
// from Pondicherry
#include
#include
void main()
{
int i = 2, n, s = 1, x, pwr = 1, dr=1;
float nr = 1, x1, sum;
clrscr();
printf("\n\n\t ENTER THE ANGLE...: ");
scanf("%d", &x);
x1 = 3.14159 * (x / 180.0);
sum = x1;
nr = x1;
printf("\n\t ENTER THE NUMBER OF TERMS...: ");
scanf("%d", &n);
while(i <= n)
{ s = s * (-1);
nr = nr * x1 * x1;
pwr = pwr + 2;
dr = dr * pwr * (pwr - 1);
sum = sum + ((float)nr / dr) * s;
i++;
}
printf("\n\t THE SUM OF THE SINE SERIES IS..: %0.3f",sum);
getch();
}
/*
Practical C Programming, Third Edition
By Steve Oualline
Third Edition August 1997
ISBN: 1-56592-306-5
Publisher: O'Reilly
*/
/* Usage: *
* sine
* *
*
* *
* Format used in f.fffe+X *
* *
* f.fff is a 4 digit fraction *
* + is a sign (+ or -) *
* X is a single digit exponent *
* *
* sine(x) = x - x**3 + x**5 - x**7 *
* ----- ---- ---- . . . . *
* 3! 5! 7! *
* *
* Warning: This program is intended to show some of *
* problems with floating point. It not intended *
* to be used to produce exact values for the *
* sin function. *
* *
* Note: Even though we specify only one-digit for the *
* exponent, two are used for some calculations. *
* This is due to the fact that printf has no *
* format for a single digit exponent. *
*/
#include
#include
#include
/*
* float_2_ascii -- turn a floating-point string *
* into ascii. *
* *
* Parameters *
* number -- number to turn into ascii *
* *
* Returns *
* Pointer to the string containing the number *
* *
* Warning: Uses static storage, so later calls *
* overwrite earlier entries *
*/
static char *float_2_ascii(floatnumber)
{
static char result[10]; /*place to put the number */
sprintf(result,"%8.3E", number);
return (result);
}
/*
* fix_float -- turn high precision numbers into *
* low precision numbers to simulate a *
* very dumb floating-point structure. *
* *
* Parameters *
* number -- number to take care of *
* *
* Returns *
* number accurate to 5 places only *
* *
* Note: This works by changing a number into ascii and *
* back. Very slow, but it works. *
*/
float fix_float(float number)
{
float result; /* result of the conversion */
char ascii[10]; /* ascii version of number */
sprintf(ascii,"%8.4e", number);
sscanf(ascii, "%e", &result);
return (result);
}
/*
* factorial -- compute the factorial of a number. *
* *
* Parameters *
* number -- number to use for factorial *
* *
* Returns *
* factorial(number) or number! *
* *
* Note: Even though this is a floating-point routine, *
* using numbers that are not whole numbers *
* does not make sense. *
*/
float factorial(float number)
{
if (number <= 1.0)
return (number);
else
return (number *factorial(number - 1.0));
}
int main(int argc, char *argv[])
{
float total; /* total of series so far */
float new_total;/* newer version of total */
float term_top;/* top part of term */
float term_bottom;/* bottom of current term */
float term; /* current term */
float exp; /* exponent of current term */
float sign; /* +1 or -1 (changes on each term) */
float value; /* value of the argument to sin */
int index; /* index for counting terms */
if (argc != 2) {
fprintf(stderr,"Usage is:\n");
fprintf(stderr," sine
exit (8);
}
value = fix_float(atof(&argv[1][0]));
total = 0.0;
exp = 1.0;
sign = 1.0;
for (index = 0; /* take care of below */ ; ++index) {
term_top = fix_float(pow(value, exp));
term_bottom = fix_float(factorial(exp));
term = fix_float(term_top / term_bottom);
printf("x**%d %s\n", (int)exp,
float_2_ascii(term_top));
printf("%d! %s\n", (int)exp,
float_2_ascii(term_bottom));
printf("x**%d/%d! %s\n", (int)exp, (int)exp,
float_2_ascii(term));
printf("\n");
new_total = fix_float(total + sign * term);
if (new_total == total)
break;
total = new_total;
sign = -sign;
exp = exp + 2.0;
printf(" total %s\n", float_2_ascii(total));
printf("\n");
}
printf("%d term computed\n", index+1);
printf("sin(%s)=\n", float_2_ascii(value));
printf(" %s\n", float_2_ascii(total));
printf("Actual sin(%G)=%G\n",
atof(&argv[1][0]), sin(atof(&argv[1][0])));
return (0);
}
Function sin in header math.h
Using its Taylor-series.
The fourier series of a sine wave is 100% fundamental, 0% any harmonics.
A Sine-Cosine Encoder is a position transducer using only two sensors, each 90 degrees out of phase with respect to each other, driving an up/down counter through appropriate logic. Since sine and cosine are 90 degrees out of phase with repect to each other, this technique is called sine-cosine encoding. The computer mouse is an example of this technique.
If you put a diode in series with an AC sine wave that goes plus and minus, it will cut off either the positive or negative portion of the waveform, depending on the direction of the diode in circuit. So in effect you have a pulse equal to one half cycle of the sine wave.
No and yes. Digital signals are usually square or pulse waves. By Fourier analysis, however, every periodic wave, even a square wave, is the summation of some series (often infinite) of sine waves.
Writing a program for a sum of sine series requires a rather long formula. That formula is: #include #include #include main() { int i,n,x; .
Using its Taylor-series.
Sine Language was created in 2009.
Generating Sine and Cosine Signals (Use updated lab)
The fourier series of a sine wave is 100% fundamental, 0% any harmonics.
arc sine is the inverse function of the sine function so if y = sin(x) then x = arcsin(y) where y belongs to [-pi/2, pi/2]. It can be calculated using the Taylor series given in the link below.
half range cosine series or sine series is noting but it consderingonly cosine or sine terms in the genralexpansion of fourierseriesfor examplehalf range cosine seriesf(x)=a1/2+sigma n=0to1 an cosnxwhere an=2/c *integral under limits f(x)cosnxand sine series is vice versa
how do you say hi in sine language
General answer: Math Specific Answer: Taylor Series
sine language, moscode and mail
The word sine, not sinx is the trigonometric function of an angle. The answer to the math question what is the four series for x sine from -pi to pi, the answer is 24.3621.
The court will take a break without sine die.