Skip to content

i think mod(a,b) are considering only integers solutions #26016

@joaorrmattos

Description

@joaorrmattos

Hello guys, i have a simplification of my code which is:

import sympy as sp
import itertools

Zp = range(3)
Zq = range(3) 
sextetos = itertools.product(Zp, Zp, Zp, Zq, Zq, Zq)


x, y, z, w = sp.symbols('x y z w', real=True)
system = []
#it will test the generic form: B(a,b) = x*a1*b1+y*a1*b2+z*a2*b1+w*a2*b2, for all pairs a= (a1,a2), b=(b1,b2) e c=(c1,c2)
#both mapping axioms, and return the set of conditions that x, y, z e w must satisfy.

for a1, b1, c1, a2, b2, c2 in sextetos:
 d1 = (b1 + c1) % p
 d2 = (b2 + c2) % q   
 if (a1, b1, c1, a2, b2, c2) != (0, b1, c1, 0, b2, c2):
    print(a1,b1,c1,a2,b2,c2)
    eq1 = ((x * (a1 * b1+b1 * a1)+y * (a1 * b2+b1 * a2)+z * (a2*b1+b2 * a1)+w * (a2 * b2+a2 * b2))) % 2
    system.append(eq1)
    eq2 = (x * (a1 * ((b1+c1)%p))+y * (a1 * ((b2+c2)%q))+z * (a2 * ((b1+c1)%p))+w * (a2*((b2+c2)%q)) - (x * a1 * (b1+c1)+y * a1 * (b2+c2)+z * a2*(b1+c1)+w * a2 * (b2+c2))) % 2
    eq2 = (x * a1 * (sp.Mod(b1+c1,p)-(b1+c1))+y * a1 * (sp.Mod(b2+c2,q)-(b2+c2))+z * a2 * (sp.Mod(b1+c1,p)-(b1+c1))+w * a2 * (sp.Mod(b2+c2,q)-(b2+c2))) % 2
    print(eq1)
    print(eq2)
    input()
vars = [x, y, z, w]
print(sp.nonlinsolve(system, vars)) 

I was feeling something was a litte bit wrong with this code, because the conditionset it returns has some rules that i know that doesnt exist, like for the sexteto (a1,b1,c1,a2,b2,c2) = (0,0,0,1,1,2), eq2 should be w * 1 * (-3) % 2. Or, with sp tools: Eq(3*Mod(w,2),0), considering the possibility of w = 2/3 (example). However, the code returns me just Eq(Mod(w,2),0), and i just cant understand why...

Important that: the error is before the nonlinsolve function. If u just put a print(eq2) with the equations.append(eq2), it will return (Eq(Mod(w,2),0).

If someone have an ideia of what is happening, please give me a hand.

Merry Christmas, gifhubbers :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    Easy to FixThis is a good issue for new contributors. Feel free to work on this if no one else has already.core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions