dharr

Dr. David Harrington

6083 Reputation

21 Badges

19 years, 322 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a professor of chemistry at the University of Victoria, BC, Canada, where my research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are replies submitted by dharr

@dharr If your objective is to follow the derivation in the paper, I can mostly derive the laplace transformed quantities, but I have to guess at the initial conditions - what are they? And why do x and y suddenly appear in the solution? Perhaps you can provide a link to the paper.

@Traruh Synred Somehow Export is being interpreted as ExportMatrix. I can't reproduce this in Maple 2023. @acer suggests you are using 2018, which had Export, but Maple 18 did not (use interface(version) to check your version). You can convert to a 4x1 Matrix and export it as you said, but saving to a .m file will save any Maple object and might be better for your application.

@Traruh Synred I can't figure out what is happening (not a version error) - please upload your worksheet using the green up-arrow in the Mapleprimes editor - choose the file, upload then choose insert link or insert contents.

@sursumCorda I added the timing test for the undocumented Makesplit, and it is not so different from some of the others, I guess there is a lot of overhead for some of these, so it might have been fairer to test with a case that had many more digits.

As for ithprime, according to ?GMP, it makes extensive use of the GMP library isprime, though that is for more digits that your test case here. Actually, processing nextprime a million times in 30 seconds seems pretty good to me!


restart;

p:= 2233433222;

2233433222

What is the fastest way to get the digits of an integer (encoded in any form) into an Array

p1:=proc(p); StringTools:-ToByteArray(sprintf("%d",p)) end proc:

a1:=CodeTools:-Usage(p1(p),iterations=10^6);

memory used=0.98KiB, alloc change=45.00MiB, cpu time=8.75us, real time=8.32us, gc time=8.3e+02ns

Vector[row](10, {(1) = 50, (2) = 50, (3) = 51, (4) = 51, (5) = 52, (6) = 51, (7) = 51, (8) = 50, (9) = 50, (10) = 50})

p2:=proc(p); Array(StringTools:-Explode(sprintf("%d",p))) end proc:

a2:=CodeTools:-Usage(p2(p),iterations=10^6);

memory used=496 bytes, alloc change=-4.00MiB, cpu time=4.11us, real time=3.87us, gc time=5.2e+02ns

Vector[row](10, {(1) = "2", (2) = "2", (3) = "3", (4) = "3", (5) = "4", (6) = "3", (7) = "3", (8) = "2", (9) = "2", (10) = "2"})

p3:=proc(p); Array(convert(p,base,10)) end proc: #shockingly slow

a3:=CodeTools:-Usage(p3(p),iterations=10^6);

memory used=10.04KiB, alloc change=0 bytes, cpu time=64.62us, real time=59.91us, gc time=10.34us

Vector[row](10, {(1) = 2, (2) = 2, (3) = 2, (4) = 3, (5) = 3, (6) = 4, (7) = 3, (8) = 3, (9) = 2, (10) = 2})

p4:=proc(p) local i,s:=sprintf("%d",p); Array([seq(s[i],i=1..length(s))]) end proc:

a4:=CodeTools:-Usage(p4(p),iterations=10^6);

memory used=0.79KiB, alloc change=0 bytes, cpu time=5.88us, real time=5.53us, gc time=7.0e+02ns

Vector[row](10, {(1) = "2", (2) = "2", (3) = "3", (4) = "3", (5) = "4", (6) = "3", (7) = "3", (8) = "2", (9) = "2", (10) = "2"})

p5:=proc(p) local i,s:=sprintf("%d",p); Array(1..length(s),i->s[i]) end proc:

a5:=CodeTools:-Usage(p5(p),iterations=10^6);

memory used=0.90KiB, alloc change=0 bytes, cpu time=7.48us, real time=7.04us, gc time=9.2e+02ns

Vector[row](10, {(1) = "2", (2) = "2", (3) = "3", (4) = "3", (5) = "4", (6) = "3", (7) = "3", (8) = "2", (9) = "2", (10) = "2"})

p6:=proc(p) Array(convert(sprintf("%d",p),'bytes')) end proc:

a6:=CodeTools:-Usage(p6(p),iterations=10^6);

memory used=504 bytes, alloc change=0 bytes, cpu time=3.52us, real time=3.26us, gc time=5.3e+02ns

Vector[row](10, {(1) = 50, (2) = 50, (3) = 51, (4) = 51, (5) = 52, (6) = 51, (7) = 51, (8) = 50, (9) = 50, (10) = 50})

p7:=proc(p); kernelopts(opaquemodules=false); Array([`convert/base`:-MakeSplit(length(p), 1, 10)(p)]) end proc:

a7:=CodeTools:-Usage(p7(p),iterations=10^6);

memory used=0.83KiB, alloc change=0 bytes, cpu time=7.95us, real time=7.16us, gc time=1.67us

Vector[row](10, {(1) = 2, (2) = 2, (3) = 2, (4) = 3, (5) = 3, (6) = 4, (7) = 3, (8) = 3, (9) = 2, (10) = 2})

NULL

 

Download DigitsToArray.mw

