Thank you for your bug report "maxima: Incorrect remainder evaluation with
unbound variables" (
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1013232).

A simpler version of your report:


remainder(5,x) => 5
remainder(5,2) => 1
remainder(y^2-x^2, x+y+1) => 2*x+1


The *remainder *function performs *explicit polynomial division,* and never
returns a noun form (a.k.a. unmodified input).

I think what you're looking for is the *mod* function, which is the
*mathematical*, *declarative, *or* simplifying* version of the function:

mod(5,x) => mod(5,x)

mod(5,2) => 1
mod(y^2-x^2, x+y+1) => mod(y^2-x^2, x+y+1)


Unfortunately, *mod* currently doesn't have many simplifications defined
for it:

declare(q,integer)
mod(4*q+2,q) => mod(4*q+2,q) ... why not mod(q+2,q) ?

It really should have been able to perform that last simplification.

Be careful: *mod*, *remainder, *and *modulus* aren't defined the same on
integers:

mod(8,5) => 3
remainder(8,5) => 3
rat(8),modulus:5 => -2

mod(-8,5) => 2
remainder(-8,5) => -3
rat(-8),modulus:5 => 2



On Wed, May 14, 2025 at 5:48 PM Camm Maguire <c...@maguirefamily.org> wrote:

> tags 1013232 forwarded maxima-disc...@lists.sourceforge.net
> thanks
>
> Greetings, and thanks for your report!
>
> =============================================================================
> Dear Maintainer,
>
> entering
>
>     2 * remainder(45, 7);
>
> returns 6, as expected.
>
>
> But using an unbound variable, a in this case,
>
>     2 * remainder(45, a);
>
> returns 90, which is incorrect. The input should be returned unchanged.
>
> =============================================================================
>
> Take care,
> --
> Camm Maguire                                        c...@maguirefamily.org
> ==========================================================================
> "The earth is but one country, and mankind its citizens."  --  Baha'u'llah
>
>
> _______________________________________________
> Maxima-discuss mailing list
> maxima-disc...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>

Reply via email to