Python Forum
Positive integral solutions for Linear Diophantine Equation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Positive integral solutions for Linear Diophantine Equation
#1
Hello All,

Say I want to find all POSITIVE INTEGRAL solutions for a,b for this linear equation:
a + 2b = 5 and the solutions are:

a|5|3|1|
----------
b|0|1|2|


import sympy
a,b = symbols('a b', integer=True)
solve( a*1 + b*2 - 5, [a,b])
which gives me the following output:

[(5 - 2*b, b)]
How to go next to extract the possible numerical solutions as given in the table? is there any built-in function in sympy for that?
Reply
#2
https://docs.sympy.org/latest/guides/sol...ight=solve

Look under "Use the solution result"
Reply
#3
(Jan-12-2023, 10:26 PM)deanhystad Wrote: https://docs.sympy.org/latest/guides/sol...ight=solve

Look under "Use the solution result"

Thanks deanhystad,
Somehow I can't figure it out, can you help further?
Reply
#4
Not really. I didn't really understand your question when I replied. Since then I realized my mistake and did some research trying to improve my response. I came up with nothing. Sorry.
Reply
#5
The integer solutions of a n + b m = r are well known mathematically. I would start from the expression of their solutions.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to calculate integral value? Tli_You 5 1,276 Aug-23-2024, 06:07 PM
Last Post: Tli_You
  How to do bar graph with positive and negative values different colors? Mark17 1 8,624 Jun-10-2022, 07:38 PM
Last Post: Mark17
  Regex: positive lookbehind Secret 2 2,893 Sep-21-2020, 12:59 AM
Last Post: snippsat
  How to Solving non-linear equation using scipy.optimize fsolve with variable list djhak 3 7,206 Jun-10-2020, 04:12 PM
Last Post: Gribouillis
  Alternate solutions to cipher problem? Mark17 3 3,319 Oct-08-2019, 01:32 PM
Last Post: jefsummers
  Positive to negative bernardoB 6 5,679 Mar-13-2019, 07:39 PM
Last Post: bernardoB
  SyntaxError - Integral michitrujillo 1 2,755 Jan-21-2019, 05:59 AM
Last Post: perfringo
  negative to positive slices Skaperen 3 4,617 Jan-29-2018, 05:47 AM
Last Post: Skaperen
  How to find any non positive integer noob 3 5,163 Apr-27-2017, 04:46 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020