Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@tomleslie I think that it's the duty of a responsible Answer Giver to warn that using cat like this creates global names, regardless of the status of the originals. But, also, a responsible OP should read the help pages of the commands recommended in an Answer.

@brian bovril To me, it was clear from the start that you wanted to index the names, not create new symbols, but I see how your meaning could've possibly been misinterpreted.

@Joe Riel Easier to find is the library function index`?[]`(N, J) is equivalent to index(N, J[]) (even if J is the empty list).

@Joe Riel Yes, and the 43 capitalized semi-inert functions described at ?mod, plus &^, are implemented in Maple as `mod/...`.

Did you see my Reply to your Answer of my thismodule Question?

This is called the inverse image or preimage problem (the two terms mean the same thing). It can be extremely difficult to get even an approximate solution when there are continuous variables and the domain has more dimensions than the codomain, as in your case. But it's a very important problem with applications in 3D imaging, for example, How does one construct a 3D model of an object from a series of its 2D projections?. (Most of our brains manage this computation in real time---we don't quite know how.) The example that you've given is significantly simpler with a 1D codomain and real-interval range/projection.

I notice that your f is quadratic. Is it always so? It'll be easier to get a solution for that case.

@Carl Love If one changes the module as I suggest above, then it becomes useful for it to export a procedure for evaluation of expressions wrt the record params. This is quite simple: Declare a local (preferably immediately after the Record's declaration):

Params:= [exports(params)],

and declare an export Eval (or other appropriate name):

Eval:= e-> eval(e, Params=~ map2(index, params, Params)).

Although the above is easy to code, it's mind-boggling to me why evaluation wrt a module or record is not part of the regular eval command. It seems like such a fundamental operation. The use command is not an adequate substitute because it only works at the top level (i.e., on a command line).

@Carl Love It should be noted that when a single subsop command is used with multiple indices (as in this case), and some of the substitutions cause the target object's operand numbers (aka indices) to change (as in this case, where NULL is being substituted into a list), then the indices are all specified as their original values (i.e., the values that pertained at that start of the command). Since this is the more-convenient way to do it, and the way the you were doing it anyway, I didn't mention it earlier. However, some Maple commands do similar operations recursively or have modes for both recursive and non-recursive operation (such as subs and eval).

@gal By "I can't reproduce your situation", I mean that if I copy your code into my Maple, then I get what we both expect: the output from the print statement. So, there must be something going on that is too subtle to be revealed by your plaintext transcription of your code. Hence, we need to see a worksheet. This is often the case with errors arising from 2D Input.

@becejac You have an older version of Maple. Please put your Maple version in your Question headers using the pull-down menu provided for that purpose, because I hate having to retrofit answers that I could've written correctly the first time.

The retrofit is

`*`(map(`+`@op, combinat:-choose([x||(1..n)], k))[]) = 0;

Your Question either has typos that I can't disambiguate[*1] or is missing crucial details. Please post the worksheet.

This is a Question, not a Post, so I moved it.

Your title is somewhat offensive because it implies that it's the writers of Maple rather than you who has done something wrong. You should change it to "I don't understand why subs does this."

[*1]Such as: Is eh a variable, or does it represent a product e*h? Is com2 the function (aka procedure) or is it simply a part of the output of a function whose name you didn't tell us? Is com2(e,e,f)=eh+he supposedly the definition of function com2? If it is, it can't work because = is not the assignment operator :=.

@Joe Riel After much thought, I decided that your way was indeed better than what I had (and I promoted your Reply to an Answer and gave it a Thumbs Up). Then, after 20 or so rewrites of it, I got my answer to Question 3 as well! It happens that this didn't require thismodule. Here it is:

KandR:= module()
local
   params:= Record(a::algebraic, b::algebraic, c::algebraic, e::algebraic),

   #procedure that lets user set parameter values:
   ModuleApply:= proc()
   local A, savAL:= kernelopts('assertlevel'= 2); 
      for A in args do 
         if A::({'symbol','string'}='anything') then params[""||(lhs(A))]:= rhs(A) fi
      od;  
      kernelopts('assertlevel'= savAL);
      return
   end proc
;
end module:

Unrelated note: Joe, I think that you'd be interested in my recent Post about Fisher's exact test because I used your recursive idea about generating contingency tables (from ?Iterator,BoundedComposition). My algorithm requires the product of the factorials of the entries, not just a count. Your Iterators are amazingly fast! I did a 3x3, n=1000, example requiring 45 million tables in 12 minutes, and a 2x3, n=75, example requiring 295 tables in 50 milliseconds. In this era of mathematical software packages, many statisticians recommend that an exact test be used whenever n < 1000.

@BaptisteK Here's some code for it:

f:= (R,L)-> Pi*R^2*L:
g:= (R,L)-> 2*Pi*R*(L+R):
A:= solve({g(R,L)=1}, {L});
plots:-spacecurve(eval([R,L,f(R,L)], A), R= 1..10);

We can't start at R=0 because has a factor of R in the denominator.

You'll need to show an example of it not producing printout.

@brian bovril With the same initial error: error (in ModuleApply) index must evaluate to a name when indexing a module? Sorry, but I have no way of testing this; I'll need your help to debug it.

I don't have an idea yet how to do it, and this wouldn't make it any easier or harder, but I noticed that your code doesn't use the d3 that you defined. So, do you need to change the plot to include d3?

First 297 298 299 300 301 302 303 Last Page 299 of 709