Question: Objectives: Learn how to write a convergent algorithm using Taylor series and how to use global variables For Taylor Series, Read the Taylor documents included

Objectives: Learn how to write a convergent algorithm using Taylor series and how to use global variables
For Taylor Series, Read the Taylor documents included with this Lab. Study the series to see how it converges. Note that
for these Trig functions, Taylor converges quickly. The number of terms will vary based on the size of the angle and the
size of epsilon.
For this program you will write a script and two functions, sine and cosine using Taylor series (NOTE: you can use any
name except the Matlab function names sin and cos for these functions). Refer to ME1101 Taylor Series DOC. The
purpose of this program is to test your sine and cosine function to insure it solves for sin and cos accurately.
CONCEPTS:
e=10^- k.].
You will gradually increase k to improve the accuracy of your functions sine and cosine compared to the MATLAB sin and
cos so that your functions results match closely the MATLAB sin and cos functions. When you match the MATLAB sin
and cos functions accuracy, freeze k. For Lab 6B set the value of k to this value.
You will use csine as a counter for your sine function and ccosine as a counter for your cosine function. the variables
csine and ccosine will be used to count how many cycles your sine and cosine functions require to converge to an
accurate answer. Your results of Sine and Cosine, k, and csine for Sine and ccosine for Cosine will be recorded in the
Excel sheet TEST TAYLOR.
Requirements:
1. Write a Script that cycles until user stops it.
2. Ask the user to input k a global variable in the script, k will then be used in both of your 2 functions. Epsilon in
each function will be 10^-k. So, by increasing k you will be improving the accuracy of your functions.
3. Ask the user for an angle in radians.
4. Using the angle the user entered, call both your sine and cosine function, as well as the MATLAB sin and cos
functions with the same angle. Compare the results for a range of angles between 0 and . Pick at least 4
different angles across this range. Adjust your input of k until you get answers close to the MATLAB functions.
5. Write your two functions for sine and cosine using Taylor series.
Here is a general outline
The purpose of the Lab is to test your sine and cosine functions. Comparing results to the MATLAB sin and cos built in
functions. This exercise is to have you write your sine and cosine functions using the Taylor series algorithm.
This is also an exercise in using global variables. There are 3 global variables: k the exponent for e which equals 10^-k.
Script:
Loops until user stops (WHILE)
Declare the globals k, csine, ccosine in the script.
Input value for k
Input angle to calculate the sine and cosine of this angle (in radians) using your sine and cosine function as well as
MATLABs sin and cos function (built it functons). By increasing the absolute value of k you make e smaller. As e gets
smaller you should be able to approach and eventully equal the MATLAB sin and cos values for the angle.
With k set and angle input finished
Call four functions with the same angle as defined
Your sine
Your cosine
MATLAB sin e.g. Ms=sin(angle);
MATLAB cos
At this point dont reloop yet rather take the data and enter the information into the TEST TAYLOR sheet given in
CANVAS. After a good number of runs use the data from the TEST TAYLOR sheet to set k.
Loops until user stops (WHILE)
You will use your sine and cosine function with k fixed to solve Lab 6B.
end of Script
function your sine function
global variables k and csine
function your cosine function
global variables k and ccosine
end
ONE Script and 2 Functions per requirements

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!