## Una breve introducción a Maxima: "Minima" Maxima

/* BREVISIMA INTRODUCCION A MAXIMA */

/* Operaciones aritmeticas */

3+2*3; 2+2; 3-3; 2*3; 5/10; 3^3;

float(27);

e;

float(e);

pi;

float(pi);

%e;

float(%e);

fpprec:50;

bfloat(%e); bfloat(%pi);

/* b3 significa 10^3 */ 
bfloat(%e^7);

float(%e^7);

??fpprec;

??float

??renato;

bfloat(%e^7);

%e^7;

(2+3^2)^3*(5*3+2^2);

/* definiendo variables */  

x:123; 
y:321; 
x*y; 
x/y; 
x-y;

z;

z:4;

z;

123*321;

x;

z=2;

z;

x;

y;

x*y;

x+z;

 x y;

xy;

/* Definiendo funciones */

f(x):= x^2 -x + 1;

f(%pi);

float(%);

float(f(%pi));

x;

%o13;

/* AYUDA Manual online: Maxima CAS*/

/* Dibujando funciones */

wxplot2d([f(x)], [x,-5,5]);

wxplot2d([f('x)], ['x,-5,5]);

plot2d([f('x)], ['x,-5,5])$

wxplot2d([f('x),2*sin('x),atan('x),-5*x], ['x,-2,2],['y,-3,8]);

/* Variables y funciones */

log(10);

float(%);

log(%e);

15!;

factor(%);

x:123;

factor(x^2 + x -6);

123^2+123-6;
factor(%);

factor('x^2 + 'x -6);

kill(x);
x;

kill(x)$
ratsimp((x^2-1)/(x-1));

/* RESOLVIENDO ECUACIONES */

solve(x^2-4=0,x);

solve(x^2-a^2-4,x);

solve(x^2-4=a^2-2,a);

solve(x^2=-1);

%i*%i;

solve(x^5=1,x);

rectform(%);

float(%);

float(solve(x^5=1,x));

kill(n);

solve(x^n=1,x);

sol:solve(x^8=1,x);

sol[1];

second(sol[1]);

rhs(sol[1]);

rectform(sol);

## Primeros pasos con el Cálculo

/* Limites: Primeros ejemplos */

limit(sin(a*x)/x,x,0);

limit(exp(1/(1-x)),x,1);

limit(exp(1/(1-x)),x,1,plus);

limit(exp(1/(1-x)),x,1,minus);

limit(exp(-1/(1-x)^2),x,1);

limit(log(x),x,0);

limit(log(x),x,0,plus);

limit(log(x),x,0,minus);

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

/* Limites: Ejemplos */;

limit(sin(1/n)/(1/n),n,inf);

limit(sin(3*x)/(x),x,0);

limit(log(1+x)/x,x,0);

limit((x+1)/abs(x-1),x,1,plus);

limit((x+1)/abs(x-1),x,1,minus);

limit((x+1)/abs(x-1),x,1);

limit((x+1)/abs(x-1),x,inf);

limit((x+1)/abs(x-1),x,-inf);

limit( sin(1/x),x,0);

limit( x*sin(1/x),x,0);

limit((2*x-sin(x))/sqrt(1-cos(x)),x,0);

wxplot2d((2*x-sin(x))/sqrt(1-cos(x)),[x,-1,1]);

limit((2*x-sin(x))/sqrt(1-cos(x)),x,0,minus);

limit((2*x-sin(x))/sqrt(1-cos(x)),x,0,plus);

limit((1*x-sin(x))/sqrt(1-cos(x)),x,0);

/* Derivadas: Primeros ejemplos */;

diff(sin(x^2+2),x);

diff(x^x, x,3);

(sin(x))^x;

diff(sin(x)^x, x);

g(x):= sin(x*log(1+x^2));

diff(g(x),x,1);

ratsimp(%);

radcan(%);

factor(%);

expand(%);

trigsimp(%);

/* Integrando: Primeros ejemplos */

integrate(sin(2*x), x);

int(x):=integrate(x+1/(x -3), x);

int(x);

wxplot2d([int('x)], ['x,2,7])$

diff(int(x),x,1);

vnum1:integrate(x+1/(x -3), x, 0,1);

int(1)-int(0);

int(1);

integrate(x+1/(x -3), x);

define(intprim(x),%);

define(intprim(x),int(x));

intprim(1);

intprim(1)-intprim(0);

%-vnum1;

rectform(%);

rectform(log(-2));

rectform(log(-3));

assume (a > 1)$
integrate (x^a*%e^(-x), x, 0, inf);

assume (a > 1)$
integrate (x**a/(x+1)**(5/2), x, 0, inf);

??beta;

??assume;

x^a*exp(-x);

kill(a);

integrate (x^a*exp(-x), x, 0, inf);

??gamma;

1;

integrate (x**a*exp(-x), x, 0, inf);

assume (a > 1)$
integrate (x^a*exp(-x), x, 0, inf);

integrate (x**(1/2)/(x+1)**(5/2), x, 0, inf);

/* Polinomio de Taylor */;

kill(all);

taylor(%e^x,x,0,5);

taylor(sin(x),x,0,5);

integrate(%,x);

diff(%,x);

/* Exportando gráficos */;

 plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi],
[y, -2, 2],  [ps_file, "/home/renato/trig.eps"]);

plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi],
[y, -2, 2], [png_file, "/home/renato/trig.png"]);

plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi],
[y, -2, 2], [pdf_file, "/home/renato/trig.pdf"]);

## Sucesiones por recurrencia

/* Definiendo sucesiones por recurrencia */

### Primeros ejemplos

/* Ejemplo 1 */ 

kill(a);
a[1]:sqrt(2); 
a[n]:=sqrt(2+a[n-1]);

la:makelist([k,float(a[k])],k,10);

wxplot2d([discrete,la]);

wxplot2d([discrete,la],[y,1,2.4]);

wxplot2d([[discrete,la],2],[x,1,10], [y,1,2.4], [style, points, lines], [point_type, bullet]);

makelist([k,float(a[k]-2)],k,10);

/* Ejemplo 2 */ 

kill(a,p,la);
p:2;
a[1]:2; 
a[n]:=1/2*(a[n-1]+p/a[n-1]);
la:makelist([k,float(a[k])],k,10);

wxplot2d([discrete,la],[style, points]);

wxplot2d([[discrete,la],sqrt(2)],[x,.9,10.1],[y,1.3,2.3], [style, points, lines], [point_type, bullet]);

makelist([k,float(a[k]-sqrt(2))],k,10);

### Otros ejemplos 

kill(all);

/* Ejemplo 3 */ 

ec:a[n]*a[n-1]=2+a[n-1];

load("solve_rec")$

solve_rec(ec,a[n]);

solve_rec(ec,a[n],a[1]=12);

define(suc(n),second(ratsimp(%)));

la:makelist([k,float(suc(k))],k,10);

/* Ejemplo 4 */ 

kill(a,la);
a[1]:1; 
a[n]:=(4+3*a[n-1])/(3+2*a[n-1]);
la:makelist([k,float(a[k])],k,10);

kill(ec,a);
ec:a[n]=(4+3*a[n-1])/(3+2*a[n-1]);
solve_rec(ec,a[n]);

solve_rec(ec,a[n],a[1]=1);

ratsimp(%);

define(sol[n],second(%));

la:makelist([k,float(sol[k])],k,10);