Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@gkokovidis @tomleslie

The Question is about Maple Calculator. There are no worksheets to upload.

@ecterrab You wrote:

  • By the way, the documentation of the Physics:-Vectors package looks clear and complete ... if you feel it doesn't please post some suggestions (thanks) and I will take them a look.

In my Maple 2021.1, there is no help page for ChangeCoordinates, nor is there any mention of this command on the Physics:-Vectors help page. However, the command does exist, and your worksheet executes in my Maple exactly as shown in your Answer.

@Kevin Dragnet To use dchange with my code above requires only 1 change to the code. In the last line, change eval(sys, Tr) to

​​​​​​PDEtools:-dchange(Tr, sys, P)

This does exactly the same thing, and in essentially the same way, as Rouben's Reply two above this one. I've simply hidden my polar coordinates in the list (for the sake of abstraction). 

@maplefan123 So, is it working for you? not working? somewhere in between? Are you having trouble understanding or implementing something that I wrote? I'm happy to provide more-detailed explanations of anything. Your memory allocation error is perplexing to me, and I want to make sure that's resolved. As I said, the memory allocation for this code is trivial, as is usually the case when an iterator is used correctly[*1]. Indeed, reducing the memory allocation is a primary reason for the invention of iterators.

[*1] Storing the entire output of an iterator in a container (such as an array) subverts the memory benefit.

@maplefan123 The latest error that you report---in LinearAlgebra:-Norm---indicates that you're using 2D Input, which is misinterpreting my string catenation operation ...||n||... as a vector norm operation. My code is intended to be run in 1D input (aka Maple Input) only. The code should appear in your worksheet in a red-brown bold monospaced font, exactly as shown in my Reply above. Download this worksheet and execute it directly:

Download AllGraphs.mw

Perhaps the memory issue is also due to the 2D Input, although in that case I don't recognize the exact mechanism of code misinterpretation that would cause a memory allocation error. Like you, I'm also using Windows 10. I've run the code above in Maple 2018, 2019, and 2021 with identical results, and the memory allocation is very small. If you continue to have a memory problem, tell me what the Memory column of Windows Task Manager tells you. The parent process of your Maple session is "Java(TM) Platform SE binary" from the Processes tab. If you don't know how to use Windows Task Manager, let me know, and I'll explain it.

@maplefan123 My code above does not use any significant amount of memory. On the other hand, your original code does use a lot of memory. Yes, things running in the background are using some memory. Keep an eye on your memory usage in Windows Task Manager (or whatever your system's equivalent is).

When you edit a Reply, MaplePrimes does not update the Reply's timestamp. (This is a serious shortcoming of MaplePrimes.) So, you should report errors in new Replies or there's a good chance that no-one will see them. You're just lucky that I saw your edit about the memory issue.

Here are my runs for from 6 to 9. The memory allocation reported at the bottom of my screen never went above 25Mb. (The number reported as "memory used" by CodeTools:-Usage is irrelevant to this; it does not represent the amount of memory allocated. "Memory used" is a cumulative rather than instantaneous measurement, akin to the distinction between a car's odometer and its speedometer.)

restart:
currentdir("C:/Users/carlj/desktop"): #Change this line!!
AllGraphs:= proc(n::posint)
local
    L:= GraphTheory:-NonIsomorphicGraphs(
        n, output= iterator, outputform= adjacency, 
        selectform= adjacency,
        select= (A-> evalb(ArrayTools:-AnyNonZeros(A[-1]) = 1))
    ),
    Text:= 
        "\ntext1 text2 text3\ntext2 text2 text3\ntext3 text3 text3\n"
        "text4 text4 text4\ntext5 text5 text5\n\n",
    fp:= FileTools:-Text:-Open("Graphs"||n||".txt", create, overwrite),
    k, A
;
    fprintf(
        fp,
        "This is the top of the file.\n\n"
    );
    for k while (A:= L()) <> FAIL do 
        fprintf(fp, "G=%a"||Text, {lhs}~(op(2,A))) 
    od;
    FileTools:-Text:-Close(fp);
    k
end proc
: 
for n from 6 to 9 do
    nprintf("Number of %d graphs", n) = CodeTools:-Usage(AllGraphs(n))
od;
memory used=3.48MiB, alloc change=32.00MiB, 
cpu time=62.00ms, real time=55.00ms, gc time=15.62ms

                    Number of 6 graphs = 123

memory used=14.18MiB, alloc change=0 bytes, 
cpu time=297.00ms, real time=286.00ms, gc time=0ns

                    Number of 7 graphs = 889

memory used=200.24MiB, alloc change=5.00MiB, 
cpu time=3.92s, real time=3.94s, gc time=578.12ms

                   Number of 8 graphs = 11303

memory used=4.71GiB, alloc change=-4.00MiB, 
cpu time=103.84s, real time=106.84s, gc time=15.20s

                  Number of 9 graphs = 262323

@Carl Love In case it's not obvious, my above-recommended value is intended for the dsolve that you did after setting the values of d1, d2, d3, d4, d5, and L. Getting a useful result from your first dsolve requires both assumptions (as used by Preben) and value (used without mention by Preben).

@maplefan123 To put some lines of text at the top of the file, use an fprintf command such as below immediately before the while:

fprintf(
    fp,
    "This is\n5 lines\nof text\nfor the top\nof the file.\n\n"
);

@Preben Alsholm The expressions can be greatly simplified with two further assumptions: 0 < d1, d5 < L.

@Carl Love I tested Answer 1, the value method, and it works. I didn't test Answer 2 because Answer 1 is much easier to implement anyway: After the dsolve command, just do value(%).

@vv Your formula treats (6, -3) as the focus of the parabola, not as its vertex.

@vv In my opinion, using HFloat to wrap the target being searched for is by far the best of the given Answers, but the OP seems to be ignoring your Answer. The other Answers--converting to rationals or using software floats--incur a substantial performance penalty.

@Ali Guzel In brief, you should do this:

numboccur(x2[1], HFloat(0.))

This is because Sample returns an array of hardware floats. Hardware floats are not exact matches to their software-float counterparts. That's what you're missing.

@Preben Alsholm You are passing arguments to numboccur in the wrong order; the first argument should be the container, and the second argument the item being counted.

I'd like to elaborate on what Mac Dude said is his P.S. The fact that a help page says that a command is intended for arguments of a certain type can't be used to infer that it won't also work for some arguments not of that type. I think that your type command returning false can be taken as definitive proof that the object is not type series.

The special parameter _rest can be used to "pass along" optional arguments without a procedure knowing what those arguments are or even whether they're present at all. I find this very useful for any procedure whose output is a plot.

waterfall:= proc(
    data::list(numeric),
    {colors::And(list({name, function, string}), 2 &under nops):= 
        ["green", "red"]
    }
)
uses P= plots, PT= plottools;
local d:= [0, data[]], c:= colors[(sign~(d[..-2] -~ d[2..]) +~ 3)/~2];
    d:= `[]`~([$0..nops(data)], d);
    P:-display(PT:-rectangle~(d[..-2], d[2..], ':-color'=~ c), _rest)
end proc
:
data := [6, 4, 4, 4, 7, 9, 12, 16, 25, 100, 105, 95, 90, 55, 45, 30]:
waterfall(data, colors= [purple, yellow], axes= boxed);

First 113 114 115 116 117 118 119 Last Page 115 of 709