# Tema 6 
06-2  Representació gràfica de funcions
Representació gràfica de corbes planes

## Representació gràfica en 2D

kill(all)$

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

wxplot2d([f(x)], [x,-4,4])$

wxplot2d([g(x)], [x,-4,4])$

wxplot2d([g(x)], [x,-4,4] , 
[gnuplot_preamble, "set size ratio 1"]  )$

wxplot2d([g(x)], [x,-4,4] , 
[gnuplot_preamble, "set size ratio 1; set grid"]  )$

wxplot2d([g(x)], [x,-4,4] , 
[gnuplot_preamble, "set size ratio 1; set grid"] , [style, [lines, 2]] )$

wxplot2d([g(x)], [x,-4,4] , [y, 0, 8] ,
               [gnuplot_preamble, "set size ratio 1; set grid; "] , [style, [lines, 2]] )$

wxplot2d([f(x),g(x)], [x,-4,4] , 
[gnuplot_preamble, "set size ratio 1; set grid; "] , [legend, "f(x)" , "g(x)"] , [style, [lines, 2]] )$

## Gràfica de funcions definides a trossos

kill(all)$

f1(x):=2*x+1$           f2(x):=sqrt(1+x^2)$
F1(x):= if x<0 then f1(x) else f2(x);

wxplot2d([F1(x)], [x,-6,6] , [y, -6, 6],
[gnuplot_preamble, "set size ratio 1; set grid; "] , [legend, "F1(x)"] , [style, [lines, 2, 2]] , [ylabel, ""] )$

g1(x):=exp(x/2)$        g2(x):=1+x*log(x/2)$        g3(x):=exp(2-x)$
G1(x):= if x<=0 then g1(x) else (if x<=2 then g2(x) else g3(x));

wxplot2d([G1(x)], [x,-6,6] , [legend, "G1(x)"] , [style, [lines, 2, 3]] , [ylabel, ""])$

wxplot2d([G1(x)], [x,-6,6] , [y, 0, 1.4],
[gnuplot_preamble, "set size ratio 1; set grid; "] , [style, [lines, 2, 1]] , [ylabel, ""]  )$

## Gràfica de corbes planes

kill(all)$

load(draw)$
wxdraw2d(   
   grid = true,    line_type = solid,  line_width = 2, color = blue,
    implicit(x^2+y^2-1=0, x, -3.0,3.0, y, -2,2)
);

load(draw)$
wxdraw2d(   
   grid = true,    line_type = solid,  line_width = 3, color = red,
    implicit((x-2)^2+(y-3)^2-4=0, x, -1,5, y, 0,6)
);

load(draw)$
wxdraw2d(   
   grid = true,    line_type = solid,  line_width = 2, color = green,
    implicit(y^2+2*y+1-x=0, x, -1,5, y, -4,2)
);