Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Kitonum By {phi}, he means the empty set (although this notation is inaccurate).

@Stretto You wrote:

  • No where on that page do they talk about using a database for pi(x).

Here is the relevant passage about the database for pi(x):

  • Andrey V. Kulsha has a file of the successive rounded values of 1.5*(π(x)-li(x)) for the 100,000,000 multiples of 109 less than 1017.... In 2014, Andrew Carr and I converted these to actually differences (rather than successive differences) so we can find π(x) for multiples of 109 with a single file read and a quick calculation of li(x). For other values we use the nearest multiple of 109 and sieve the region between to find π(x).

@Stretto You said, "Maple gives no indication how it is computing pi(x)." You can read the code via

showstat(NumberTheory::prime_counting);

You can see that it's quite simplistic compared to VV's.

@vv Good work on that procedure, and vote up.

Its time can be improved significantly with some remember tables and replacing some calls to ithprime with equivalent calls to nextprime.

restart:
Lpi := module()  # Lehmer pi
  local
      M:=10^7,
    
      phi := proc(x, a)
      option remember;
          if a <= 1 then iquo(x + 1, 2)
          else thisproc(x, a-1) - thisproc(iquo(x, ithprime(a)), a-1)
          fi
      end proc,

      ModuleApply:= proc(x)
      option remember;
      local a,b,c,s,w,i,j,L, xx:= trunc(x), p_i, p_j;
          if xx < M then return NumberTheory:-pi(x) fi;
          a := thisproc(iroot(xx, 4));;
          b := thisproc(isqrt(xx));
          c := thisproc(iroot(xx, 3));
          s := phi(xx,a) + (b+a-2) * (b-a+1) / 2;
          p_i:= ithprime(a+1)-1;
          for i from a+1 to b do
              w := iquo(xx , (p_i:= nextprime(p_i)));
              L := thisproc(isqrt(w));
              s-= thisproc(w);
              if i <= c then
                  p_j:= p_i - 1;
                  for j from i to L do
                      s-= thisproc(iquo(w , (p_j:= nextprime(p_j))))
                          - j + 1
                  od
              fi
          od;
          s
      end proc
;
end module:

CodeTools:-Usage(Lpi(6469693230));
memory used=3.40GiB, alloc change=80.00MiB, cpu time=29.58s, real time=26.99s, gc time=6.81s

                           300369796

By putting it in a module, as I have above, it will "learn" from each usage, making subsequent usages faster.

What do you mean by "I would like to plot the plane formed by the solutions"? The solution is a single point.

@mathkid99 It looks like you had specified elementwise multiplication rather than the usual matrix multiplication. Using the usual input syntax (rather than the more-elaborate form that's shown in your transcript), the elementwise multiplication of matrices and is A *~ B, and the usual matrix multiplication is A . B (spaces optional in both cases). Of course, each of these operations has its own size-matching requirements for the operands.

@kelvin goh It should be g, not g(x). It should be undefined, not undefine.

Even by imposing various severe conditions on the parameters (such as k_1= 0, k_2= 0), I can't get any solution where z <> 0 or w <> 0.

@Carl Love Here's the same thing done in code that should work in Maple 2015:
 

restart:

Veq:= 3/2-9/2*exp(-2*x)-9/2*exp(-x)+1/2*int(exp(-y)*Z(x-y), y= 0..ln(2));

3/2-(9/2)*exp(-2*x)-(9/2)*exp(-x)+(1/2)*(int(exp(-y)*Z(x-y), y = 0 .. ln(2)))

eps:= 1e-4:
S[0]:= 3/2: S[-1]:= 0:

for n while evalf(Int(abs@(S[n-1]-S[n-2]), 1.5..3.5)) >= eps do
    S[n]:= unapply(eval(Veq, Z= S[n-1]), x)
od
:

n;

13

plot(S[n-1], 1.5..3.5);

 


 

Download IntEq.mw

@Carl Love Gimme a moment, and I'll retrofit that to your Maple 2015.

@LichengZhang The English word "next" as used by John May implies something in the future. Maple 2019.2's release is something in the past.

Are you saying that after 6 years on MaplePrimes, you don't know how to even enter the above equations into Maple?

@Kitonum Please post worksheets inline so that I can read them on my phone. 

Please post worksheets inline so that I can read them on my phone.

@dingtianlidi Hmm, I see that you're right. I couldn't do anything to get colorscheme= ["xyzcoloring", ...to work with tubeplot. But it won't give an error message either! Unfortunately, that misled me to believe that my previous plot was correct.

Here's an alternative which I'm sure works (as can be seen in the plot below). We use the old-style option color= COLOR(HUE, C(t)) where C(t) is an expression in the parameter t scaled to 0..1.
 

restart:

S1:= x*y+y*z+x*z = 0:
S2:= x+y+z = 5:

E:= eliminate({S1,S2}, z);

[{z = -x-y+5}, {-x^2-x*y-y^2+5*x+5*y}]

#I'll call the 2nd part above the "residual". The only "trick" to
#parameterizing is to make two-variable substitutions for (x,y) into the
#residual that
#can be uniquely solved for one of those two variables. Polar coordinates is a
#standard such trick for circles and ellipses.
Polar:= {x= r*cos(t), y= r*sin(t)}:

R:= solve(eval(E[2], Polar), r);

{r = 0}, {r = 5*(cos(t)+sin(t))/(cos(t)^2+cos(t)*sin(t)+sin(t)^2)}

#We can discard the trivial solution. The final paramterization is

Pt:= combine(eval[recurse]([x,y,z], Polar union E[1] union R[2]));

[5*(cos(2*t)+1+sin(2*t))/(2+sin(2*t)), -5*(-sin(2*t)-1+cos(2*t))/(2+sin(2*t)), -5*sin(2*t)/(2+sin(2*t))]

#Express coloring function in terms of the paramter (t):
C:= eval(x*y*z, [x,y,z]=~ Pt)
:

#We need to put the colors on a 0..1 scale:
(m,M):= (minimize,maximize)(C, t= -Pi..Pi);
C:= (C-m)/(M-m):

-500/27, 0

plots:-tubeplot(
    Pt, t= -Pi..Pi, radius= .2, numpoints= 300,
    color= COLOR(HUE, C),
    style= surface, scaling= constrained
);

 


 

Download ColoredTubeplot.mw

Note that x+y+z is constant 5 on the circle, so that doesn't make a good coloring function.

The radius option to tubeplot refers to the cross-sectional radius of the tube, not the radius of the overall circle.

First 219 220 221 222 223 224 225 Last Page 221 of 708