Question: Q 3 . Create a NEW Jupyter Notebook file with the name PT 1 Q 3 . Copy the content of the source

Q3. Create a NEW Jupyter Notebook file with the name "PT1Q3". Copy the content of the source file in Q2 to a source file in this project. Modify the program developed for Q2 to perform the following tasks:
- Rewrite the function showMenu() such that if the user enters '\( c \)', it will display "Please enter value of \( x \) : ". The function calcos() is called with a float data type number and an integer value from functions \(\boldsymbol{g e t}_{\mathbf{t}}\mathbf{x}()\) and \(\boldsymbol{g e t}\mathbf{k}()\) respectively as the input parameter values. The function calcos() returns a value of type float, which is the approximated cosine function value calculated by using equation (1) on page 1. This returned result should be printed by showMenu (). Inside the function calCos(), you must call the function calTerm() in Q1 to compute the approximated cosine function value.
- You may use math. \(\cos (\)) library function to compare with your result.
- By default, print() with \(\{: g\}\) format will only show a floating-point number with 6 significant digits. Hence, the result under different \( k \) may be the same owing to inadequate precision. To see the difference, you need to show a floating-point number with more significant figures. Modify your program such that you can show the result as a 15-digit number. This is achieved by using the following statement to show the value of variable \(\mathbf{f}\) :
\[
\text { print("\{:.15f\}". format(f))}
\]
- Finally, implement a new better function calCosNew () which performs the same task of calCos() without using the function calTerm(). You may use Horner's rule (only \( n+1\) multiplications are needed ) for polynomial evaluation, i.e.
\[
P(x)=a_{n} x^{n}+a_{n-1} x^{n-1}+\cdots+a_{0}=\left(\left(\cdots\left(a_{n} x+a_{n-1}\right) x+a_{n-2}\right) x+\cdots+a_{0}\right.
\]
- The sample outputs given below should be realised by your program on executing it. Notice that the character(s) following a colon (: ) is/are entered by the user.
```
[t] Get a term in cosine function
[a] Get the terms in cosine function
[c] Get cosine of an angle in radian
[q] Quit
State your choice (}t,a,c\mathrm{, or q to quit): c
Please enter value of x: 6
-3.1416
Q 3 . Create a NEW Jupyter Notebook file with the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!