Carl Love

Carl Love

26381 Reputation

25 Badges

11 years, 137 days
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity

These are replies submitted by Carl Love

@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.

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.

pts:= [[0,0], [1,2], [4,2], [3,1], [5,1]]:  
n:= nops(pts):
GT:= GraphTheory: LA:= LinearAlgebra:
G:= (GT:-Graph@Matrix)(
   (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]
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 

@nm The counter can be reset, without using restart, by

`tools/genglobal`[1](_C, 1, reset);

That form of the command just does the reset without returning a name. So, the next call to `tools/genglobal`(_C) will return _C1.

@Scot Gould I've experienced the same thing as you: The norification flag used to do something (not something that I find useful---but that's beside the point) and now it just says Loading.

See the help page ?simplify,size.

@mmcdara Those two things are not necessary for your example, but might be needed for some generalization that you have in mind. What I can't figure out is why assigning invfunc[phi] doesn't require the unprotect, but assigning both invfunc[phi] and invfunc[invphi] does require it.

The use of invfunc can be implemented like this:

phi:= u-> (u^(-theta)-1)/theta:
invphi:= unapply(solve(phi(x)=u, x), u):
unprotect(invfunc): invfunc[phi]:= invphi: invfunc[invphi]:= phi: protect(invfunc):
C:= (u,v)-> simplify((phi@@(-1))(phi(u)+phi(v))):


To understand better what's going on here, check out showstat(`@@`).

@janhardo I don't find it at all surprising that ChatGPT can give you an extensive discussion of the infinitude of primes, which is one of the most-ancient topics of formal abstract mathematics. But how does it involve Maple or any computer language?

Yes, I have noticed that most operations on MaplePrimes have been much slower for a few weeks.

1 2 3 4 5 6 7 Last Page 1 of 687