Calculation of the sine function using the expansion

Calculation of the sine function using the expansion - term...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Calculation of the sine function using the expansion. #include <iostream> #include <cmath> using namespace std; int main() { double sine1, sine2, power, term, fact, x, delta; int k, sign; delta = 0.0000001; sign = -1; cout << " enter the angle " ; cin >> x; k = 3; fact = 6; sine1 = x; power = x*x*x;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: term = sign*power; sine2 = sine1 + term/fact; while (fabs((sine1-sine2)/sine1) > delta) { k = k+2; sine1 = sine2; sign = -sign; fact = fact*k*(k -1); power = power*x*x; term = sign*power; sine2 = sine1 + term/fact; } cout << "sin = " << sine1 << endl; return 0; }...
View Full Document

This note was uploaded on 02/05/2012 for the course CIS 210 taught by Professor Feinstein during the Fall '10 term at S. Alabama.

Ask a homework question - tutors are online