Factoring as list

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 574
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Factoring as list

Message par compsystems » sam. août 12, 2017 12:45 am

Xcas has a command that returns a list of expressions, but without multiplicity?

1:
factors( x^4-1 ) returns
[x-1,1,x+1,1,x^2+1,1]

2:
factor( x^4-1 ) returns
(x-1)*(x+1)*(x^2+1)

3:
split( x^4-1, x) returns
Error =(

x^4-1 ->
[x-1,x+1, x^2+1]

parisse
Messages : 5771
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Factoring as list

Message par parisse » sam. août 12, 2017 5:01 am

you can easily write a user program from the output of factors to do that.

compsystems
Messages : 574
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: Factoring as list

Message par compsystems » mer. août 16, 2017 2:44 pm

Code : Tout sélectionner

   splits(pol):=
  {
   fs:=factors(pol);
   sz:=size(fs);
   return seq('fs[k-1]',k,1,sz,2);
  }


1:
factors(x^4-1) returns
[x-1,1,x+1,1,x^2+1,1]

2:
splits(x^4-1) returns
[x-1,x+1,x^2+1]

3:
split(x^4-1,[x,y]) trick
[(x-1)*(x+1)*(x^2+1), 1]


An idea, I like that commands embedded in the system
add a Full keyword, to denote total separation, As does matlab
https://www.mathworks.com/help/symbolic/factor.html :mrgreen:

4:
split(x^4-1,x,'full')
[x-1,x+1,x^2+1]

Répondre