for this problem I ju

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
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
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
LUP Decomposition
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education