0% found this document useful (0 votes)
24 views

CLC Clear Tolerence 0.0001 A 0.8 B 1.0 R 1 I 0 : While

This document describes an iterative method to find the root of an equation. It initializes variables including a tolerance value, starting values for a and b, an initial guess r, and an iteration counter i. It then enters a while loop to calculate new values of r using bisection between a and b until the difference between (r^3) and sin(r) is within the tolerance. It updates a or b depending on whether the difference is positive or negative, and increments i. After the loop, it prints the number of iterations and the calculated root r.

Uploaded by

Ahmad Almasri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

CLC Clear Tolerence 0.0001 A 0.8 B 1.0 R 1 I 0 : While

This document describes an iterative method to find the root of an equation. It initializes variables including a tolerance value, starting values for a and b, an initial guess r, and an iteration counter i. It then enters a while loop to calculate new values of r using bisection between a and b until the difference between (r^3) and sin(r) is within the tolerance. It updates a or b depending on whether the difference is positive or negative, and increments i. After the loop, it prints the number of iterations and the calculated root r.

Uploaded by

Ahmad Almasri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

clc; clear;

tolerence=0.0001;
a=0.8;
b=1.0;
r=1;
i=0;

while abs((r^3) - sin(r))>tolerence;

r=(a+b)/2;
if ((r^3) - sin(r))<0;
a=r;
else ((r^3) - sin(r))>0;
b=r;
end
i=i+1;
end

fprintf('Number of iterations = %g',i)


fprintf('\nThe root = %g\n',r)

Number of iterations = 11
The root = 0.928613

Published with MATLAB 8.0

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy