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="x",
    ylabel="f(x)")$

## Svojstva funkcija

a)

f(x):=2*sqrt(x)/(3-x^2);

wxdraw2d(xrange=[-1,5], yrange=[-5,5], 
     line_width=3, color=blue, explicit(f(x),x,0,5),
     line_width=2, color=black, line_type=dots, 
       parametric(sqrt(3),t,t,-5,5)), wxplot_size=[600,400]$

draw2d(terminal=wxt,xrange=[-1,5], yrange=[-5,5], 
     line_width=3, color=blue, explicit(f(x),x,0,5),
     line_width=2, color=black, line_type=dots, 
       parametric(sqrt(3),t,t,-100,100))$

b)

f(x):=sqrt(x+5);

wxdraw2d(xrange=[-10,50], yrange=[-1,8], 
     line_width=3, color=blue, explicit(f(x),x,-5,50)), wxplot_size=[600,400]$

draw2d(terminal=wxt,xrange=[-10,50], yrange=[-1,8], 
     line_width=3, color=blue, explicit(f(x),x,-5,50))$

c)

f(x):=4/(x^2+3);

wxdraw2d(yrange=[-0.3,1.5], 
     line_width=3, color=blue, explicit(f(x),x,-10,10)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-0.3,1.5], 
     line_width=3, color=blue, explicit(f(x),x,-10,10))$

d)

f(x):=%e^(5-x);

wxdraw2d(yrange=[-50,680],line_width=3, 
   color=blue, explicit(f(x),x,-1.5,4)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-50,680],line_width=3, 
   color=blue, explicit(f(x),x,-1.5,4))$

e)

f(x):=2*x^2/(3-x^2);

wxdraw2d(yrange=[-10,10], line_width=3, ytics=[-10,2,10],xtics=[-4,1,4], 
   color=blue, explicit(f(x),x,-5,5),
   color=black, line_type=dots, line_width=2, 
   parametric(t,-2,t,-5,5), parametric(-sqrt(3),t,t,-10,10),
   parametric(sqrt(3),t,t,-10,10)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-10,10], line_width=3, ytics=[-100,2,100],xtics=[-4,1,4], 
   color=blue, explicit(f(x),x,-5,5),
   color=black, line_type=dots, line_width=2, 
   parametric(t,-2,t,-5,5), parametric(-sqrt(3),t,t,-100,100),
   parametric(sqrt(3),t,t,-100,100))$

f)

f(x):=(x+5*x^5)^(1/3);

wxdraw2d(line_width=3, color=blue, 
   explicit(f(x),x,-3,3)), wxplot_size=[600,400]$

draw2d(terminal=wxt,line_width=3, color=blue, 
   explicit(f(x),x,-3,3))$

g) trebamo biti oprezni

f(x):=log((3+2*x)/(3-2*x))/log(4);

mogli bismo dobiti krivi dojam da je funkcija omeđena

wxdraw2d(xrange=[-3,3], yrange=[-5,5], xtics=[-3,0.5,3], ytics=[-5,1,5], 
   line_width=3, color=blue, explicit(f(x),x,-3/2,3/2)), wxplot_size=[600,400]$

stavimo li decimalne brojeve -1.499 i 1.499 da se čim više približimo rubovima -3/2 i 3/2

wxdraw2d(xrange=[-3,3], yrange=[-7,7], xtics=[-3,1,3], ytics=[-7,1,7], 
   line_width=3, color=blue, explicit(f(x),x,-1.499,1.499),
   line_width=2, color=black, line_type=dots,
   parametric(-3/2,t,t,-7,7), parametric(3/2,t,t,-7,7)), wxplot_size=[600,400]$

draw2d(terminal=wxt,xrange=[-3,3], xtics=[-3,1,3],
   line_width=3, color=blue, explicit(f(x),x,-1.4999,1.4999),
   line_width=2, color=black, line_type=dots,
   parametric(-3/2,t,t,-7,7), parametric(3/2,t,t,-7,7))$

možemo izračunati i limese

limit(f(x),x,3/2,minus);

limit(f(x),x,-3/2,plus);

h)

f(x):=%e^(x^2-4*x+3)-1;

wxdraw2d(yrange=[-5,70], xrange=[-1,4.5],
   line_width=3, color=blue, explicit(f(x),x,-0.3,4.3)), wxplot_size=[400,600]$

draw2d(terminal=wxt,yrange=[-5,70], xrange=[-1,4.5],
   line_width=3, color=blue, explicit(f(x),x,-0.3,4.3))$

i)

f(x):=sin(2*x)*cos(3*x);

wxdraw2d(yrange=[-1,1], xrange=[-11,11],
   line_width=3, color=blue, explicit(f(x),x,-10,10)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-1,1], xrange=[-11,11],
   line_width=3, color=blue, explicit(f(x),x,-10,10))$

j)

f(x):=sin(1/x);

wxdraw2d(yrange=[-1.2,1.2],
   line_width=3, color=blue, explicit(f(x),x,-3,3)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-1.2,1.2],
   line_width=3, color=blue, explicit(f(x),x,-3,3))$

