We will write our own (Python) function to calculate the (mathematical) sine function. One obvious way is to evaluate the Taylor series: sin x = x - 3! (-1)n-1,2n–1 (2n – 1)! +... = 5! 7! n=1 A small trick will come in useful here. As n gets larger (and we will certainly need to add lots of terms to get an accurate result!) it will take longer and longer to calculate both x2n-1 and (2n – 1)!. However, both of these are easy to calculate given the previous term. So the smart way to evaluate this series is to keep track of the previous term added, and then use a recursive relationship tn = tn-1 × (2n – 1)(2n – 2)' Check that you understand how this works, then write a function sine_sum (x) to calculate sin(x) by this method.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
We will write our own (Python) function to calculate the (mathematical) sine function. One obvious way is to evaluate the Taylor series:
ř-1)=-1,2n–1
(2n – 1)!
73
sin x = x -
+
3!
5!
7!
n=1
A small trick will come in useful here. As n gets larger (and we will certainly need to add lots of terms to get an accurate result!) it will take longer and longer to calculate both x2n and (2n – 1)!.
However, both of these are easy to calculate given the previous term. So the smart way to evaluate this series is to keep track of the previous term added, and then use a recursive relationship
tn = tn-1 x
(2n – 1)(2n – 2)
Check that you understand how this works, then write a function sine_sum(x) to calculate sin(x) by this method.
Transcribed Image Text:We will write our own (Python) function to calculate the (mathematical) sine function. One obvious way is to evaluate the Taylor series: ř-1)=-1,2n–1 (2n – 1)! 73 sin x = x - + 3! 5! 7! n=1 A small trick will come in useful here. As n gets larger (and we will certainly need to add lots of terms to get an accurate result!) it will take longer and longer to calculate both x2n and (2n – 1)!. However, both of these are easy to calculate given the previous term. So the smart way to evaluate this series is to keep track of the previous term added, and then use a recursive relationship tn = tn-1 x (2n – 1)(2n – 2) Check that you understand how this works, then write a function sine_sum(x) to calculate sin(x) by this method.
Expert Solution
Step 1

we need to find sine_sum(x) function using recursion formula:

Computer Engineering homework question answer, step 1, image 1

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY