乘法逆元?

发布于 2024-08-10 23:01:19 字数 1459 浏览 13 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

完美的未来在梦里 2024-08-17 23:01:19

这是因为 2 没有乘法逆模 26:因为 13*2=0,所以不存在 K 使得 K * a = 1。您的模数必须是素数。尝试查找中国剩余定理以获取更多信息。

更具体地说,整数 mod 26 不是一个域(一个数学集合,其中除了 0 之外的每个元素都有乘法逆元)。任何 a * b = 0 的环(对于某些 a!=0 和 b!=0)都不是域。

事实上,一个字段总是有 p^n 个元素,其中 p 是质数,n 是正整数。最简单的字段只是整数 mod 素数,但对于素数幂,您需要构造一个更复杂的系统。因此,简而言之,使用不同的模数,例如 29。

That's because 2 doesn't have a multiplicative inverse mod 26: since 13*2=0, there does not exist K such that K * a = 1. Your modulus must be prime. Try looking up the Chinese Remainder Theorem for more information.

To be more specific, integers mod 26 is not a field (a mathematical set where every element, except 0, has a multiplicative inverse). Any ring in which a * b = 0, for some a!=0 and b!=0, is not a field.

In fact, a field will always have p^n elements, where p is a prime number and n is a positive integer. The simplest fields are just integers mod a prime number, but for prime powers you need to construct a more elaborate system. So, in short, use a different modulus like 29.

毁虫ゝ 2024-08-17 23:01:19

a = 7 有效吗? 2*7 = 14。因此,b = 11。

让我们检查 2 个方程,看看是否有效:

  • 7+11 = 18(检查第一个方程)。
  • 3*7+11=21+11 = 32 = 6.

上面有什么问题?

编辑:好的,现在我知道尝试在非质数模数中除以 2 可能会出现什么问题,因为它类似于除以 0。您可以采用 ribond 的建议,使用中国剩余定理并拆分方程转换成另一对:

mod 13: a+b=5, 3a+b=6。 (2a=1=14=>a=7。b=18-7=11。)

mod 2:a+b=0。 3a+b=0 (请注意,这是相同的方程,并且有一对可能的解决方案,其中 a 和 b 为 0 或 1。)

因此,我认为您的问题有唯一的解决方案。

Does a = 7 work? 2*7 = 14. Thus, b = 11.

Let's check the 2 equations to see if that works:

  • 7+11 = 18 (check for the first equation).
  • 3*7+11=21+11 = 32 = 6.

What is wrong with the above?

EDIT: Ok, now I see what could go wrong with trying to do a division by 2 in a non-prime modulus as it is similar to a division by 0. You could take ribond's suggestion of using the Chinese Remainder Theorem and split the equations into another pair of pairs:

mod 13: a+b=5, 3a+b=6. (2a = 1 = 14 => a=7. b = 18-7 = 11.)

mod 2: a+b=0. 3a+b=0 (Note this is the same equation and has a pair of possible solutions where a and b are either 0 or 1.)

Thus there is the unique solution for your problem I think.

翻身的咸鱼 2024-08-17 23:01:19

其他海报是正确的,因为没有 2 modulo 26 的逆,所以你不能通过乘以 2 的逆来解决 2a=14 mod 26 。但这并不意味着 2a=14 mod 26 不是可解。

考虑一般方程 cx = d mod n (在您的情况下为 c=2,d=14,n=26)。设 g = gcd(c,n)。仅当 g 除 d 时,方程 cx=d 才有解。如果 g 除 d,那么实际上有多个解(其中 g 个)。方程 (c/g)x = d/g mod n/g 有唯一解(称为 x_0),因为 c/g 与 n/g 互质,因此有倒数。原方程的解为 x_0, x_0 + n/g, ..., x_0 + (g-1)n/g。

在你的情况下,c=2,d=14,n=26,g=2。 g 除 d,因此首先求解方程 (2/2)x = (14/2) mod (26/2),得到 7。因此 7 和 7+13=20 都求解原始方程。

请注意,这意味着您尚未唯一确定仿射变换,仍然存在两种可能性。您需要另一个数据点...

Other posters are right in that there is no inverse of 2 modulo 26, so you can't solve 2a=14 mod 26 by multiplying through by the inverse of 2. But that doesn't mean that 2a=14 mod 26 isn't solvable.

Consider the general equation cx = d mod n (c=2,d=14,n=26 in your case). Let g = gcd(c,n). The equation cx=d has a solution if an only if g divides d. If g divides d, then there are in fact multiple solutions (g of them). The equation (c/g)x = d/g mod n/g has a unique solution (call it x_0) because c/g is relatively prime to n/g and therefore has an inverse. The solutions to the original equation are x_0, x_0 + n/g, ..., x_0 + (g-1)n/g.

In your case c=2,d=14,n=26, and g=2. g divides d, so first solve the equation (2/2)x = (14/2) mod (26/2) which gives 7. So both 7 and 7+13=20 solve your original equation.

Note that this means you haven't uniquely determined your affine transformation, two possibilities still exist. You need another data point...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文