@2cUniverse You cannot export a plot structure to a .tiff file. But you can convert it to an Image and then use ImageTools:-Write to write the file - see the code I provided above.

@Scot Gould I used the term "copy contents". The Vector has to be pre-existing; in your example z was not predined as a vector, and by default was a table. copy(v) does copy the vector and is fine at the top level, but within the OPs procedure prev:=copy(curr) still has the problem of assigning to a formal parameter.

@2cUniverse You can convert a plot directly to an Image without writing it to a file, so I think the following does what you want. I made the white background in the plot structure but if you prefer you can add it with PadImage after converting.

restart;

Make some square plot structure with white frame

sq:=plottools:-rectangle([-1,-1],[1,1],color=red):
lbl:=plots:-textplot([0,0,"HELLO"]):
whitebg:=plottools:-rectangle([-1.1,-1.1],[1.1,1.1],color=white):
plt:=plots:-display([sq,whitebg,lbl],axes=none,scaling=constrained,size=[500,500]):

Convert plot structure to image and output as .tiff

img:=convert(plt,Image):

ImageTools:-Write("C:/Users/dharr/Desktop/plt.tiff",img);

9510

NULL

Download maketiff.mw

@2cUniverse You can output plots to .gif or .jpeg or .png or  some other image formats (not .tiff). You can set the directory to anything you like for example

path:="C:/Users/dharr/Desktop";
filnam:=cat(path,"/plt",i,".gif");

and omit the base=option if using Export.

@2cUniverse I didn't understand your resolution comments. You could add the white frame as a rectangle behind all elements before exporting the plot in whatever format you want at whatever resolution you want (or as svg or eps vector graphics to later convert to tiff)

Edit: Following makes a square SVG with a white frame.

restart;

Make some square svg files with white frame

for i to 3 do
  sq:=plottools:-rectangle([-1,-1],[1,1],color=red);
  lbl:=plots:-textplot([0,0,convert(i,string)]);
  whitebg:=plottools:-rectangle([-1.1,-1.1],[1.1,1.1],color=white);
  plt:=plots:-display([sq,whitebg,lbl],axes=none,scaling=constrained,size=[0.5,"square"]);
  Export(cat("plt",i,".svg"),plt,base=worksheetdir,format="SVG");
  #print(plt);
end do:

NULL

Download makesvg.mw

@2cUniverse I can't access your zip file. But here is how to make square format .png files (I used Export) - note the size option to give the number of pixels.

restart;

Make some png files

for i to 3 do
  sq:=plottools:-rectangle([-1,-1],[1,1],color=red);
  lbl:=plots:-textplot([0,0,convert(i,string)]);
  Export(cat("plt",i,".png"),plots:-display(sq,lbl,axes=none,scaling=constrained,size=[500,500]),base=worksheetdir);
end do:

NULL

Download makepng.mw

Infolevel can be used to show the methods used, though the output is not always easy to understand. In this case further information about the homogeneous methods is given in the odeadvisor help pages.

restart;

Equation := int(diff(u(x), x)*v(x), x) = int(u(x)^(1/2)*v(x), x)^(-2/3);

int((diff(u(x), x))*v(x), x) = 1/(int(u(x)^(1/2)*v(x), x))^(2/3)

infolevel[dsolve]:=3;

3

Solution1:=dsolve(Equation);

Methods for first order ODEs:

--- Trying classification methods ---

trying homogeneous types:

differential order: 1; looking for linear symmetries

trying exact

-> Calling odsolve with the ODE (2*G(x)^(1/2)*v(x)+Intat(v(_a)*(diff(G(x) x))/G(x)^(1/2) _a = x))/Intat(G(x)^(1/2)*v(_a) _a = x)^(8/3) G(x) explicit [quadrature separable linear Bernoulli homogeneous]

   *** Sublevel 2 ***

   Classification methods on request

   Methods to be used are: [quadrature, separable, linear, Bernoulli, homogeneous]

   ----------------------------

   * Tackling ODE using method: quadrature

   --- Trying classification methods ---

   ----------------------------

   * Tackling ODE using method: separable

   --- Trying classification methods ---

   ----------------------------

   * Tackling ODE using method: linear

   --- Trying classification methods ---

   ----------------------------

   * Tackling ODE using method: Bernoulli

   --- Trying classification methods ---

   ----------------------------

   * Tackling ODE using method: homogeneous

   --- Trying classification methods ---

   trying homogeneous types:

<- exact successful

(3/4)*u(x)^(4/3)+Intat((2/3)*u(x)^(5/6)/(Int(u(x)^(1/2)*v(_b), _b))^(5/3), _b = x)+c__1 = 0

Odetest cannot verify this solution

odetest(Solution1,Equation);

-2*Intat(v(_b)/(Intat(v(_a), _a = _b)*(u(x)^(1/2)*Intat(v(_a), _a = _b))^(2/3)), _b = x)*(u(x)^(1/2)*(Int(v(x), x)))^(2/3)-3

NULL

Download dsolve.mw

 

