## Zadavanje niza

ispisivanje članova niza zadanih formulom

b[n]:=(n+1)/(n^2+1);

makelist(b[n],n,1,6);

rekurzivno zadavanje niza

a[1]:1;
a[n]:=a[n-1]+n-1;

makelist(a[n],n,1,6);

## Omeđenost i monotonost niza

ako želimo ponovo koristiti varijablu "a" za spremanje članova novog niza, moramo prethodni niz ukloniti pomoću naredbe "kill" 

kill(a);

1. zadatak

a[n]:=(n-1)/(n+1);

makelist(a[n],n,1,10);

makelist([n,a[n]],n,1,10);

wxplot2d([discrete,makelist([n,a[n]],n,1,20)],[style,points],grid2d);

kill(a);

2. zadatak

a[n]:=log(n+5);

wxplot2d([discrete,makelist([n,a[n]],n,1,20)],[y,0,4],[style,points],grid2d);

kill(a)$

3. zadatak

a[n]:=1/n!;

wxplot2d([discrete,makelist([n,a[n]],n,1,8)],[x,-1,8.5],[y,-1,1.5],[style,points],grid2d);

kill(a)$

4. zadatak

a[n]:=(-1)^n/n!;

wxplot2d([discrete,makelist([n,a[n]],n,1,8)],[x,-1,8.5],[y,-1.5,1],[style,points],grid2d);

kill(a)$

5. zadatak

a[n]:=(3*n-18)/(3*n-19);

makelist(a[n],n,1,10);

makelist(float(a[n]),n,1,10);

wxplot2d([discrete,makelist([n,a[n]],n,1,15)],[x,-1,16],[y,-1,2],[style,[points,2]],grid2d);

## Limes niza

1. zadatak

limit((n+3)/(2*n+5),n,inf);

wxplot2d([[discrete,makelist([n,(n+3)/(2*n+5)],n,1,24)],1/2],[x,-1,25],[y,0,1],
[style,[points,2],[lines,1]],grid2d);

2. zadatak

limit((5*n-2)/(n^2+n+1),n,inf);

3. zadatak

limit((n-1)^2/(3*n^2),n,inf);

4. zadatak

limit(sqrt(n^2+3*n)-n,n,inf);

5. zadatak

limit(n^3/(n^2+1)-n,n,inf);

6. zadatak

limit(n*(sqrt(n^2+1)-n),n,inf);

7. zadatak

limit((8*n^3-7*n+4)^(1/3)/(3*n+4),n,inf);

8. zadatak

limit(n!/((n+1)!+(n-1)!),n,inf);

9. zadatak

limit(sqrt(2*n-3)/(sqrt(n)+1),n,inf);

wxplot2d([[discrete,makelist([n,sqrt(2*n-3)/(sqrt(n)+1)],n,2,100)],sqrt(2)],[x,-1,100],[y,-1,2],
[style,[points,2],[lines,1]],grid2d);

10. zadatak

limit((16*4^(n-2)+4^n)/(1+4^n),n,inf);

11. zadatak

limit((n+1)^(1/3)-n^(1/3),n,inf);

12. zadatak

limit((2^n+3^n+4^n+5^(n-1))/(2^n+2*6^n),n,inf);

13. zadatak

limit(((n+6)/(n-1))^(2*n),n,inf);

14. zadatak

limit(((3*n)/(3*n+1))^(n+1),n,inf);

## Nizovi - wxdraw2d i draw2d

load(draw)$

nekoliko zajedničkih globalnih postavki za crtanje da 
ih ne moramo kod svake slike posebno pisati

set_draw_defaults(
    grid=true,
    xaxis=true,
    yaxis=true,
    xaxis_width=2,
    yaxis_width=2,
    xaxis_type=solid,
    yaxis_type=solid,
    xlabel="n",
    ylabel="a_n")$

a)

a[n]:=(n-1)/(n+1);

niz:points(makelist([n,a[n]],n,1,20))$

wxdraw2d(xrange=[0,20.2], yrange=[-0.2,1.5], xtics=[0,1,20],
   color=blue, point_size=2, point_type=7, niz), wxplot_size=[700,500]$

draw2d(terminal=wxt, xrange=[0,20.2], yrange=[-0.2,1.5], xtics=[0,1,20],
   color=blue, point_size=2, point_type=7, niz)$

b)

kill(a)$

a[n]:=log(n+5);

niz2:points(makelist([n,a[n]],n,1,20))$

wxdraw2d(xrange=[0,20.2], yrange=[-0.2,4], xtics=[0,1,20],
   color=blue, point_size=2, point_type=7, niz2), wxplot_size=[700,500]$

draw2d(terminal=wxt, xrange=[0,20.2], yrange=[-0.2,4], xtics=[0,1,20],
   color=blue, point_size=2, point_type=7, niz2)$

c)

kill(a)$

a[n]:=1/n!;

niz3:points(makelist([n,a[n]],n,1,8))$

wxdraw2d(xrange=[0,8.5], yrange=[-0.2,1.1], xtics=[0,1,9],
   color=blue, point_size=2, point_type=7, niz3), wxplot_size=[700,500]$

draw2d(terminal=wxt, xrange=[0,8.5], yrange=[-0.2,1.1], xtics=[0,1,9],
   color=blue, point_size=2, point_type=7, niz3)$

d)

kill(a)$

a[n]:=(-1)^n/n!;

niz4:points(makelist([n,a[n]],n,1,8))$

wxdraw2d(xrange=[0,8.5], yrange=[-1.1,0.6], xtics=[0,1,9],
   color=blue, point_size=2, point_type=7, niz4), wxplot_size=[700,500]$

draw2d(terminal=wxt, xrange=[0,8.5], yrange=[-1.1,0.6], xtics=[0,1,9],
   color=blue, point_size=2, point_type=7, niz4)$

e)

kill(a)$

a[n]:=(3*n-18)/(3*n-19);

niz5:points(makelist([n,a[n]],n,1,15))$

wxdraw2d(xrange=[0,15.5], yrange=[-1,2], xtics=[0,1,15],
   color=blue, point_size=2, point_type=7, niz5), wxplot_size=[700,500]$

draw2d(terminal=wxt,xrange=[0,15.5], yrange=[-1,2], xtics=[0,1,15],
   color=blue, point_size=2, point_type=7, niz5)$