

#zad 2 eps maszynowy
a=1;
x=1;
N=0;
while((a+x)>a)
 x=x*.5;
 N=N+1;
endwhile
N=N-1

#to samo w pojedynczej precyzji
a=x=single(1);
N=0;
while((a+x)>a)
 x=x*.5;
 N=N+1;
endwhile
N=N-1



#zad 3
x=linspace(0,1,1000);
a=256;
for k=8:58,
 plot(x,(x-a)+a,[";2^k,k=", num2str(k),";"]);
 pause(.5);
 a=2*a;
endfor

#pojedyncza precyzja
x=single(linspace(0,1,1000));
a=single(256);
for k=8:30,
 plot(x,(x-a)+a,[";2^k,k=", num2str(k),";"]);
 pause(.5);
 a=2*a;
endfor


#zad 4 

a=1e-3;
x=linspace(2-a,2+a);
f1=(x-2).*(x-2);f1=f1.*f1;
f2=x.*x.*x.*x-8*x.*x.*x+24*x.*x-32.*x+16;
plot(x,f1,";f1=(x-2)^4;",x,f2,";f2=x^4..+16;",x,0*x,";f(x)=0;");

#pojedyncza precyzja
a=1e-1;
x=linspace(2-a,2+a);
x=single(x);
f1=(x-2).*(x-2);f1=f1.*f1;
f2=x.*x.*x.*x-8*x.*x.*x+24*x.*x-32.*x+16;
plot(x,f1,";f1=(x-2)^4;",x,f2,";f2=x^4..+16;",x,0*x,";f(x)=0;");

