Question

x) -1-2! +41-614 (2k)! k=0 he actual Write a script that will determine how many terms are needed in the series to get the er
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB CODE---------------------------

x=input('Enter value of x');

x1=(x*pi)/180;

COS2x_Actual=cosd(2*x)

n=0;

Error=1;

COS2X_estimated=0;

while (Error>0.0001)

COS2X_estimated =COS2X_estimated +(((-1)^(n)*((2*x1)^(2*n)))/factorial(2*n))

Error = abs(COS2x_Actual-COS2X_estimated)

n=n+1;

end

fprintf('\n\n%d terms are needed to meet the tolerance',n)

OUTPUT----------------TEST---------------------OF-----------CODE

Enter value of x> 45
COS2x_Actual = 0
COS2X_estimated =  1
Error =  1
COS2X_estimated = -0.23370
Error =  0.23370
COS2X_estimated =  0.019969
Error =  0.019969
COS2X_estimated =   -8.9452e-04
Error =    8.9452e-04
COS2X_estimated =    2.4737e-05
Error =    2.4737e-05


5 terms are needed to meet the tolerance

 

 
Enter value of x> 5
COS2x_Actual =  0.98481
COS2X_estimated =  1
Error =  0.015192
COS2X_estimated =  0.98477
Error =    3.8624e-05


2 terms are needed to meet the tolerance
Add a comment
Know the answer?
Add Answer to:
X) -1-2! +41-614 (2k)! k=0 he actual Write a script that will determine how many terms are needed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Instructions: Submit your script in a file named hwk08.m to the dropbox before 11:59 pm on the du...

    Instructions: Submit your script in a file named hwk08.m to the dropbox before 11:59 pm on the due date NOTE: This assignment is neither quick nor simple. You will be well served to start on it early, and to ask for help if you need it. Being a more substantial assignment than earlier hwk, it is worth- s. When you ask your calculator for the value of a function for a specified argument, (e.g., sin(22), cos(74), In(6.5)), it almost certainly...

  • THE CODE NEEDS TO BE ON MATLAB 2. Exercise (a) Let's write a script file that...

    THE CODE NEEDS TO BE ON MATLAB 2. Exercise (a) Let's write a script file that calculates exp(2) by a Maclaurin series using a while loop exp x )=-+-+-+-+ The while loop should add each of the series terms. The program error as defined below is smaller than 0.01. Error is the exact value (i.e. exp(2)), minus the approximate value (i.e., the current series sum) should exit the loop when the absolute absolute error-lexact-approx Use fprintf within the loop such...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • Part 2 to the problem in matlabthis is the hint that came with the problem

    part 2 to the problem in matlabthis is the hint that came with the problem The value of T can be estimated from the following equation: In your script file, estimate the value of t for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message (including the asterisks) where II is the number...

  • Write VBA functions to calculate sin (x) using the Maclaurin arcsine series, and compare the values...

    Write VBA functions to calculate sin (x) using the Maclaurin arcsine series, and compare the values for sin-1(x) from your program to those given by the Excel spreadsheet function ASIN(x). The Maclaurin arcsine expansion is given by x 3x 6 40 (2n)! sin1(x)-2((2n+1) Note: This function by definition is only defined for-1 SxS1. When you write the code for calculating it, you will need to include code that assigns a value to it that reflects it is undefined for values...

  • Task 4 Many real world objects travel in a jagged manner that is best represented by piecewise fu...

    MATLAB question: Task 4 Many real world objects travel in a jagged manner that is best represented by piecewise functions. For example, the velocity of a rocket may change sharply when thrusters are enabled or disabled and due to various external factors. The velocity of a rocket can be modelled by v(t) where t represents the time 112-5t 0sts10 1100-5t10StS20 vt) 502( 20)25 20sIs 30 1520e0-30) 0 t >30 otherwise Write a function that takes a start and end time...

  • 1. Write a C++ program called Password that handles encrypting a password. 2. The program must...

    1. Write a C++ program called Password that handles encrypting a password. 2. The program must perform encryption as follows: a. main method i. Ask the user for a password. ii. Sends the password to a boolean function called isValidPassword to check validity. 1. Returns true if password is at least 8 characters long 2. Returns false if it is not at least 8 characters long iii. If isValidPassword functions returns false 1. Print the following error message “The password...

  • Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, w...

    Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output) for each of the 3 problems given below. You should not write any actual C++ code. Make sure the problem statement is in your own words and is descriptive enough so someone not...

  • python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a...

    python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT