Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
diophant
Solves the diophantine (Bezout) equation p1*x1 + p2*x2 = b
Syntax
[x1x2, err] = diophant(p1p2, b)
Arguments
- p1p2, x1x2
Vectors of two numbers or polynomials
p1p2 = [p1 p2]
andx1x2 = [x1 x2]
, with the same size and type (integers, numbers, polynomials).When there is no solution,
x1x2 = []
- b
single number or polynomial
- err
Single real number: error flag:
0 No error. -%inf There is an infinite number of solutions. %nan p1==0
,p2==0
, whileb <> 0
: No solution.> 0 There is no solution. err = ||coeff(b - int(b/g)*g)|| / ||coef(b)||
whereg = gcd(p1,p2)
.
Description
diophant
solves the bezout equation p1*x1 + p2*x2 = b
for polynomials, encoded integers, or numbers.
If input arguments are encoded integers, only integer solutions are searched.
If input arguments are decimal numbers or constant polynomials, there is always an infinite number of solutions.
When there is an infinite number of solutions, only one [x1 x2] solution is returned.
Examples
[X, e] = diophant(int8([4, 7]), 5) // int8([10 -5]) [X, e] = diophant(int16([1234 5321]), 543); // int16([30533 -2339]) sum(X .* [1234 5321]) s = %s; p = (1+s)*(s-1) + (1-s^2)*s; [X, e] = diophant([1+s ; 1-s^2], -1+s+s^2-s^3); // [-1+2*s-s^2 ; 0] sum(X .* [1+s ; 1-s^2])
No solution exists:
s = %s; [X, e] = diophant([0, 0], 1) [X, e] = diophant([s^3, s^2], s) [X, e] = diophant([1+s ; 1-s^2], 1-s+s^2) [X, e] = diophant(int8([2 0]), int8(1)) // No integer solution
An infinite number of solutions exists:
[X, e] = diophant([4, 7], 5) // [0 5/7] s = %s; [X, e] = diophant([0, 0]*s, 0) [X, e] = diophant([0, 1]*s, 2*s) [X, e] = diophant([0, s]*(1-s^2), s^2*(1-s^2))
See Also
History
Версия | Описание |
6.1.0 |
|
Report an issue | ||
<< detr | Polynomials | factors >> |