On Tue, Jul 04, 2023 at 10:48:10PM +0200, Ralf Hemmecke wrote: > (458) -> sqrt(s2) > > +--------------------------------------------------------+ > | +--+ > \|1097675101059710976000 %i\|67 + 36223278334970462208000 > (458) ----------------------------------------------------------- > 17 > Type: Expression(Complex(Integer)) > > (459) -> factor gcd(1097675101059710976000,36223278334970462208000) > > 18 5 3 3 2 > (459) 2 3 5 11 10177 > > Is there some easy way (a fricas function) to obtain from sqrt(s2) an > expression that has moved all common quadratic parts under the square root > outside? > > I would like to see something like > > +------------------+ > | +--+ > 2579258880 \|165 %i\|67 + 5445 > (471) -------------------------------- > 17 > Type: Expression(Complex(Integer)) >
Well, this is probably too much: rootFactor(sqrt(p1)) +-------------+ +--------+ +------+ +-+ +--+ | +--+ (70) 2579258880 \|1 + 2 %i \|2 + %i \|3 \|11 \|\|67 - 33 %i We have ingredients like nthRoot(squareFree(1097675101059710976000), 2)$FactoredFunctions(Integer) (61) [exponent = 2, coef = 2579258880, radicand = [3, 5, 11]] qroot(1097675101059710976000/1, 2)$pR (63) [exponent = 2, coef = 2579258880, radicand = 165] and content and primitivePart: p1 := 1097675101059710976000*%i*sqrt(67) + _ 36223278334970462208000::EXPR(COMPLEX(INT)) content(numer(p1)) (65) 1097675101059710976000 primitivePart(numer(p1)) +--+ (66) \|67 - 33 %i In a sense closest to what you want is 'froot' from PolynomialRoots but it does not handle integer content (which AFAICS is delibarate decision due to potentially prohibitive cost of integer factorization). It would be easy to add variant of 'froot' which handles also integer content. OTOH calling anything from PolynomialRoots is far from easy. For example pR above was defined via this sequence of assignments: vV := Kernel(Expression(Complex(Integer))) eE := IndexedExponents(vV) sP := SparseMultivariatePolynomial(Complex(Integer), _ Kernel(Expression(Complex(Integer)))) pR := POLYROOT(eE, vV, Complex(Integer), sP, Expression(Complex(Integer))) Probably better would be do such transformation in 'rootSimp', but again they can be quite expensive, so debatable is should be done by default. And of course, 'rootSimp' can do things which you do not want... BTW: For roots of rational numbers AlgebraicFunction is doing this by defualt: sqrt(1097675101059710976000) +---+ (67) 2579258880 \|165 But such transformations sometimes are undesirable. -- Waldek Hebisch -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZKSXGuFBGaOdldrN%40fricas.math.uni.wroc.pl.