Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Cómo obtener sympy para dar soluciones con coeficientes más pequeños

Considere el siguiente ejemplo Ecuación diofántica

 -118w + 989x + 918y -512z == 0

Puedes resolver esto en sympy con:

 import sympy from sympy.solvers.diophantine import diophantine w, x, y, z = sympy.symbols('wxy z') a, b, c, d = -118, 989, 918, -512 diof = list(diophantine(a*w + b*x +c*y +d*z ))[0] print(diof)

lo que da:

 (t_0, 118*t_0 + 2*t_1, 1690468*t_0 + 28937*t_1 + 256*t_2, 3031184*t_0 + 51887*t_1 + 459*t_2)

Explicación: esta solución le permite elegir tres enteros t_0, t_1, t_2 libremente y desde allí puede calcular los valores de w, x, y, z.

Esto está bien, excepto que los coeficientes siempre son mucho más grandes de lo que deben ser. Si resuelves el mismo sistema en Mathematica obtienes:

 x = 2 c_2, y = 9 c_2 + 256 c_3 + 81 w, z = 20 c_2 + 459 c_3 + 145 w, c_2 element Z and c_3 element Z

o:

ingrese la descripción de la imagen aquí

Reescrito en el mismo estilo que la solución Sympy, sería:

 (t_0, 2*t_1, 9*t_1 + 256*t_2 + 81*t_0, 20*t_1 + 459*t_2 + 145*t_0)

¿Es posible obtener sympy para dar soluciones a ecuaciones diofánticas lineales con coeficientes igualmente pequeños?


Errores tipográficos corregidos en el código sympy.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!