On Tue, Jun 16, 2026 at 05:58:08PM +0800, Qian Yun wrote:
> New optimization for today:
> 
> If x and y does not have common algebraic kernels, either:
> 
> 1. they don't have algebraic kernels at all, so they are
> canonical under FRAC SMP, so previous check is enough.

That is true for Expression(Integer) and probably also for
Expression(Complex(Integer)), but may fail for more general
coefficients.  Internally we sometimes use
Expression(Expression(Integer))...

So any such thing must be conditional, limited to "good"
coefficients.

> 2. they have different algebraic kernels.  Then there's
> no way they can be equal.

That looks obvious, but I have seen various strange examples,
so it would be better to have a proof.

This certainly fails for say Expression(AlgebraicNumber).

> For mapleok.input, this saves around 30% memory and 15% time.
> 
> - Qian
> 
> diff --git a/src/algebra/expr.spad b/src/algebra/expr.spad
> index ed89a42f..08fecfcc 100644
> --- a/src/algebra/expr.spad
> +++ b/src/algebra/expr.spad
> @@ -103,9 +103,11 @@
>              x : % / y : %        == algreduc(x /$Rep y, commonk(x, y))
>              x : % = y : % ==
>                  denom(x) = denom(y) => numer(x) = numer(y)
> +                lk := commonk(x, y)
> +                empty? lk => false
>                  -- we only need to care about the numerator of (x - y)
>                  res := (numer(x)*denom(y) - numer(y)*denom(x))::Rep
> -                zero?(reduc(res, commonk(x, y)))$Rep
> +                zero?(reduc(res, lk))$Rep
> 
>              number?(x : %) : Boolean ==
>                  if R has RetractableTo(Integer) then
> 
> -- 
> 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 visit 
> https://groups.google.com/d/msgid/fricas-devel/74de9c95-3b7a-483e-a7d1-0cc6e473f9d9%40gmail.com.

-- 
                              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 visit 
https://groups.google.com/d/msgid/fricas-devel/ajEzx8AQo7vSEldg%40fricas.org.

Reply via email to