Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

I have the question and the answer for this problem I just want to understand the concepts and logic of how to do it step by step

 

LUsing Taylor's thearem, we can obtain a formula to calculate he sine of S
sin(x) - x
- + (-1)
(2n - 1)!
Write a function detinition to calculate the sine of x using the formula above. Your function should
teminate when the absolute value of the last term calculated is less than 1.0 x 10. You may not use any
functions supplied in the cmath.h header file (ie. you cannor use the powx.y) function Your sine
function may call other functions, and in this case, you must also wrie the definitions of those functions.
You do nor need to comment anything, although, a well-placed comment may provide clarity for the
grader.
Bonus (2 pes): Briefly explain why the sine function above will always converge. You will only get the
bonus points if the sine function is wrimen.
Single Function Version
Multiple Function Version
double sin(double x) (
int i;
int n- 1
int sign;
double eps - 1.De-4;
double sum- 0.0;
double pow;
lang fact;
double this term;
do {
pow - 1.0;
Pact- 1
for (1-1; ie-2*n-1; +1) {
double sint double x) (
int a- 1;
double eps - 1.0e-4;
double sum - 0.0;
double this tera
do
this tern-sign(n-1)"pow(x, 2"a-
1)/fact(2'n-1):
sum this tern;
ir (this tern <0.0) this tern -
-this term;
*n;
} while (this tern eps);
return sum;
pow x;
fact i
ir ((n-aa - 1)
sign --1;
else
sign - 1;
this tern- sign'pow/fact;
int sign(int n) {
if (ns2 -- 1)
return -1
return 1;
sum - this_term;
if (this_ter < 0.0)
this tern --this term
double powdouble K, int a) {
int A
double p- 1.0
for (i-0; ien; **1)
} while (this tera eps):
Feturn sim;
P- x;
return p:
lang fact (int n) {
int i;
long f-1
for (1-1; ien; 1) {
return f
expand button
Transcribed Image Text:LUsing Taylor's thearem, we can obtain a formula to calculate he sine of S sin(x) - x - + (-1) (2n - 1)! Write a function detinition to calculate the sine of x using the formula above. Your function should teminate when the absolute value of the last term calculated is less than 1.0 x 10. You may not use any functions supplied in the cmath.h header file (ie. you cannor use the powx.y) function Your sine function may call other functions, and in this case, you must also wrie the definitions of those functions. You do nor need to comment anything, although, a well-placed comment may provide clarity for the grader. Bonus (2 pes): Briefly explain why the sine function above will always converge. You will only get the bonus points if the sine function is wrimen. Single Function Version Multiple Function Version double sin(double x) ( int i; int n- 1 int sign; double eps - 1.De-4; double sum- 0.0; double pow; lang fact; double this term; do { pow - 1.0; Pact- 1 for (1-1; ie-2*n-1; +1) { double sint double x) ( int a- 1; double eps - 1.0e-4; double sum - 0.0; double this tera do this tern-sign(n-1)"pow(x, 2"a- 1)/fact(2'n-1): sum this tern; ir (this tern <0.0) this tern - -this term; *n; } while (this tern eps); return sum; pow x; fact i ir ((n-aa - 1) sign --1; else sign - 1; this tern- sign'pow/fact; int sign(int n) { if (ns2 -- 1) return -1 return 1; sum - this_term; if (this_ter < 0.0) this tern --this term double powdouble K, int a) { int A double p- 1.0 for (i-0; ien; **1) } while (this tera eps): Feturn sim; P- x; return p: lang fact (int n) { int i; long f-1 for (1-1; ien; 1) { return f
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education