Pogreške

Pretvaranje broja w u k-znamenkasti floating-point broj

fl[w_,k_]:=Module[{sw}, sw=MantissaExponent[w]; 
		                         sw[[1]]=Round[10^k sw[[1]] ]/10^k;
		                         sw[[1]] 10^sw[[2]]//N
		                                         ];

fl[243.57,4]

(* Primjer 1.3 *)
p=125.;  q=.0125; Clear[x];       k=8;

(* Pravo rjesenje *)
sol=Solve[x^2+2p x-q==0,x];
Print["x1: ",sol[[1]],"   x2: ",sol[[2]] ] ;

(* Direktno f-p pozitivno rjesenje *)
ww=fl[p^2,k];Print["p^2 = ",ww]
ww=fl[ww+q,k]; Print["p^2+q = ",ww]
ww=fl[Sqrt[ww],k];Print["Sqrt[p^2+q] = ",ww]
ww=fl[-p+ww,k]; Print["x'= ",ww]
Print[]

(* Korigirano f-p pozitivno rjesenje *)
ww=fl[p^2,k];Print["p^2 = ",ww]
ww=fl[ww+q,k]; Print["p^2+q = ",ww]
ww=fl[Sqrt[ww],k];Print["Sqrt[p^2+q] = ",ww]
ww=fl[p+ww,k]; Print["p+Sqrt[p^2+q] = ",ww]
ww=fl[q/ww,k]; Print["x'' = ",ww]

P1.9

V[r_,pi_]:=4 r^3pi/3;
w={r->10.2,pi->3.14};
Vz=V[r,pi]/.w;
DV=.05 Abs[D[V[r,pi],r]/.w]+.005 Abs[D[V[r,pi],pi]/.w];
dV=DV/Vz;
Print["V*=",Vz,"  DV=",DV,"  dV=",dV]

Z1.12

c[a_,b_,gam_]:=Sqrt[a^2+b^2-2a b Cos[gam]];

D[c[a,b,gam],a]

D[c[a,b,gam],a]/.{a->10.2,b->7.5,gam->31.3 Pi/180}

w={a->10.2,b->7.5,gam->31.3 Pi/180};
cz=c[a,b,gam]/.w;
Dc=.05 Abs[D[c[a,b,gam],a]/.w]+.05 Abs[D[c[a,b,gam],b]/.w]+.05 (Pi/180)Abs[D[c[a,b,gam],gam]/.w];
dc=Dc/cz;
Print["c*=",cz,"  Dc=",Dc,"  dc=",dc]

w={a->230.7,b->123.5,gam->27.4 Pi/180};
cz=c[a,b,gam]/.w;
Dc=.05 Abs[D[c[a,b,gam],a]/.w]+.05 Abs[D[c[a,b,gam],b]/.w]+.05 (Pi/180)Abs[D[c[a,b,gam],gam]/.w];
dc=Dc/cz;
Print["c*=",cz,"  Dc=",Dc,"  dc=",dc]

Z1.16

f[x_]:=Sqrt[1+x^2]-x+200

f[100.]
Df=1 Abs[f'[x]/.{x->100.}]

Z1.17

g=9.81;
d[v0_,al_]:=v0^2 Sin[2 al]/g;
w={v0->115,al->15 Pi/180};
dz=d[v0,al]/.w;
Dd=1 Abs[D[d[v0,al],v0]/.w]+.1 (Pi/180)Abs[D[d[v0,al],al]/.w];
dd=Dd/dz;
Print["d*=",dz,"  Dd=",Dd,"  dd=",dd]

w={v0->900,al->15 Pi/180};
dz=d[v0,al]/.w;
Dd=10 Abs[D[d[v0,al],v0]/.w]+.1 (Pi/180)Abs[D[d[v0,al],al]/.w];
dd=Dd/dz;
Print["d*=",dz,"  Dd=",Dd,"  dd=",dd]

Z1.18

Clear[v0,g,X];
X[v0_,g_]:=v0^2 /g;
w={v0->115,g->9.81};
Xz=X[v0,g]/.w;
DX=1 Abs[D[X[v0,g],v0]/.w]+.001 Abs[D[X[v0,g],g]/.w];
dX=DX/Xz;
Print["X*=",Xz,"  DX=",DX,"  dX=",dX]

w={v0->900,g->9.81};
Xz=X[v0,g]/.w;
DX=10 Abs[D[X[v0,g],v0]/.w]+.001 Abs[D[X[v0,g],g]/.w];
dX=DX/Xz;
Print["X*=",Xz,"  DX=",DX,"  dX=",dX]