## Injekcija, surjekcija, bijekcija

a)

f(x):=log(4*x^2)/log(2);

wxdraw2d(yrange=[-7,7], nticks=200,
   line_width=3, color=blue, explicit(f(x),x,-5,5)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-7,7], nticks=200,
   line_width=3, color=blue, explicit(f(x),x,-5,5))$

b)

f(x):=2^(x+3);

wxdraw2d(yrange=[-10,70],nticks=200,
   line_width=3, color=blue, explicit(f(x),x,-3,3)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-10,70],nticks=200,
   line_width=3, color=blue, explicit(f(x),x,-3,3))$

c)

f(x):=3/(3*x^2+1);

wxdraw2d(yrange=[-0.5,3.5],
   line_width=3, color=blue, explicit(f(x),x,-5,5)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-0.5,3.5],
   line_width=3, color=blue, explicit(f(x),x,-5,5))$

d)

f(x):=x/(4-2*x);

wxdraw2d(yrange=[-5,5], ytics=[-5,1,5],
   line_width=3, color=blue, explicit(f(x),x,-5,5),
   line_width=2, color=black, line_type=dots,
   parametric(t,-1/2,t,-5,5),parametric(2,t,t,-5,5)), wxplot_size=[600,400]$

draw2d(terminal=wxt,yrange=[-5,5], ytics=[-100,1,100],
   line_width=3, color=blue, explicit(f(x),x,-5,5),
   line_width=2, color=black, line_type=dots,
   parametric(t,-1/2,t,-5,5),parametric(2,t,t,-100,100))$

## Inverzna funkcija

a)

f(x):=(2*x-1)/(1-x);

inverzna funkcija

solve(y=(2*x-1)/(1-x),x);

g(x):=(x+1)/(x+2);

wxdraw2d(yrange=[-5,5], xtics=[-5,1,5], ytics=[-5,1,5], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-5,5),
   color=red, explicit(g(x),x,-5,5),
   color=green,line_width=2,explicit(x,x,-5,5)), wxplot_size=[500,500]$

draw2d(terminal=wxt,yrange=[-5,5], xtics=[-100,1,100], ytics=[-100,1,100], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-5,5),
   color=red, explicit(g(x),x,-5,5),
   color=green,line_width=2,explicit(x,x,-5,5))$

b)

f(x):=5^(1-x/3);

inverzna funkcija

solve(y=5^(1-x/3),x);

expand(%);

g(x):=3-3*log(x)/log(5);

wxdraw2d(yrange=[-2,10], xtics=[-5,1,10], ytics=[-1,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-5,10),
   color=red, explicit(g(x),x,0.01,10),
   color=green,line_width=2,explicit(x,x,-5,10)), wxplot_size=[600,500]$

draw2d(terminal=wxt,yrange=[-2,10], xtics=[-5,1,10], ytics=[-1,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-5,10),
   color=red, explicit(g(x),x,0.001,10),
   color=green,line_width=2,explicit(x,x,-5,10))$

c)

f(x):=log(x)/log(3)+2;

inverzna funkcija

solve(y=f(x),x);

radcan(%);

g(x):=3^(x-2);

wxdraw2d(yrange=[-2,10], xtics=[-3,1,10], ytics=[-1,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,0.01,10),
   color=red, explicit(g(x),x,-2,10),
   color=green,line_width=2,explicit(x,x,-2,10)), wxplot_size=[500,500]$

draw2d(terminal=wxt,yrange=[-2,10], xtics=[-3,1,10], ytics=[-1,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,0.01,10),
   color=red, explicit(g(x),x,-2,10),
   color=green,line_width=2,explicit(x,x,-2,10))$

d)

f(x):=log(x+2)/log(3);

inverzna funkcija

solve(y=f(x),x);

radcan(%);

g(x):=3^x-2;

wxdraw2d(yrange=[-4,10], xtics=[-3,1,10], ytics=[-4,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-1.99,10),
   color=red, explicit(g(x),x,-4,10),
   color=green,line_width=2,explicit(x,x,-4,10)), wxplot_size=[500,500]$

draw2d(terminal=wxt,yrange=[-4,10], xtics=[-3,1,10], ytics=[-4,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-1.99,10),
   color=red, explicit(g(x),x,-4,10),
   color=green,line_width=2,explicit(x,x,-4,10))$

e)

f(x):=sqrt(x+1);

inverzna funkcija

solve(y=f(x),x);p;

g(x):=x^2-1;

wxdraw2d(yrange=[-4,10], xtics=[-3,1,10], ytics=[-4,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-1,10),
   color=red, explicit(g(x),x,0,10),
   color=green,line_width=2,explicit(x,x,-4,10)), wxplot_size=[500,500]$

draw2d(terminal=wxt,yrange=[-4,10], xtics=[-3,1,10], ytics=[-4,1,10], proportional_axes=xy,
   line_width=3, color=blue, explicit(f(x),x,-1,10),
   color=red, explicit(g(x),x,0,10),
   color=green,line_width=2,explicit(x,x,-4,10))$