@AlexShura OK, so you only entered the sequence to 512. Maple's listtoalgeq still returns fail, so I agree that the oeis result is unexpected and hard to interpret.

@AlexShura Email response (below) does not contain the polynomial in a(n). Please advise how you got that.

Greetings from The On-Line Encyclopedia of Integer Sequences! https://oeis.org/

 

> lookup 1 2 4 5 8 12 14 16 28 32 37 64 94 106 128 144 232 256 289 320

> 512 560 704 760 838 1024 1328 1536 1944 2048 2329 3104 3328 4096 4864

> 6266 6802 7168 8192 11952 15360 16384 16428 19149 28928 32768

 

a(n) = 1, 2, 4, 5, 8, 12, 14, 16, 28, 32, 37, 64, 94, 106, 128, 144, 232, 256, 289, 320, 512, 560, 704, 760, 838, 1024, 1328, 1536, 1944, 2048, 2329, 3104, 3328, 4096, 4864, 6266, 6802

 

# Direct matches

 

These sequences match the query directly.

oeis.org/search?q=1,2,4,5,8,12,14,16,28,32,37,64,94,106,128,144,232,256,289,320,512,560,704,760,838,1024,1328,1536,1944,2048,2329,3104,3328,4096,4864,6266,6802

 

oeis.org/A035001 Sorted elements of table (A035002) of a(m,n) =

                 sum(a(m-k,n), k=1..m-1)+sum(a(m,n-k), k=1..n-1).

 

    <1, 2, 4, 5, 8, 12, 14, 16, 28, 32, 37, 64, 94, 106, 128, 144, 232,

    256, 289, 320, 512, 560, 704, 760, 838, 1024, 1328, 1536, 1944, 2048,

    2329, 3104, 3328, 4096, 4864, 6266, 6802>, 7168, 8192, 11952, 15360,

    16384, 16428, 19149, 28928, 32768, 37120, 42168

 

 

# Transformations

 

These sequences match transformations of the original query.

 

T001 a(n) itself

 = 1, 2, 4, 5, 8, 12, 14, 16, 28, 32, 37, 64, 94, 106, 128, 144, 232, 256, 289, 320, 512, 560, 704, 760, 838, 1024, 1328, 1536, 1944, 2048, 2329, 3104, 3328, 4096, 4864, 6266, 6802

 

oeis.org/A035001 Sorted elements of table (A035002) of a(m,n) =

                 sum(a(m-k,n), k=1..m-1)+sum(a(m,n-k), k=1..n-1).

 

    <1, 2, 4, 5, 8, 12, 14, 16, 28, 32, 37, 64, 94, 106, 128, 144, 232,

    256, 289, 320, 512, 560, 704, 760, 838, 1024, 1328, 1536, 1944, 2048,

    2329, 3104, 3328, 4096, 4864, 6266, 6802>, 7168, 8192, 11952, 15360,

    16384, 16428, 19149, 28928, 32768, 37120, 42168

 

 

# Transformations as Deltas

 

The deltas of these sequences match transformations of the original query.

 

T018 a(n+1) - a(n)

 = 1, 2, 1, 3, 4, 2, 2, 12, 4, 5, 27, 30, 12, 22, 16, 88, 24, 33, 31, 192, 48, 144, 56, 78, 186, 304, 208, 408, 104, 281, 775, 224, 768, 768, 1402, 536 (as deltas)

 

oeis.org/A035001 Sorted elements of table (A035002) of a(m,n) =

                 sum(a(m-k,n), k=1..m-1)+sum(a(m,n-k), k=1..n-1).

 

    <1, 2, 4, 5, 8, 12, 14, 16, 28, 32, 37, 64, 94, 106, 128, 144, 232,

    256, 289, 320, 512, 560, 704, 760, 838, 1024, 1328, 1536, 1944, 2048,

    2329, 3104, 3328, 4096, 4864, 6266, 6802>, 7168, 8192, 11952, 15360,

    16384, 16428, 19149, 28928, 32768, 37120, 42168

 

 

In transformation descriptions,

Sn(z) denotes the ordinary generating function with coefficients a(n), and

En(z) denotes the exponential generating function with coefficients a(n).

 

___________________________________________________________________________

 

o  You can look up sequences online at the OEIS web site https://oeis.org/ o  For an explanation of the format used in the OEIS,

     see https://oeis.org/wiki/Style_Sheet o  If your sequence was not in the OEIS and is of general interest,

     please submit it using the submission form https://oeis.org/Submit.html o  The email address <sequences@oeis.org> does a simple lookup in the

   On-Line Encyclopedia of Integer Sequences, a limited form of the search

   available on the web site.

o  If you send an empty message, you will be sent the help file.

 

    Sequentially yours,

    The On-Line Encyclopedia of Integer Sequences.

    Maintained by The OEIS Foundation Inc., https://oeisf.org.

    Please donate!

 

P.S. This content is made available under the terms of The OEIS End-User License Agreement: https://oeis.org/LICENSE

Perhaps I'm not understanding what you did, but I can't reproduce this.

A035001.mw

 

First 15 16 17 18 19 20 21 Last Page 17 of 62