#Dayoon Kim, 2024-4-7, HW20 Help:=proc(): print(` Diag(a,b),IntSol(a,b,K),SolChain(a,b,S1,S2,K) `): end: #####Old Code #C20.txt, April 1, 2024; Help20:=proc(): print(`RP(a,b), DoesLie(a,b,P), AddE(a,b,P,Q)`): end: #random number RP:=proc(a,b) local x: x:=rand(0..200)()/100: [x,sqrt(x^3+a*x+b)]: end: #checking if the point lies in the curve DoesLie:=proc(a,b,P): P[2]^2-P[1]^3-a*P[1]-b: end: # AddE:=proc(a,b,P,Q) local y,s,sol,xR: s:=(P[2]-Q[2])/(P[1]-Q[1]): y:=P[2]+(x-P[1])*s: sol:={solve(y^2-x^3-a*x-b,x)}: #sol: finding 3 x coordinate of points where elliptic curve and the line meets if not (nops(sol)=3 and member(P[1],sol) and member(Q[1],sol)) then print(`sth bad happened`): RETURN(Fail): fi: sol:=sol minus {P[1],Q[1]}: xR:=sol[1]: [xR,sqrt(xR^3+a*xR+b)]: end: #####End of Old Code #HW20-1 Diag:=proc(a,b) local A,B,L,f: A:=RP(a,b): B:=[A[1],-A[2]]: L:=[A,B]: f:=sqrt(x^3 + a*x + b): print(`Random point=`, A); plot([f,-f,L]); end: #HW20-2 IntSol:=proc(a,b,K) local sol,x,y: sol:=[]: for x from -K to K do y:=floor(sqrt(x^3 + a*x + b)): # Integer square root if y^2=x^3+a*x+b then sol:=[op(sol),[x,y]]: fi: od: sol; end: #HW20-3 SolChain:=proc(a,b,S1,S2,K) local L, i, P, Q: L:=[S1, S2]: for i from 3 to K + 2 do P:=L[-2]: Q:=L[-1]: L:=[op(L), AddE(a, b, P, Q)]: od: L; end: #No, you cannot get infinitely many solutions. #IntSol(2, 3, 15); #[[-6, 15 I], [-2, 3 I], [-1, 0], [3, 6]] #SolChain(2,3,[-1, 0],[3, 6], 9); #[[-1, 0], [3, 6], [1/4, 15/8], [-1, 0], [3, 6], [1/4, 15/8], [-1, 0], [3, 6], [1/4, 15/8], [-1, 0], [3, 6]] #Same three repeats.