Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

function [ lastTerm , numTerms ] = sqrt 2 approx ( errorTol ) % [ lastTerm , numTerms ] = sqrt 2 approx ( ErrorTol

function [lastTerm, numTerms]= sqrt2approx(errorTol)
%[lastTerm, numTerms]= sqrt2approx(ErrorTol)
%
% This function calculates terms of the sequence
%
% x(1)=1, x(k)=(x(k-1)+2/x(k-1))/2
%
% until the relative error between the Nth term and sqrt(2) falls below
% a given tolerance.
%
% Input:
% errorTol - The tolerance used as the convergence criterion
% Output:
% lastTerm - The last term in the sequence (that meets the tolerance)
% numTerms - The number of terms required to meet the tolerance
ea =100;
numTerms = uint8(1);
lastTerm = ;
while ea >
lastTerm =(+2/lastTerm)/2;
ea = abs((sqrt(2)-)/sqrt(2));
numTerms=numTerms+ ;
end

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions