Carl Love

Carl Love

24688 Reputation

25 Badges

10 years, 59 days
Natick, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@PhearunSeng Like this:

eqs:= ...exactly what you had...;
V:= indets(eqs, specindex(W)); #decision variables
Wsol:= solve(eqs, V);

@PhearunSeng Assign the output of LinearSolve to a variable, say sol:

sol:= <W>=~ LA:-LinearSolve(LA:-GenerateMatrix(eqs, [W]));

Then make the last command

eval[recurse]([W], [InputW[], seq(sol)])[];

 

@Oliveira Note that what you're calling a "path" is usually called a Hamiltonian circuit or Hamiltonian cycle.

@Manuparis The instructions that I gave pertain to an existing Maple 2-D plot of curves. That's what I thought you were asking about. But now I understand that you want to "digitize" an existing image from an external source. 

What is the file format of the image? Maple's ImageTools package might be able to help with that, but I suspect that some other software would be better for putting the graphic into numeric form.

I converted your Post into a Question. Please put questions in the Question section.

@acer A variation of your Answer having the benefit of avoiding an -> is

evalindets(x, specfunc(exp), eval, omega1= omega2);

Here are some Answers to your Q2 and Q3. You asked:

  • Q2:-  What is a good way to handle different numbers of inputs to procedures (exported) here eg Proc1(a), Proc2(a,b), ....,                   ProcN(a1,...,aN)

Hmm, I don't see those procedures, nor does the given module have any exports. Perhaps this module is intended to be part of a larger module that you didn't post? Anyway, notice the change that I made to your two-parameter procedure in the overload. I changed its header from proc(A, B) to proc(A::_T2L, B::_T3L, $). That means that overload will reject that procedure and move onto the next one if the number of passed arguments is more than 2. If you use $, it must be at the end of the parameters.

  • Q3:-    Would the package exports of the module be the procedures inside the Mydispatch? Or does all of MyModule sit inside the  package module?

MyModule does not have any exports; its only interaction with the outside world is through its ModuleApply. At the moment (not seeing the overall package), I see no reason to put the code of MyModule inside another module. But you can call it from any other module, or, indeed, from anywhere at all.

Since the final polynomial obtained by @acer compares favorably under various metrics to the one produced by you by hand, produced by me by hand, and produced by codegen:-optimize(..., tryhard) (which are all the same polynomial except for slight differences in the order that the variables appear), one may wonder why optimize didn't return it. There are various metrics in use in this thread. I'd guess that the two primary ones actually used for optimization (rather than just being measured for curiosity) are 

  • Length: essentially order isomorphic to the number of characters in a displayed form of the polynomial. Good and essentially order-isomorphic approximations to this can be obtained by the commands length (built-in and extremely fast) and `simplify/size/size`, used by the important optimizing command simplify(..., size). The exact number of characters is returned by (length@String), which could also be used as a metric, but isn't used by any of the methods discussed so far in this thread. 
     
  • Operation count (which I'll abbreviate as opcount): A count of the number of basic computational operations (mostly arithmetic and assignment) that are needed to evaluate the expression to a (one-word) number when the variables are given (one-word) numeric values. This is the metric more closely related to computational efficiency and the one used by codegen:-optimize(..., tryhard). It allows for the use of intermediary variables (used for repeated subexpressions). This metric can be obtained (exactly) by codegen:-cost.

You may have noticed from my Answer that I used these steps:

  1. Extract the variables from the expression ex by using indets;
  2. Convert ex to a procedure by using unapply;
  3. Put that procedure through optimize, which returns a new-and-improved procedure;
  4. Apply that new procedure to the original symbolic (i.e., non-numeric) variables.

I used step 4 in case you were truly interested in the displayed length of the expression; however, for those interested in computational efficiency (as measured by opcount), step 4 is a very bad idea. Here is (essentially) the optimized procedure returned by optimize. Since it uses meaningless names for the intermediary variables, I changed them to meaningful ones; and I used modern sleek syntax (which requires 1D input):

new_ex:= (G1, G2, G3, G4, G5, G6, G7, G8, P2, P3, P5, P6)->
local G458:= G4 + G5 + G8,  G34578:= G3 + G458 + G7;
    G34578*P2 + (G1 + G34578)*P5 + (P3 + P6)*(G1 + G2 + G458 + G6)
:

You can easily obtain the opcount by eye---11 additions, 2 multiplications, 2 assignments, 2 (local) storage---which is also what codegen:-cost(new_ex) will say. This is significantly better than if step 4 is used, that result having 17 additions and 3 multiplications.

@666 jvbasha A negative number raised to a fractional or "decimal" power is always nonreal. I don't know if the derivative that you raise to the power n-1 is ever negative, but if it is, there will be a problem. I doubt that Maple's numeric PDE solver could be made to work with nonreal values.  

@Kitonum Sorry, I meant to say that it needed to be changed for n=2.

@Kitonum Given that r = sin(n*theta) is specifically used in the Question's title, I did not intend for the parameter n to represent the number of petals, only for it to have the same parity as the number of petals. Your procedure needs to be changed for n=1.

I immediately see several things that can likely be made more efficient. But before I go too far with that, please supply some suitable arguments to call the procedure so that I can test my ideas. In other words, for the call 

mcmcBinomialBeta(a, b, n, k, init, N, burn, thin)

what should I use for the values of a, b, n, k, init, N, burn, and thin

Also, will "hardware floats" a.k.a. "double precision" (64-bit floats) be sufficiently high precision for you?

@smithss Your previous Question was about a Maple program that you wrote that defines an external process to read a specific email you may have received (or report that it hasn't received). I think that that would be more easily done with the ssystem command shown by @nm. For example, I've used it within Maple programs so that they would email me debugging-related information about the program execution. 

@ecterrab Okay, Edgardo, after discussing with the OP (shown below), I think that there is an issue. It might not be formally called a bug, but it's a serious issue. So I encourage you to file that report. The anomaly is fully described by the first and last paragraphs of help page ?local_scopes. But, see, that was Maple 2019, and it hasn't been fixed yet. There are a huge number of these 1D - 2D divergences due to syntax enhancements, going back to Maple 2017 (and maybe earlier). They're all duly noted on their respective help pages (usually at the bottom), but then seemingly forgotten by the GUI developers. 

@bstuan The path need not be a straight line. I just woke up, so I haven't tested these yet, but my first guess is g1 = 0 and g2 = x-> x^(2/3) with the limits being and 1/2. Let me know how it goes.

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