#its ok to post #TaerimKim,12/13/2020,Assignment 25 #1. Ferr([9,6,5,3,1,1,1]); 1, 1, 1, 1, 1, 1, 1, 1, 1 1, 1, 1, 1, 1, 1 1, 1, 1, 1, 1 1, 1, 1 1 1 1 ################################################################ #2. pnk(151,10); 79811865 ################################################################# #3. Given that j = -1, #L=[6,5,3,1,1,1,1,1] = p(19) = p(n-a(-1)) -> n=20 #t=8 #a(j) = 3(-1)^2-1/2 = 1 #L[1] = 6 > 8-3 = 5, so we take the second route #results should be p(20-a(-1+1)=p(20) with j=0 #phi([6,5,3,1,1,1,1,1]) -> (5+1,3+1,1+1,1+1,1+1,1+1,1+1) #= (6,4,2,2,2,2,2) = p(20) with j=0 #lets check with BZ BZ([[6,5,3,1,1,1,1,1],-1]) [[6, 4, 2, 2, 2, 2, 2], 0] #yes! ################################################################### #4. The reason for pnFast to fail is because there is too much recursion #since pnFast is a brutal way that uses two recursion patterns that is heavy for large n [seq(pnFast(i),i=1..20000)][20000]; 2521148138125296979166195332304704522813289496018115934368503141\ 08034284423801564956623970731689824369192324789351994903016411\ 826230578166735959242113097 [seq(pnFast(i),i=1..30000)][30000]; 4296358424632538517488315748300592091269024864540113906601448061\ 27641639862154581851929901733148321795642113672288553217180150\ 74490598095469727784182254987592569621576375743614022636192786 [seq(pnFast(i),i=1..100000)][100000];27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519 2749351056977569651267751632098635268817342931598005475820312598\ 43021473281149641730550507416607366215901578447742962489404930\ 63070200461792764493033510116079342457190155718943509725312466\ 10845200636955893446424871682878983218234500926285383140459702\ 13071306745106244192273112389997022844086093709355316296978515\ 69569892196108480158600569421098519 #very laggy but still doable ####################################################################### #5.A simple tast pnFastmod:=proc(n,m) local i: pnFast(n) mod m; end: pnFastmod(100000,101) 89 ###################################################################### #6.So lets think first. #to invert the Glashier is to invert the Glashier1 #So. let plot Glashier2 that is opposite of Glashier1 and bring it from InvGlashier #Glashier2(L) Glashier2:=proc(L) local i: for i from 1 to nops(L)-1 do if L[i]=L[i+1] and i < nops(L) - 2 then RETURN(sort([op(1..i-1,L),2*L[i],op(i+2..nops(L),L)],`>`)): fi: if L[i]=L[i+1] and i>nops(L)-2 then RETURN(sort([op(1..i-1,L),2*L[i]],`>`)): fi: L: od: end: #lets see if it works Glashier2([5, 5, 5, 5, 5, 5, 3, 3, 3, 1, 1]) [10, 5, 5, 5, 5, 3, 3, 3, 1, 1] Glashier2(%) [10, 10, 5, 5, 3, 3, 3, 1, 1] Glashier2(%) [20, 5, 5, 3, 3, 3, 1, 1] Glashier2(%) [20, 10, 3, 3, 3, 1, 1] Glashier2(%) [20, 10, 6, 3, 1, 1] Glashier2(%) [20, 10, 6, 3, 2] Glashier2(%) [20, 10, 6, 3, 2] #check it with Glashier evalb(Glashier([20, 10, 6, 3, 2])=[5, 5, 5, 5, 5, 5, 3, 3, 3, 1, 1]) true #it works! #so lets finish the InvGlashier by just tweeking function from original Glashier(Glashier1 -> Glashier2) InvGlashier:=proc(M) local L1,L2,L3: L1:=L: L2:=Glashier2(L1): while L1<>L2 do L3:=Glashier2(L2): L1:=L2: L2:=L3: od: L2: end: #lets check distinct -> distinct InvGlashier(Glashier([20, 10, 6, 3, 2])) [20, 10, 6, 3, 2] #works Glashier(InvGlashier([5, 5, 5, 5, 5, 5, 3, 3, 3, 1, 1])); [5, 5, 5, 5, 5, 5, 3, 3, 3, 1, 1] #odd -> odd also works so #its goodd ####################################################################################### #7. we will follow the guidline from the paper #InvSyl(L): DIs -> ODD InvSyl:=proc(L) local i,m,s,r,L1,M1: option remember: if L=[] then RETURN([]): fi: if L=[1$nops(L)] then RETURN([nops(L)]): fi: s:=nops(L); #1. from paper m:=L[1]-L[2]-1; #2. recursive L1:=[seq(L[i],i=3..s)]: M1:=Syl(L1): r:=nops(M1); a1:=L[2]-r+1; [2*a1+1,op(M1),1$m]: end; InvSyl([13, 10, 9, 5, 4]) [ 1 -3 ] [11, 7, 6, 3, 2, -, --, 1, 1] [ 2 2 ] Syl([5, 5, 5, 5, 5, 5, 3, 3, 3, 1, 1]) [13, 10, 9, 5, 4] #something is wrong...