20170327, 04:26  #34 
"Rashid Naimi"
Oct 2015
Remote to Here/There
89D_{16} Posts 

20170327, 04:30  #35  
"Rashid Naimi"
Oct 2015
Remote to Here/There
2205_{10} Posts 
Quote:
upperPower =ceil(log(n)\log(2)) and runningBase=ceil(sqrtn(n ,i)) Thanks in advance. 

20170327, 04:31  #36 
Aug 2006
3×1,993 Posts 
Also, FWIW, my version of your above program
Code:
np(x)=>if(x<=1,return(1));my(best=(sqrtnint(x1,3)+1)^3,t);x=ceil(x);for(e=4,logint(x,2),t=(sqrtnint(x1,e)+1)^e;if(t<best,best=t));best 
20170327, 04:35  #37 
"Rashid Naimi"
Oct 2015
Remote to Here/There
3^{2}×5×7^{2} Posts 
Can you be more specific on the bug?
What value of n gives the wrong result? 
20170327, 04:35  #38  
Aug 2006
3·1,993 Posts 
Quote:
If n is an integer which is at least 2, then you can use upperPower = logint(n1,2)+1 and if n and i are integers which are at least 1, you can use runningBase = sqrtnint(n1,i)+1 

20170327, 04:37  #39  
Aug 2006
3×1,993 Posts 
Quote:
Code:
apply(nextPower3RN, [2..7]) %1 = [4, 9, 16, 25, 36, 49] 

20170327, 04:39  #40 
Aug 2006
5979_{10} Posts 

20170327, 05:34  #41 
"Rashid Naimi"
Oct 2015
Remote to Here/There
3^{2}×5×7^{2} Posts 
Thank you for the bug catch.
Here is the corrected code: Code:
\\"Efficient" nextPower3RN(n)={ my(upperPower ,i,smallestPower=n^2,theBase,theExp,runningBase,theCandidate); if(n<5,print("\n",8," = ",2,"^",3);return(8);); if(ispower(n)>2,n=n+1); upperPower =ceil(log(n)/log(2)); for(i=3,upperPower, runningBase=ceil(sqrtn(n ,i)); theCandidate=runningBase^i; if(theCandidate<smallestPower, smallestPower=theCandidate; theBase=runningBase; theExp=i; ); ); print("\n",smallestPower," = ",theBase,"^",theExp); return(smallestPower); } \\BruteForce nextPower3(n)={ m=n; if(ispower(n)>2,m=n+1); while(ispower(m)<3, m=m+1; ); print(m); return(m); } and did not treat n differently when it was already a power of 3 or more and did not treat n< 5 differently. Last fiddled with by a1call on 20170327 at 05:35 
20170327, 14:47  #42  
Feb 2017
Nowhere
7×13×59 Posts 
Quote:
Computing Galois groups can also come to grief if approximate numerical roots have insufficient precision. Number field calculations largely rely on exact polynomial arithmetic. For example, Mod(x, x^2  2) is an exact square root of 2... 

20171003, 02:40  #43 
"Ed Hall"
Dec 2009
Adirondack Mtns
2·3^{2}·233 Posts 
I'd like to renew this thread just long enough to revisit the following. I've probably missed something in my studies, or maybe this just isn't doable. Anyway:
I'm trying to figure out how to calculate where the coincidence of two series will happen. The series grow by a known progression. I know the starting integer and the progression for each series, but I can't figure out a way to calculate coincidence. Is that because it can't be done, or because I don't know enough? series1 is 2704+105+107+109+111... series2 is 2691+17+19+21+23+25... series1 will equal 2916 at 2705+105+107 series2 will equal 2916 at 2691+17+19+21+23+25+27+29+31+33 Is there a way to calculate the value 2916 directly, if it is unknown? IOW, can 2705+105+107... = 2691+17+19... be calculated instead of stepping through each to coincidence? Obviously, I'll want to be able to do this with much larger integers, but these small ones illustrate my query. Thanks for any replies... 
20171003, 05:52  #44 
Aug 2006
3×1,993 Posts 
If you can compute them termbyterm, and if each summand is a positive integer, it's not hard.
Code:
coincidence(f, g, terms)= { my(n1, n2, s1, s2); while(max(n1,n2) < terms, if(s1==s2, print("Sum of the first "n1" terms equals sum of the first "n2" terms"); s1 += f(n1++); s2 += g(n2++) , if(s1<s2, s1 += f(n1++) , s2 += g(n2++) ) ) ); } coincidence(n>if(n>1, 2*n+101, 2704), n>if(n>1, 2*n+13, 2691), 1e6); 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
radius of convergence of a complex power series  wildrabbitt  Math  3  20160816 08:38 
Modification of Fermat's method  rdotson  Miscellaneous Math  0  20070727 10:32 
Elliptic Curve Method factoring  Fermat numbers  philmoore  Math  131  20061218 06:27 
Fermat's factoring method with Gauss's inprovement  Carlos  Programming  0  20050911 12:50 
Convergence of infinite series  LoKI.GuZ  Math  10  20041128 03:07 