Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A power series representation of sin(x), where x is an angle in radians, is as follows: sin(x) -x-+ n-0 n= 1 Write a MATLAB function

image text in transcribed

A power series representation of sin(x), where x is an angle in radians, is as follows: sin(x) -x-+ n-0 n= 1 Write a MATLAB function m-file that iteratively approximates sin(x) using this formula until the absolute relative approximate error falls below a given tolerance: Your function must have two inputs (a scalar value for x, and a tolerance) and a single output (the computed approximation of sin(x)) . Iteratively compute the approximation of sin(x) o For each iteration, compute and compare the absolute relative approximate error to the tolerance, and stop if the error becomes less than the tolerance. . Just be fore your function ends, use fprintf to print out the number of iterations that were executed and the final absolute relative approximate error. Hint: Look at the examples in lecture6.pdf for computing a square root and for computing cos(r). Your code should combine elements of both For your demonstration: Set MATLAB's output format to longG . Show the function's output when computing sin(1/2) with a tolerance of 0.01 o Compute the absolute relative true error for vour result Show the function's output for another pair ofx and tolerance values A power series representation of sin(x), where x is an angle in radians, is as follows: sin(x) -x-+ n-0 n= 1 Write a MATLAB function m-file that iteratively approximates sin(x) using this formula until the absolute relative approximate error falls below a given tolerance: Your function must have two inputs (a scalar value for x, and a tolerance) and a single output (the computed approximation of sin(x)) . Iteratively compute the approximation of sin(x) o For each iteration, compute and compare the absolute relative approximate error to the tolerance, and stop if the error becomes less than the tolerance. . Just be fore your function ends, use fprintf to print out the number of iterations that were executed and the final absolute relative approximate error. Hint: Look at the examples in lecture6.pdf for computing a square root and for computing cos(r). Your code should combine elements of both For your demonstration: Set MATLAB's output format to longG . Show the function's output when computing sin(1/2) with a tolerance of 0.01 o Compute the absolute relative true error for vour result Show the function's output for another pair ofx and tolerance values

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago