Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 360 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@das1404 Thanks, I like it! These can be nice as electronic greeting cards.

Some possibilities for improvement:

  1. I think the left upright of the R should be thicker.
  2. The football should start smaller than it currently starts.
  3. The football should end larger than it currently ends.
  4. Speed up the transformation of the Y. It should be fully upright by the time that the football reaches it and stay fixed that way until the end.

@vv VV, I was trying to give Adam some gentle guidance and instruction in asymptotics, Bachmann-Landau notation, and "experimental mathematics with Maple" by using the function that he's interested in. If that function turns out to be not very interesting, that's not very relevant to me; there's still value in the instruction itself.

Adam, regression coeffiecients tend to become unstable when we know that one of them "is supposed to be" a certain value, especially if it's a coefficient of a high-order term. Let's accept that the coefficient of n is 1. Now we go for a second asymptotic term, a2(n). So, we want to find a2(n) such that (f(n) - a1(n)) ~ a2(n) and limit(a2(n)/a1(n), n= infinity) = 0.[1] (And we'd strongly prefer that a2(n) be eventually monotonic and analytic.) You may use regression or other experimental mathematics to explore this: Perhaps try a2(n) = A*sqrt(n) + B or A*ln(n) + B or A*log[2](n)+B. And perhaps the second term is too erratic to classify this way, in which case we'd at least like an upper bound for abs(n - f(n)).

[1] This latter limit is usually expressed as a2(n) = o(a1(n)). That's little-o, not big-O.

@rahinui That's interesting that .mpl is not listed as valid by MaplePrimes. I would change the extension to .txt, which is listed as valid. I don't know what .maple is supposed to represent (perhaps the new workbooks, collections of worksheets?)

And now that I know that you were trying to upload a .mpl, please do upload it as a .txt, because the .mw is giving me some trouble.

@Adam Ledger Your notation with the ~ is correct: The statements "a1(n) is the 1st term of the asymtotic expansion (or series) of f(n)" and "limit(f(n)/a1(n), n= infinity) = 1" are both often abbreviated f(n) ~ a1(n). (Although I'm not yet prepared to say that your statement (1) is a rigorously proven theorem!)

In your statement (2), you've correctly used the big-O. However, if (1) is true, then (2) is ridiculously redundant. Indeed, if there exists any positive constant C such that limit(f(n)/a1(n), n= infinity) = C, then we could write f(n) = O(a1(n)); whereas statement (1) says that C = 1, exactly.

@minhthien2016 I anticipated this complication, (yet I gave Kitonum's Answer a Vote Up anyway). Here's an adjustment that'll guarantee that they come in the correct order (even if there's more than two extrema):

restart;
f:= x-> (4*cos(x)+sin(x))/(-2*cos(x)+sin(x)+3);
ex:= simplify(rationalize([extrema(f(x), {}, x)[]]));
(Min,Max):= ex[[(min[index],max[index])(evalf(ex))]][];
evalf([Min,Max]);

 

@das1404 Don't use a macro for that. Use a procedure, such as

Col2:= ()-> 'color' = 'COLOR'('RGB', 'evalf[8](rand()/10.^12)' $ 3);

I'm having trouble downloading your file. That may be due to the .maple file extension. Can you upload a (Standard) Maple worksheet with .mw extension?

@Adam Ledger Could you please write those formulae in a more-human-readable format rather than Latex or MathJax? I know that that incurs a risk of a loss of precision. That's a risk that I'm willing to accept.

By "first term of the asymptotic expansion of f(n)" what's meant is some relatively simple function a1(n), preferably eventually[1] monotonic and analytic, such that limit(f(n)/a1(n), n= infinity) = 1. Note that the PNT does nothing more than say that the first term of the asymptotic expansion of the prime-counting function pi(n) is n/ln(n).[2] So, just getting one term can be quite an achievement.

[1] "Eventually" means for all sufficiently large n.

[2] The function Li(n) = Int(1/ln(x), x= 2..n) can also be used for the first term, and it gives a more accurate approximation.

 

@Adam Ledger I am not an expert on the Prime Number Theorem, but perhaps I can give some help anyway. I read your StackExchange post that you linked to. 

So, you have a function defined on the positive integers, which I'm going to call f(n) (feel free to change the f). Here it is:

q:= n-> min(divisors(n*floor(ithprime(n)/n) minus {1}));
f:= n-> (n*igcd(n, n*q(n))-floor(sqrt(n))*igcd(floor(sqrt(n)), q(n)))^(1/2);

Please confirm that I have that right.

So, you want an asymptotic approximation to that. The evidence from the StackExchange post's replies suggests that the first term of that will be n.

 

@Gabriel samaila For the sake of completeness and full disclosure, here's the code that does the check that I referred to in my previous Reply:

_V0:= <V0, 0.5, 0.75, 1, 1>:
_Pr:= <Pr, 0.7, 0.7, 0.7, 0.015>:
_Pm:= <Pm, 0.5, 0.5, 1.0, 0.5>:
_Ha:= <Ha, 5, 5, 5, 0.5>:
T1:= <_V0 | _Pr | _Pm | _Ha >:
_Cf:= Vector(5, [C__f]):
#######
#This little hack is required to set Nb to 0 because it's a 
#denominator in ODEs. By setting Nt to 0 first, the fraction with Nb in the
#denominator disappears:
savODEs:= copy(ODEs):
ODEs:= eval(ODEs, [Nt, Br, Sc]=~ 0):
#End of hack.
######
for k from 2 to 5 do 
   sol:= Solve(convert(T1[1,..] =~ T1[k, ..], list)[], ([Nt, Br, Nc, Nb]=~ 0)[]);
   _Cf[k]:= eval(C__f, sol(.5)) #.5 is arbitrary between boundary points.
od:
#Restore ODEs to its original pre-hacked state:
ODEs:= savODEs:
#######
<T1 | _Cf>;

 

I converted your Post into a Question. I also needed to lengthen the title because there's a 15-character minimum.

@Carl Love Okay, here is a fair test that shows that iterating with nextprime is many times faster than iterating with ithprime when the primes are in the range just above the limit of Maple's fresh-out-of-the-box pre-stored knowledge of prime ranks, which is where you're currently getting stuck. To generate the first 30,000 such primes, nextprime is 25 times faster. But, the slowness of ithprime will increase (quadratically!) as you proceed due to an idiosyncracy of the way that Maple handles lists.[1]

restart:

PP:= op(op(4, eval(`ithprime/large`))):

p:= max(rhs~(PP));

419113693

(1)

PP:= 'PP':

P1:= proc(P::posint, n::posint)
local p:= P;
   to n do p:= nextprime(p) od;
   p
end proc:

gc(); CodeTools:-Usage(P1(p, 3*10^4));

memory used=175.34MiB, alloc change=0 bytes, cpu time=891.00ms, real time=886.00ms, gc time=62.50ms

 

419710261

(2)

restart:

PP:= op(op(4, eval(`ithprime/large`))):

n:= max(lhs~(PP));

22299999

(3)

PP:= 'PP':

P2:= proc(N::posint, n::posint)
local k, p;
   for k from N+1 to N+n do p:= ithprime(k) od;
   p
end proc:

gc(); CodeTools:-Usage(P2(n, 3*10^4));

memory used=4.02GiB, alloc change=32.00MiB, cpu time=22.75s, real time=22.83s, gc time=671.88ms

 

419710261

(4)

22.75/.891;

25.53310887

(5)

ithprime(n);

419113693

(6)

ithprime(n+3*10^4);

419710261

(7)

 

Download nextprime_vs_ithprime.mw

[1] Here are some details of that idiosyncracy: The ordinates (or indices) of the remember table of procedure `ithprime/large` are stored in the list `ithprime/global/list`. Use showstat(`ithprime/large`) to display the code of the procedure. On lines 6, 10, 17, and 22, you can see that items are added to the list as it acquires new knowledge about the ranks of larger primes. It is well known that adding items to long lists in Maple is extremely inefficient; indeed, the time required is proportional to the length of the list; so, using ithprime in a loop requires time at least proportional to the square of the number of iterations.

You can also see on lines 3-4 of the procedure that ithprime simply iterates with nextprime anyway when it's operating beyond the limit of its stored knowledge. That alone proves that nextprime must be at least a little faster for those primes. But the list idiosyncracy makes nextprime much faster.

@David Sycamore Rather than make a comparison of ithprime and nextprime (because I don't have time at the moment to construct a fair comparison of the two), I made the following test, which shows that for the range of primes that you're working with (I think), the nextprime method iterates through them at more than 30,000 primes per second  on my machine:

restart:
P:= proc(P::posint, n::posint)
local p:= P;
   to n do p:= nextprime(p) od;
end proc:
CodeTools:-Usage(P(3*10^8, 3*10^4)):

memory used=173.43MiB, alloc change=0 bytes, cpu time=906.00ms, real time=902.00ms, gc time=46.88ms

 

@Gabriel samaila If you make Nt=0 first, that will eliminate the term that has Nb in the denominator. After that, you can make Nb=0. Since the four unknown parameters now have numeric values, there's no need use fsolve; you can just use the procedure Solve that I already posted. I've done this, and I still get values for C__f completely different from those shown in Table 1.

@Gabriel samaila I haven't tried it yet. I think that you mean making Nb a small value, not Nt? I will try it.

First 327 328 329 330 331 332 333 Last Page 329 of 709