Generic two integer variable equation solver
- Alpertron
- Web applications
- Generic two integer variable equation solver
This Web application can solve equations of the form ax² + bxy + cy² + dx + ey + f = 0 where the unknowns x and y are integer numbers.
You can type numbers or numerical expressions on the input boxes.
The calculator accepts numbers of up to 10000 digits but notice that the algorithm requires the factorization of some numbers (in general large numbers cannot be factored in a reasonable amount of time). The factorization engine is the one used in the Integer factorization calculator, that uses the Elliptic Curve Method (ECM) and Self-Initializing Quadratic Sieve (SIQS) algorithms.
If there are too many solutions, the application could run out of memory. In this case it will not show anything.
Expressions
You can also enter expressions that use the following operators and parentheses:
- + for addition
- - for subtraction
- * for multiplication
- / for integer division
- % for modulus (remainder of the integer division)
- ^ or ** for exponentiation (the exponent must be greater than or equal to zero).
- <, ==, >; <=, >=, != for comparisons. The operators return zero for false and -1 for true.
- AND, OR, XOR, NOT for binary logic. The operations are done in binary (base 2). Positive (negative) numbers are prepended with an infinite number of bits set to zero (one).
- SHL or <<: When b ≥ 0, a SHL b shifts a left the number of bits specified by b. This is equivalent to a × 2^{b}. Otherwise, a SHL b shifts a right the number of bits specified by −b. This is equivalent to floor(a / 2^{−b}). Example: 5 SHL 3 = 40.
- SHR or >>: When b ≥ 0, a SHR b shifts a right the number of bits specified by b. This is equivalent to floor(a / 2^{b}). Otherwise, a SHR b shifts a left the number of bits specified by −b. This is equivalent to a × 2^{−b}. Example: -19 SHR 2 = -5.
- n!: factorial (n must be greater than or equal to zero). Example: 6! = 6 × 5 × 4 × 3 × 2 = 720.
- n!! ... !: multiple factorial (n must be greater than or equal to zero). It is the product of n times n − k times n − 2k ... (all numbers greater than zero) where k is the number of exclamation marks. Example: 7!! = 7 × 5 × 3 × 1 = 105.
- p#: primorial (product of all primes less or equal than p). Example: 12# = 11 × 7 × 5 × 3 × 2 = 2310.
- B(n): Previous probable prime before n. Example: B(24) = 23.
- F(n): Fibonacci number F_{n} from the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, etc. where each element equals the sum of the previous two members of the sequence. Example: F(7) = 13.
- L(n): Lucas number L_{n} = F_{n-1} + F_{n+1}
- N(n): Next probable prime after n. Example: N(24) = 29.
- P(n): Unrestricted Partition Number (number of decompositions of n into sums of integers without regard to order). Example: P(4) = 5 because the number 4 can be partitioned in 5 different ways: 4 = 3+1 = 2+2 = 2+1+1 = 1+1+1+1.
- Gcd(m,n, ...): Greatest common divisor of these integers. Example: GCD(12, 16) = 4.
- Lcm(m,n, ...): Least common multiple of these integers. Example: LCM(12, 16, 24) = 48.
- FloorDiv(m,n): integer part of the quotient of m divided by n. Examples: floordiv(10, 7) = 1 and floordiv(-10, 7) = -2.
- Mod(m,n): value of m modulo the absolute value of n. Examples: Mod(10, 7) = 3 and Mod(-10, 7) = 4.
- Modinv(m,n): inverse of m modulo n, only valid when m and n are coprime, meaning that they do not have common factors. Example: Modinv(3,7) = 5 because 3 × 5 ≡ 1 (mod 7)
- Modpow(m,n,r): finds m^{n} modulo r. Example: Modpow(3, 4, 7) = 4, because 3^{4} ≡ 4 (mod 7).
- Totient(n): finds the number of positive integers less than n which are relatively prime to n. Example: Totient(6) = 2 because 1 and 5 do not have common factors with 6.
- Jacobi(m,n): obtains the Jacobi symbol of m and n. When the second argument is prime, the result is zero when m is multiple of n, it is one if there is a solution of x² ≡ m (mod n) and it is equal to −1 when the mentioned congruence has no solution.
- Random(m,n): integer random number between m and n.
- Abs(n): absolute value of n.
- Sign(n): returns zero if n is zero, −1 if negative or 1 if positive.
- IsPrime(n): returns zero if n is not probable prime, −1 if it is. Example: IsPrime(5) = −1.
- Sqrt(n): Integer part of the square root of the argument.
- Iroot(n,r): Integer r-root of the first argument. Example: Iroot(8, 3) = 2.
- NumFact(n): number of distinct prime factors of n. Example: NumFact(28) = 2 because its prime factors are 2 and 7.
- MinFact(n): minimum prime factor of n. Example: MinFact(28) = 2 because its prime factors are 2 and 7.
- MaxFact(n): maximum prime factor of n. Example: MaxFact(28) = 7 because its prime factors are 2 and 7.
- NumDivs(n): Number of positive divisors of n. Example: NumDivs(28) = 6 because the divisors of 28 are 1, 2, 4, 7, 14 and 28.
- SumDivs(n): Sum of all positive divisors of n. Example: SumDivs(28) = 56 because 1 + 2 + 4 + 7 + 14 + 28 = 56.
- NumDigits(n,r): Number of digits of n in base r. Example: NumDigits(13, 2) = 4 because 13 in binary (base 2) is expressed as 1101.
- SumDigits(n,r): Sum of digits of n in base r. Example: SumDigits(213, 10) = 6 because the sum of the digits expressed in decimal is 2+1+3 = 6.
- RevDigits(n,r): finds the value obtained by writing backwards the digits of n in base r. Example: RevDigits(213, 10) = 312.
- ConcatFact(m,n): Concatenates the prime factors of n according to the mode expressed in m which follows this table:
Mode | Order of factors | Repeated factors | Example |
---|---|---|---|
0 | Ascending | No | concatfact(0,36) = 23 |
1 | Descending | No | concatfact(1,36) = 32 |
2 | Ascending | Yes | concatfact(2,36) = 2233 |
3 | Descending | Yes | concatfact(3,36) = 3322 |
You can use the prefix 0x for hexadecimal numbers, for example 0x38 is equal to 56.
The exponentiation symbol is not present in some mobile devices, so two asterisks ** can by typed as the exponentiation operator.
Configuration
You can change settings for this application by pressing the Config button when a factorization is not in progress. A new window will pop up where you can select different settings:
- Digits per group: In order to improve readability, big numbers are separated by spaces forming groups of a fixed number of digits. With this input box, you can determine the number of digits in a group.
- Keyboard: This enables the user to select between numeric or complete (alphanumeric) virtual keyboard. The virtual keyboard appears on the screen when the user selects an input box on touch screens.
The configuration is saved in your device, so when you start again the calculator, all settings remain the same.
Source code
You can download the source of the current program and the old quadratic integer equation applet from GitHub. Notice that the source code is in C language and you need the Emscripten environment in order to generate JavaScript.
Written by Dario Alpern. Last updated 17 May 2024.