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


Messages In This Thread
Positive integral solutions for Linear Diophantine Equation - by august - Jan-12-2023, 10:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to do bar graph with positive and negative values different colors? Mark17 1 5,240 Jun-10-2022, 07:38 PM
Last Post: Mark17
  Regex: positive lookbehind Secret 2 2,031 Sep-21-2020, 12:59 AM
Last Post: snippsat
  How to Solving non-linear equation using scipy.optimize fsolve with variable list djhak 3 4,616 Jun-10-2020, 04:12 PM
Last Post: Gribouillis
  Alternate solutions to cipher problem? Mark17 3 2,474 Oct-08-2019, 01:32 PM
Last Post: jefsummers
  Positive to negative bernardoB 6 4,436 Mar-13-2019, 07:39 PM
Last Post: bernardoB
  SyntaxError - Integral michitrujillo 1 2,149 Jan-21-2019, 05:59 AM
Last Post: perfringo
  negative to positive slices Skaperen 3 3,675 Jan-29-2018, 05:47 AM
Last Post: Skaperen
  How to find any non positive integer noob 3 4,098 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