Use the “solve” function. Before using “solve”, assume that the variables in the Diophantine equation are integers to ensure “solve” returns integer solutions. For example, solve the linear Diophantine equation 1027*x + 712*y = 1;
For MATLAB R2015a and later:
syms x y integer
eqn = 1027*x + 712*y == 1;
[xSol, ySol] = solve(eqn,[x y])
xSol =
-165
ySol =
238
For MATLAB R2014b or before:
syms x y
assume([x y], 'integer')
eqn = 1027*x + 712*y == 1;
[xSol, ySol] = solve(eqn,[x y])
xSol =
-165
ySol =
238
Best Answer