Carl Love

Carl Love

28050 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

I'd do this:

plot(
    f[1](x), x= -5..5,
    legend= typeset("function ", convert(f, `local`)[1](x))
)

@Carl Love The above Answer is doing that taking-forever-to-submit thing that I described a few days ago. This Reply is just to increment the Replies counter and update the Last Action time.

@Joe Riel The problem with directly using the view option as you propose is that the OP wants to use the automatically generated VIEW option if its y-component includes 0. And if it doesn't include 0, the OP wants to enlarge it only so much as is needed to include 0.

@Carl Love The above Answer is doing that taking-forever-to-submit thing that I described a few days ago. This Reply is just to increment the Replies counter and update the Last Action time.

@Preben Alsholm I assume that you wanted to use the smallest possible thickness for the horizontal line. The smallest is not 1. The smallest integer thickness is 0. Floating-point values between 0 and 1 will produce lines even thinner than thickness= 0. On my current screen, the smallest practical value seems to be 0.05; smaller positive values give me visible lines that appear the same as using 0.05.

Formally speaking, the period is the number of digits in the fundamental repeating part, not the repeating part itself. So, the base-10 period of 1/12 is 1.

@Ronan Meta-parameters (most of whose names begin with underscore: _params, _nparams_options_noptions_rest_nrest_passed_npassed) are described in section "Special Sequences" of help page ?using_parameters. You must use the specific name _rest, but you could have assign it to a local variable so that the _rest can be isolated at the top of the procedure. For example,

MyPlot:= proc(MainArgs::list)
local
    default_opts:= (color= red, thickness= 0, linestyle= dash),
    ad_hoc_opts:= _rest
;
    plot(MainArgs[], default_opts, ad_hoc_opts
)
end proc;

 

@nm Your example -- a procedure with local n::integer -- is not giving a type to n. Rather, it's enforcing (when kernel(assertlevel) = 2) a type check of the things that will be assigned to n, not itself. (Note that the type command in my procedure below explicitly says that x is not type integer.) Here's an example using a declared type on a variable vs. assuming an analogous property.

restart:
kernelopts(assertlevel= 2):
#Compare type integer...: 
proc() local x::integer, y::integer; 
    print([type(x, integer), is(x+1, integer)] assuming x::integer); 
    y:= x+1
end proc();
                             [false, true]
Error, (in anonymous procedure) assertion failed in assignment to y, expected integer, got x+1

#...versus property integer:
assume(x::integer); y:= x+1: [type, is](y, integer);
                             [false, true]

Also, I should point out that Maple's type system is much more complicated and much more important than its property system.

Another example: Maple has a pre-defined type nothing, which always returns false. You can put ::nothing in a variable's local declaration. The reason one may want to do this is that it protects (under kernelopts(assertlevel) = 2) against the variable being assigned to. But you can still use the variable symbolically.

 

And here's the imaginary part:

@dharr Okay, I understand, and I withdraw my comment about it being incorrect. And I put a more-formal withdrawal at the top of the Reply.

[Edit: I understand dharr's followup explanation, and I withdraw my comment about the work being incorrect. I didn't realize that it was just solving (correctly) a different problem than the OP intended, specifically one where certain edges are forbidden.]

@dharr Your algorithm for reducing the Hamiltonian cycle to a Hamiltonian path is incorrect. In particular, I don't understand how you chose your edges. If I apply my dummy-vertex algorithm (from my Answer below) to your points, I get a significantly shorter minimal path, 7.3 vs. 9.8. You can easily verify from the plots that my path is Hamiltonian and my edge weights are the same as yours.

restart:
pts:= [[0,0], [1,2], [4,2], [3,1], [5,1]]:  
n:= nops(pts):
GT:= GraphTheory: LA:= LinearAlgebra:
G:= (GT:-Graph@Matrix)(
   n+1, 
   (i,j)-> `if`(i=j, 0, `if`(i>n or j>n, 1, LA:-Norm(<pts[i]-pts[j]>, 2))), 
   shape= symmetric, datatype= hfloat
):
(MinDist, HamPath):= GT:-TravelingSalesman(G, startvertex= n+1):
MinDist-= 2; HamPath:= HamPath[2..-2];
                  MinDist := 7.30056307974577
                   HamPath := [1, 2, 4, 3, 5]
#Plot:
H:= GT:-InducedSubgraph(G, [$1..n]):  #Discard dummy
GT:-SetVertexPositions(H, pts);
GT:-HighlightTrail(H, HamPath);
GT:-DrawGraph(H, axes= frame, scaling= constrained);

I think you're posting in the wrong forum. As far as I know, no Meplesoft product has a subpart named "Workday".

I wonder how ChatGPT came up with the non-existent command Optimization:-LinearSumAssignment. It had to have read that somewhere; it doesn't just make up fake Maple command names on a whim.

@C_R The command that you're thinking of is called unames.

@Scot Gould I've also noticed a speed improvement the past day or two 

First 20 21 22 23 24 25 26 Last Page 22 of 709