Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Ap3.

Create a new class: Lab_06_3_surname_name

Markov series

1 a 
xn   xn 1   a i
2 xn 1 

Determine the first term in the series for which the relative error (err) is less than a given
epsilon (eps)

xn  a
err  <eps
a

The number a and the first term of the series x1 are also given.

At the end of the program the user will be asked if he wants to run the program again by
typing with y for yes and n for no

Notation x2≡xi x1≡xi-1

err=1;

while (err>eps){

x2=0.5*(x1+a/x1);

err= Math.abs( (x2-Math.sqrt(a))/Math.sqrt(a) );

x1=x2;

You might also like