我需要在有限域 F17 上绘制一条椭圆曲线(换句话说,我想在曲线上绘制一些特定的点),但不知何故我没有做对。
曲线由等式定义:
y^2 = x^3 +x + 1 (mod 17)
我试过下面的方法,还是不行。
for x = 0:16, plot(x, mod(sqrt(x^3+x+1), 16),'r')', end
有人可以帮忙吗?
[更新]
根据 Nathan 和 Bill 的建议,这里有一个稍微修改的版本。
x = 0:18
plot(mod(x,16), mod(sqrt(x.^3+x+1), 16),'ro')
但是,我觉得这个数字是错误的,例如,当 x=4 时 y 不是整数。
最佳答案
您必须测试满足方程 y^2 = x^3 +x + 1 (mod 17)
的所有点。由于它是一个有限域,所以不能简单地在右侧取平方根。
这就是我的做法:
a=0:16 %all points of your finite field
left_side = mod(a.^2,17) %left side of the equation
right_side = mod(a.^3+a+1,17) %right side of the equation
points = [];
%testing if left and right side are the same
%(you could probably do something nicer here)
for i = 1:length(right_side)
I = find(left_side == right_side(i));
for j=1:length(I)
points = [points;a(i),a(I(j))];
end
end
plot(points(:,1),points(:,2),'ro')
set(gca,'XTick',0:1:16)
set(gca,'YTick',0:1:16)
grid on;
关于matlab - 你如何使用matlab在有限域上绘制椭圆曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9156782/