.TH sin() "" "" "Mathematics function (libm)"
.PC "Calculate sine"
.B "#include <math.h>"
\fBdouble sin(\fIradian\^\fB) double \fIradian\^\fB;\fR
.PP
.B sin()
calculates the sine of its argument
.IR radian ,
which must be in radian measure.
.SH Example
The following example uses the functions
.B sin()
and
.B cos()
to paint sine and cosine on the screen.
.II "Gringauz, Dmitry"
It is by Dmitry Gringauz (dmitry@golem.com).
.DM
#include <math.h>
#include <stdio.h>
.DE
.DM
#define MAX_X 79 /* X dimension of screen */
#define MAX_Y 23 /* Y dimension of screen */
char screen[MAX_X][MAX_Y]; /* the screen matrix */
.DE
.DM
main()
{
	double pi = 3.14159, i, result;
	int x = 0, y = 0, mid_x = (MAX_X-1)/2, mid_y = (MAX_Y-1)/2;
.DE
.DM
	/* blank (dot) out the screen */
	for (y = 0; y < MAX_Y; y++)
		for (x = 0; x < MAX_X; x++)
			screen[x][y] = '.';
.DE
.DM
	/* build the "axis" */
	for (x=0; x < MAX_X; x++)
		screen[x][mid_y] = '-';
	for (y = 0; y < MAX_Y; y++)
		screen[mid_x][y] = '|';
.DE
.DM
	/* make center and arrows */
	screen[mid_x][mid_y] = '+';
	screen[mid_x][0] = '^';
	screen[MAX_X-1][mid_y] = '>';
.DE
.DM
	/* do the sin() and cos() thing */
	for (i = -pi; i <= pi; i = i + 2.0 / (MAX_X)) {
		result = sin(i) ;
.DE
.DM
		x = i*mid_x/pi + mid_x;
		y = mid_y*(-1.0*result) + mid_y;
.DE
.DM
		if (x >= MAX_X)
			x = MAX_X - 1;
.DE
.DM
		if (y >= MAX_Y)
			y = MAX_Y - 1;
.DE
.DM
		screen[x][y] = '*';
		result = cos(i) ;
.DE
.DM
		x = i*mid_x/pi + mid_x;
		y = mid_y*(-1.0*result) + mid_y;
.DE
.DM
		if (x >= MAX_X)
			x = MAX_X - 1;
.DE
.DM
		if (y >= MAX_Y)
			y = MAX_Y - 1;
		screen[x][y] = '*';
	} /* i */
.DE
.DM
	/* print the screen */
	for (y = 0; y < MAX_Y; y++) {
		for (x = 0; x < MAX_X; x++)
			printf("%c", screen[x][y]);
		printf("\en");
	} /* y */
}
.DE
.SH "See Also"
.Xr "cos()," cos
.Xr "cosh()," cosh
.Xr "libm," libm
.Xr "sinh()" sinh
.br
\*(AS, \(sc7.5.2.6
.br
\*(PX Standard, \(sc8.1
