Elliptic curve arithmetic: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: changed whitespace.)
m (→‎{{header|Perl 6}}: given how clueless I am on the topic, please retract if I misunderstood anything; apparently the results from previous data set are not correct? for example, x=2, y=3.74165738677394 does not lie on y² = x³ + 7 ?)
Line 965: Line 965:
}
}


say my $p = Point.new: x => $_, y => sqrt(abs(1 - $_**3 - $A*$_ - $B)) given 1;
say my $p = Point.new: x => $_, y => sqrt(abs($_**3 + $A*$_ + $B)) given 1;
say my $q = Point.new: x => $_, y => sqrt(abs(1 - $_**3 - $A*$_ - $B)) given 2;
say my $q = Point.new: x => $_, y => sqrt(abs($_**3 + $A*$_ + $B)) given 2;
say my $s = $p + $q;
say my $s = $p + $q;


say "checking alignment: ", abs ($p.x - $q.x)*(-$s.y - $q.y) - ($p.y - $q.y)*($s.x - $q.x);</lang>
say "checking alignment: ", abs ($p.x - $q.x)*(-$s.y - $q.y) - ($p.y - $q.y)*($s.x - $q.x);</lang>
{{out}}
{{out}}
<pre>EC Point at x=1, y=2.64575131106459
<pre>EC Point at x=1, y=2.8284271247461903
EC Point at x=2, y=3.74165738677394
EC Point at x=2, y=3.872983346207417
EC Point at x=-1.79898987322333, y=0.421678696849803
EC Point at x=-1.9089023002066448, y=0.21008487055753378
checking alignment: 8.88178419700125e-16</pre>
checking alignment: 0</pre>


=={{header|Phix}}==
=={{header|Phix}}==