2014 UZTAILA

1.

f[x_]=1+x+x^5-3Sin[x]

a)

Plot[f[x],{x,-2,2}]

CountRoots[f[x],x]

Plot[f[x],{x,0.4,1}]

ERRO POSITIBOAK
1. 0.6
2. 0.8
3. [-2,-1]
b) BISEKZIO [-2,-1]
luzera<0.1

For[a=-2.;b=-1.;i=1;tol=0.1;luzera=b-a,i<50&&luzera>tol,i++,c=(a+b)/2;If[f[a]*f[c]<0,b=c,a=c];luzera=b-a;Print[i,"garren iterazioan tartea [",a,",",b,"] eta luzera = ",luzera]]

c) NEWTON RAPHSON
errorea= 10^(-8)
t=10 digitu esanguratsu
i<30

For[x0=0.6;i=1;tol=10^(-8);err=tol+1,i<30&&err>tol,i++,x1=SetPrecision[x0-(f[x0]/f'[x0]),10];err=Abs[(x1-x0)/x1];Print[i,"garren iterazioan hurbilketa = ",x1," eta errorea ",err];x0=x1]

For[x0=0.8;i=1;tol=10^(-8);err=tol+1,i<30&&err>tol,i++,x1=SetPrecision[x0-(f[x0]/f'[x0]),10];err=Abs[(x1-x0)/x1];Print[i," garren iterazioan hurbilketa = ",x1," eta errorea = ",err];x0=x1]

2.

eku=y''[t]-2y'[t]-3y[t]==DiracDelta[t-5]

ekutrans=LaplaceTransform[eku,t,s]/.{y[0]->1,y'[0]->-1}

lys=LaplaceTransform[y[t],t,s]

soltrans=Solve[ekutrans,lys]

y1[s_]=lys/.soltrans[[1]]

Y1[t_]=InverseLaplaceTransform[y1[s],s,t]

Plot[{y1[s],y1'[s]},{s,-4,0}]

3.

eku=t*y'[t]+y[t]^2+y[t]==Cos[t]+t*Exp[t]

sol=NDSolve[{eku,y[1]==1},y[t],{t,0.4,2}]

yh[t_]=y[t]/.sol[[1]]

f[t_,y_]=t*y''+y^2+y==Cos[t]+t*Exp[t]

a=StreamPlot[{1,f[t,y]},{t,0.4,2},{y,-1,2}]