19

Trigonometry

  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. main() {
  5.     float x;
  6.  
  7.     /* empirical demonstration that sin(2x) = 2sin(x) * cos(x) */
  8.     for ( x = 0; x < 2.0; x += 0.2 )
  9.         printf("\t%.1f\t\t%f\t%f\n", x, sin(2*x), 2*sin(x) * cos(x));
  10. }
$ gcc -o trigo trigo.c
$ ./trigo 
	0.0		0.000000	0.000000
	0.2		0.389418	0.389418
	0.4		0.717356	0.717356
	0.6		0.932039	0.932039
	0.8		0.999574	0.999574
	1.0		0.909297	0.909297
	1.2		0.675463	0.675463
	1.4		0.334988	0.334988
	1.6		-0.058374	-0.058374
	1.8		-0.442521	-0.442521

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].