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))
The following probably is doing what you want:
(1) -> p1 := 1097675101059710976000*%i*sqrt(67) + 36223278334970462208000
+--+
(1) 1097675101059710976000 %i\|67 + 36223278334970462208000
Type: Expression(Complex(Integer))
(2) -> r1 := sqrt(p1)
+--------------------------------------------------------+
| +--+
(2) \|1097675101059710976000 %i\|67 + 36223278334970462208000
Type: Expression(Complex(Integer))
(3) -> r1f := rootFactor(r1)
+-------------+
+--------+ +------+ +-+ +--+ | +--+
(3) 2579258880 \|1 + 2 %i \|2 + %i \|3 \|11 \|\|67 - 33 %i
Type: Expression(Complex(Integer))
(4) -> sqrt_rule := rule sqrt(x)*sqrt(y) == sqrt(-%i*%i*x*y)
+-+ +-+ +---+
(4) %D\|x \|y == %D\|x y
Type: RewriteRule(Integer,Complex(Integer),Expression(Complex(Integer)))
(5) -> sqrt_rule(r1f)
+------------------+
| +--+
(5) 2579258880 \|165 %i\|67 + 5445
Type: Expression(Complex(Integer))
So first use rootFactor to expand root into product of integer and
other roots, then combine roots together using rewrite rule.
Note: there is silly looking '-%i*%i' in the right hand of the rule,
I used it to force type to Expression(Complex(Integer)), otherwise
we would get rule applicable to Expression(Integer), but not
applicable to Expression(Complex(Integer)).
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/ZKXmYRO9fFC7g7qn%40fricas.math.uni.wroc.pl.