Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Write a Matlab script file to calculate sin(x) and cos(x), which are defined as follows: sin (x) = x - x^3/3! + x^5/5! -
a) Write a Matlab script file to calculate sin(x) and cos(x), which are defined as follows: sin (x) = x - x^3/3! + x^5/5! - x^7/7! + ... cos (x) = 1 - x^2/2! + x^4/4! - x^6/6! + ...Here n! is 'n factorial': n! identical to n middot (n - 1) middot (n - 2)... 3 middot 2 middot 1. Note that the argument x is in radians. NOT degrees! Your program should have the following features: Prompt user for x and the number of terms to include in the summation (input the values of x and n from command window) Do NOT calculate n! for each term. Recognize that for each successive tem, n! for that tem is n! of the previous term times (n + 1) (n + 2) Similarly do NOT calculate x^n for each term. Recognize that each successive term for n is x from the previous term multiplied by x^2.i.e., x^n + 2 = x^n x^2 Tips: Manually calculate the first several terms to verify your program is working correctly Learn to use the debugger in Matlab. It is an invaluable tool. Use the 'format long' command to express your results with many digits b) use your program to compute the following: sin (0.01) and cos (0.01) using 80 terms sin (0.5) and sin(0.5) using 80 terms sin(10) and cos(10)using 80 terms c)how many terms are required to computer each of the following to 10 digits of accuracy (tip: use the sin() and cos() functions in MATLAB to get the true values) sin (0.5) sin(5) sin(20) d) can you calculate sin(100)? can you calculate sin(0.01) using 200 terms? If not, what do you think is happening
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started