How to find x-coordinate of the curve If y-coordinate is given?

5 visualizaciones (últimos 30 días)
Ammy
Ammy el 27 de Mzo. de 2021
Comentada: Ammy el 28 de Mzo. de 2021
disp('y^2 = x^3 + 14 mod 17')
y=0:16
for i=1:17
left_side = mod(y(i).^2,17);
right_side = mod(x.^3+14,17;
end
If I have y-coordinates from 0 to 16, how can I find the corresponding x-coordinate that satifies 'y^2 = x^3 + 14 mod 17'

Respuesta aceptada

Image Analyst
Image Analyst el 28 de Mzo. de 2021
I understand now. Try this:
for k1 = 0 : 16
for k2 = 0 : 16
equation1 = k1 .^ 2;
equation2 = k2 .^ 3 + 14;
eqn1mod = mod(equation1, 17);
eqn2mod = mod(equation2, 17);
indexes = find(eqn1mod == eqn2mod);
if ~isempty(indexes)
fprintf('Match at k1 = %d and k2 = %d.\n', k1, k2);
fprintf(' equation1 = %d and equation2 = %d.\n', equation1, equation2);
fprintf(' mod(equation1, 17) = %d and mod(equation2, 17) = %d.\n', eqn1mod, eqn2mod);
end
end
end
You'll see
Match at k1 = 0 and k2 = 7.
equation1 = 0 and equation2 = 357.
mod(equation1, 17) = 0 and mod(equation2, 17) = 0.
Match at k1 = 1 and k2 = 13.
equation1 = 1 and equation2 = 2211.
mod(equation1, 17) = 1 and mod(equation2, 17) = 1.
Match at k1 = 2 and k2 = 14.
equation1 = 4 and equation2 = 2758.
mod(equation1, 17) = 4 and mod(equation2, 17) = 4.
Match at k1 = 3 and k2 = 6.
equation1 = 9 and equation2 = 230.
mod(equation1, 17) = 9 and mod(equation2, 17) = 9.
Match at k1 = 4 and k2 = 8.
equation1 = 16 and equation2 = 526.
mod(equation1, 17) = 16 and mod(equation2, 17) = 16.
Match at k1 = 5 and k2 = 12.
equation1 = 25 and equation2 = 1742.
mod(equation1, 17) = 8 and mod(equation2, 17) = 8.
Match at k1 = 6 and k2 = 11.
equation1 = 36 and equation2 = 1345.
mod(equation1, 17) = 2 and mod(equation2, 17) = 2.
Match at k1 = 7 and k2 = 1.
equation1 = 49 and equation2 = 15.
mod(equation1, 17) = 15 and mod(equation2, 17) = 15.
Match at k1 = 8 and k2 = 16.
equation1 = 64 and equation2 = 4110.
mod(equation1, 17) = 13 and mod(equation2, 17) = 13.
Match at k1 = 9 and k2 = 16.
equation1 = 81 and equation2 = 4110.
mod(equation1, 17) = 13 and mod(equation2, 17) = 13.
Match at k1 = 10 and k2 = 1.
equation1 = 100 and equation2 = 15.
mod(equation1, 17) = 15 and mod(equation2, 17) = 15.
Match at k1 = 11 and k2 = 11.
equation1 = 121 and equation2 = 1345.
mod(equation1, 17) = 2 and mod(equation2, 17) = 2.
Match at k1 = 12 and k2 = 12.
equation1 = 144 and equation2 = 1742.
mod(equation1, 17) = 8 and mod(equation2, 17) = 8.
Match at k1 = 13 and k2 = 8.
equation1 = 169 and equation2 = 526.
mod(equation1, 17) = 16 and mod(equation2, 17) = 16.
Match at k1 = 14 and k2 = 6.
equation1 = 196 and equation2 = 230.
mod(equation1, 17) = 9 and mod(equation2, 17) = 9.
Match at k1 = 15 and k2 = 14.
equation1 = 225 and equation2 = 2758.
mod(equation1, 17) = 4 and mod(equation2, 17) = 4.
Match at k1 = 16 and k2 = 13.
equation1 = 256 and equation2 = 2211.
mod(equation1, 17) = 1 and mod(equation2, 17) = 1.
  3 comentarios
Image Analyst
Image Analyst el 28 de Mzo. de 2021
Just set up an array and index and assign them. You'll need to learn how to assign values into a matrix if you're going to be successful in MATLAB. You can start here:
In the meantime, here is how you can store the values in an array called "results".
results = [0, 0];
counter = 1;
for k1 = 0 : 16
for k2 = 0 : 16
equation1 = k1 .^ 2;
equation2 = k2 .^ 3 + 14;
eqn1mod = mod(equation1, 17);
eqn2mod = mod(equation2, 17);
indexes = find(eqn1mod == eqn2mod);
if ~isempty(indexes)
fprintf('Match at k1 = %d and k2 = %d.\n', k1, k2);
fprintf(' equation1 = %d and equation2 = %d.\n', equation1, equation2);
fprintf(' mod(equation1, 17) = %d and mod(equation2, 17) = %d.\n', eqn1mod, eqn2mod);
results(counter, :) = [k1, k2];
counter = counter + 1;
end
end
end
Ammy
Ammy el 28 de Mzo. de 2021
Thank you very much for such a help.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 27 de Mzo. de 2021
Because of missing parentheses regarding mod, and a poorly worded question, it's unclear what you want and exactly what is to be moded. But let's start here, then you can explain further.
disp('y^2 = x^3 + 14 mod 17')
y=0:16
x = (y .^ 2 - 14) .^ (1/3)
nexttile;
plot(x, y, 'b.-', 'LineWidth', 2, 'MarkerSize', 25);
grid on
xlabel('x', 'Interpreter', 'none', 'FontSize', 15);
ylabel('y', 'Interpreter', 'none', 'FontSize', 15);
for k=1:17
left_side(k) = mod(y(k).^2,17)
right_side(k) = mod(real(x(k).^3+14),17)
% If I have y-coordinate from 0 to 16
% how can I find corresponding x-coordinate that
% satisfies 'y^2 = x^3 + 14 mod 17'
end
nexttile;
plot(right_side, left_side, 'b.-', 'LineWidth', 2, 'MarkerSize', 25);
grid on
xlabel('right_side', 'Interpreter', 'none', 'FontSize', 15);
ylabel('left_side', 'Interpreter', 'none', 'FontSize', 15);
  2 comentarios
Ammy
Ammy el 27 de Mzo. de 2021
I mean in this curve 'y^2 = x^3 + 14 mod 17' we have points (1,7), (1,10), (6,3) etc if y coordinate is given how can I find x-coordinate that satifies the curve
Image Analyst
Image Analyst el 27 de Mzo. de 2021
So if x=1 and y=7,
y^2 = 49 and mod(49,17) is 15
x^3+14 = 17 and mod(17,17) is 0
So explain again in detail why point (1,7) is a point where this condition is true.
And please make clear whether y^2 is also supposed to be moded by 17, or if it's just the right hand (x) side of the equation that's supposed to be moded with 17. In other words is it
mod(y^2, 17)
AND
mod(x.^3+14,17)
OR JUST the right hand side (because you did not use mod explicitly on the left hand side).
mod(x.^3+14,17)
In other word did you mean
y^2 = x^3 + 14 mod 17
or did you mean
y^2 mod 17 = x^3 + 14 mod 17
So, since y^2 = x.^3+14, whenever y^2 is mod 17, then x.^3+14 will also be mod 17 since y^2 = x.^3+14. They will both be mod 17 at the same time.
And finally, you might want to look at rem() rather than mod.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by