Carl Love

Carl Love

28045 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@tomleslie The edges do not need to be passed to the Graph constructor. You can replace

G2:= Graph({seq( seq( {i, j}, j in op(4,s)[i]), i=1..30)}):

with

G2:= Graph(op(4,s)):

And  you don't need IsIsomorphic to get phi. You can do

phi:= op(3,s) =~ [$nops(op(3,s))];

These aren't just syntactic shortcuts; they're significantly more efficient. 

@lcz My algorithm's approach is a simple straightforward check-all-subsets approach. Since the subsets are checked in size order, this is guaranteed to work. Of course, "all subsets" could easily be impossibly large to check, and some heuristics for special cases will likely have a better average-case time. I saw a paper recently that claimed a polynomial-time algorithm for certain classes of graphs, including triangle-free graphs. The writing was dense and very technical for me, and I didn't have the mental energy to plow through it. I'll post a link to that paper if you're interested. 

Formulating the problem as an ILP seems cute and academically interesting, but I'd guess that it doesn't have much practical value because there aren't average-case efficient algorithms for general ILPs. (Not sure.) Formulation as an LP would be a different matter.

I think that it could also be formulated as a boolean satisfiability problem, which Maple has a great algorithm for. (See ?Logic,Satisfy.) But, if the general problem is NP-hard, these things can't really help with the computation time.

@Danish Toheed I suppose that you're already aware that the "raw" Newton's method converges very slowly at points where both the function and its derivative are 0 (a condition usually equivalent to "multiple roots"). In practice, I often divide a function by its own derivative, then simplify, before applying Newton's to avoid this. (Yes, I know there are cases where this itself causes problems.)

@vlineze Your Answer reads to me as if it were written by ChatGPT. Was it?

@lcz Yes, in most languages that have a goto, it is fast, and the only harm that it can cause is stylistic. But the Maple goto is particularly slow (CPU time). If you don't believe me, then just construct a timing test of it.

I urge you to never consider using Maple's goto again. Maple's main looping command, do, is the most sophisticated looping command that I'm aware of in any language, and its options allow you to control any situation without using goto.

Just in case this wasn't already obvious: The main purpose of my Answer is to tell you that I don't think that it'd be a good idea to use evala on all your integrals. I wasn't denying that it can help in some cases.

@dharr As the OP has stated repeatedly over the years in numerous threads, they need an automatic way to stop processing, not a "button". The timelimit command is unreliable. Even if it works 99% of the time, that's not good enough. The OP does batch-mode processing of (I think) thousands of unrelated symbolic integrals and ODEs. It's a major hassle to get stuck on one that can't be killed via a trappable error such as timelimit gives.

@acer From reading only the posted and displayed part of Tom's worksheet, I don't see any.simplify with side relations command. Perhaps there is one in the worksheet that didn't get displayed. The result that I got is identical to what Tom got with subs followed by one-argument simplify.

@lcz Here is the reason that I know that the domination set that I return is of minimal size: Subsets of the vertices are checked in order by size. The loop that begins in V do checks all k-subsets of V on its kth iteration.

The first 9 words of your title---"Is there no function in Maple to calculate the..."---which is more than appears in the index "Active Conversations", have almost zero information content. Please change the title to the words after those: "Domination number of a graph". If you feel that you must include low-information words, then put them at the end of the title where they'll do less damage.

And there's no need to phrase titles as grammatical questions. It should only be done if it doesn't destroy the inforrnation content at the beginning.

My objections apply only to titles. If you want to begin the body with an actual question, that's fine by me.

I only looked at the worksheet above for about 10 seconds, so I might ask something in this Reply that you already answered. Anyway, it appeared that you're using a self-coded RK2. I have several questions about that:

  1. What happens if you use dsolve(..., numeric, method= classical[rk2], stepsize= ...)?
  2. What happens if you use self-coded RK3 or RK4?
  3. What happens if you use rk3 or rk4 in question 1?
  4. Do you think that the variable stepsizes used by the standard IVP methods (rkf45, etc.) are causing your problem? They can be limited.

@sursumCorda It's not hard at all---at least it's not hard in Maple---to make a few easy adjustments to the procedure that I already gave to do all of

  • Turn it into a procedure that returns both the depth and the leaf count, without redundant calculation;
  • Do that in a way that makes sorting by depth and then leaf count trivial;
    and
  • Address your concern regarding rtables.

Thus:

DepthAndLeafCount:= E->
local e:= `if`(E::rtable, convert(E, list, 'nested'), E), r:= [op](e); 
    1 +~ `if`(e::atomic or r = [e], [0$2], ([max,add]@~curry~(op~, [1,2])@thisproc~)(r))
:

To sort a list of expressions in the specified manner:

sort(E, 'key'= DepthAndLeafCount)

@MaPal93 So, now that Tom has elaborated regarding fsolve, I'll elaborate regarding undefined, because I realize that my previous comment may have been a bit cryptic. Like many things in numerical analysis, fsolve is  an iterative process attempting to create a numeric sequence (or a sequence of numeric vectors) that converges in some sense (I suppose that you have at least enough basic topology knowledge to know precisely what convergence means). Now, I've learned over the years that despite our best efforts (e.g., using all the tricks that Tom has provided), there will always be some cases where fsolve doesn't converge. Indeed, I don't think that I've ever had a practical system of nonlinear equations with parameters and more than 50 sets of parameter instantiations where I could get fsolve to give an answer for all instantiations. So, whenever you get a non-answer from fsolve, whatever values that would've gone into your plots had it returned numeric values should be replaced by the keyword undefined.

@vv Okay, that's a reasonable objection. So, without using atomic, or even string or indeed any type not used in the original, you can still defensively program it to protect against both

  • any new types of basic data structures added to Maple in the future 
    and
  • any infinite recursion errors of the present kind

via

LC := proc(expr)
local ope;
    if expr::{numeric,name} or (ope:= [op](expr)) = [expr] then 1
    else add(map(thisproc, ope)) + 1
    end if
end proc;


If that condition is rephrased (just for mathematical readability, not for Maple coding) as
   [op(expr)] <> [expr] implies expr::{numeric, name},
then I think that you can see that it's essentially close to atomic although not exactly the same as atomic, which by Maple's definition is map('f', expr) = 'f'(expr).

I am adding this (formally, without directly amending) to my Answer:

My Answer's title, "Not intended for strings", is not quite correct; perhaps it should be "Can't work for strings". Indeed, the programmer's intention (as much as can be discerned) was likely that it work for any input expression. However, due to the obvious bug (if you read the recursive procedure), it gets stuck in an infinite recursion if its input can't be ultimately decomposed into numbers and names by repeated application of op. In other words, the only "leaves" that it'll accept on the expression's "tree" are numbers and names. This would perhaps be reasonable if the intention were only to process algebraic expressions all of whose subexpressions are also algebraic.

First 50 51 52 53 54 55 56 Last Page 52 of 709