Sei sulla pagina 1di 2

La funcin pretty.

Imprime en un formato agradable las


expresiones:
Ejemplo:
>> syms x >> f = x^3 - 6*x^2 + 11*x - 6;
>> g = (x - 1)*(x - 2)*(x - 3);
>> h = -6 + (11 + (-6 + x)*x)*x;
>> pretty(f) 3 2 x - 6 x + 11 x - 6
>> pretty(g); (x - 1) (x - 2) (x - 3)
>> pretty(h); x (x (x - 6) + 11) 6

Veamos las funciones expand,.


Ejemplo:
>> syms x;
>> f=(x^2- 1)*(x^4 + x^3 + x^2 + x + 1)*(x^4 - x^3 + x^2 - x + 1);
>> expand(f)
ans = x^10 1 >> g = x^3 + 6*x^2 + 11*x + 6;
factor
>> factor(g)
ans = (x + 3)*(x + 2)*(x + 1)
>> h = x^5 + x^4 + x^3 + x^2 + x;
y horner
>> horner(h)
ans = x*(x*(x*(x*(x + 1) + 1) + 1) + 1)
Veamos la funcin collect.
Ejemplo:
>> syms x y;
>> R1 = collect((exp(x)+x)*(x+2))
R1 = x^2 + (exp(x) + 2)*x + 2*exp(x)
>> R2 = collect((x+y)*(x^2+y^2+1), y)
R2 = y^3 + x*y^2 + (x^2 + 1)*y + x*(x^2 + 1)
>> R3 = collect([(x+1)*(y+1),x+y])
R3 = [ y + x*(y + 1) + 1, x + y]

La funcin simple trata de reescribir la expresin empleando la


menor cantidad de caracteres. Ejemplo:
>> syms x;
>> f = cos(x)^2 + sin(x)^2;
>> f = simple(f)
f=1
>> g = cos(3*acos(x));
>> g = simple(g)
g = 4*x^3 - 3*x

Potrebbero piacerti anche