0% found this document useful (0 votes)
11 views1 page

Successive Approximation Method Program

This document contains the code for a program that uses the successive approximation method to find the root of an equation. The program takes an initial guess x1 for the root as input, calculates the function value at x1, and then iteratively calculates new values of x by applying the function g(x) = log(1.4/cos(x)) for n iterations, outputting the final root value x2. It also provides the actual solution using MATLAB's fzero function for comparison.

Uploaded by

Rushabh Meher
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Successive Approximation Method Program

This document contains the code for a program that uses the successive approximation method to find the root of an equation. The program takes an initial guess x1 for the root as input, calculates the function value at x1, and then iteratively calculates new values of x by applying the function g(x) = log(1.4/cos(x)) for n iterations, outputting the final root value x2. It also provides the actual solution using MATLAB's fzero function for comparison.

Uploaded by

Rushabh Meher
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ASSIGNMENT NO:

PROGRAM ON : Successive Approximation Method


Roll No:B-25

Function File :
Function g.m => function y=g(x)
y=log(1.4/cos(x));

Function dg.m => function y=dg(x)


y=tan(x);

Program File :
x1=input('enter the value of first root x1=');
n=input('enter the no. of iterations n=');
a=dg(x1);
while (abs(a)>1)
x1=input('enter the value of first root x1=');
a=dg(x1);
end
for i=1:1:n
x2=g(x1);
x1=x2;
end
fprintf('The root of equation is x2=%f',x2);

Program Output :

enter the value of first root x1=0.2

enter the no. of iterations n=5

The root of equation is x2=0.430590

Solver Solution :
x=fzero('exp(x)*cos(x)-1.4',0.2)

x =0.4336

You might also like