{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cubedroot - if a == theoret disp'The cube root is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [x] = cubedroot(a,b) %In this situation, a is your starting guess, and b is the number wanting to %be cube-rooted. For example, if you wanted the cube root of 27, b = 27, %and a first guess could be equal to, let's say, 2. theoret=nthroot(b,3); %This is for the case when your guess "a" is equal to the cube root.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if a == theoret disp('The cube root is:'); disp(a) %This is for the case when your guess "a" is not equal to the cube root. else while (abs(a - theoret)/theoret) > (10^-8); a = (1/3)*(2*a + b/a^2); disp(a) end end end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online