# Sesión 1

Miguel Piñar, 19/09/2011

## Cálculos numéricos

2+2;

2+2$

-2 + 5;

2*3;

2 3;

4/2;

2^3;

1/3;

2/6;

1/3 + 2/5;

2^10000;

set_display('ascii)$

2^10000;

set_display('xml)$

2^1000;

2.15;

2.3*3.4;

2/3;

2.0/3;

2/3,numer;

if numer#false then numer:false else numer:true;

2/3;

if numer#false then numer:false else numer:true;

2/3;

float(%), numer;

float(2/3);

bfloat(%);

bfloat(2/3);

fpprec : 32;

bfloat(2/3);

fpprec:50;

bfloat(2/3);

float(2/3);

2/3,numer;

%pi;

%pi,numer;

bfloat(%pi);

%e,numer;

%i;

%i^2;

2+3*%i;

%phi,numer;

%Alpha;

%phi;

(2+3*%i)^2;

rectform(%);

polarform(%);

rectform(%);

realpart(%);

imagpart(%o51);

a:2+7*%i;

a^2;

rectform(a^2);

realpart(a);

imagpart(a^2);

a:1$
b:2$
c:a+b;

a:1;
b:2;
c:a+b;

(
a:1,
b:2,
c:a+b
);

## Funciones

sin(x);

sin(%pi);

sin(2);

sin(2.0);

sin(2),numer;

float(sin(2)) /* comentario */ ;

log10(x):=log(x)/log(10.0);

log10(10.0);

log10(1000.0);

plot2d([log10(x)], [x,0.1,5],
 [plot_format, gnuplot],
 [gnuplot_preamble, "set size ratio 1; set zeroaxis;"])$

plot2d([log10(x),log(x),log(x)/log(2.0)], [x,0.1,5],
 [plot_format, gnuplot],
 [gnuplot_preamble, "set size ratio 1; set zeroaxis;"])$

kill(a,b,c);

suma(a,b):=a+b$

suma(2,5);

f(x,y):=sin(x+cos(y));

plot3d(f(x,y), [x,-5,5], [y,-5,5], [plot_format,gnuplot])$

plot3d(f(x,y), [x,-5,5], [y,-5,5], [plot_format,gnuplot],
 [gnuplot_preamble, "set pm3d at s; unset surf"])$

plot3d(f(x,y), [x,-5,5], [y,-5,5], [plot_format,gnuplot],
 [grid,50,50],
 [gnuplot_pm3d,true])$

plot3d(f(x,y), [x,-5,5], [y,-5,5], [plot_format,gnuplot],
 [grid,50,50],
 [gnuplot_preamble, "set pm3d at s; unset surf; unset colorbox"])$

suma(a,b):=(c:a+b,c);

suma(2,3);

suma(x,2);

c;

suma(a,b):=block([c],
                 c:a+b,
                 c
                );

suma(2,3);

c;

producto_complejo(a,b):=rectform(a*b);

producto_complejo(2,3);

producto_complejo(2+%i,2-%i);

## Listas

[1,2,3];

kill(a,b,c);

m:[a,b,c];

m[2];

m[4];

m[0];

cons(x,m);

m;

endcons(x,m);

m:endcons(d,m);

m;

length(m);

append([x,y,z],m);

append(m,[x]);

first(m);

last(m);

second(m);

delete(b,m);

reverse(m);

makelist(k^2,k,20,2,-2);

numeros:makelist(k,k,1,10);

numeros^2;

numeros+3;

1/numeros;

numeros*numeros;

sqrt(numeros),numer;

raices:sqrt(float(numeros));

plot2d([discrete,numeros,raices],[style,points]);

lista:makelist(random(1.0),k,1,10);

sort(lista);

lista2:makelist(random(1.0),k,1,10);

sort([a,x,c]);