Carl Love

Carl Love

28150 Reputation

25 Badges

13 years, 352 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@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 A 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?

@Ramakrishnan There are some differences between `if` and if:

  • `if` is a builtin procedure. It always takes exactly 3 arguments and (like any procedure) it always returns a value. It's name is in quotes because if is a reserved word. In the call `if`(BC, TV, FV), BC is a boolean condition: something that will evaluate to true or false. TV is the expression which will be evaluated and returned if BC is true; FV will be returned if BC is false. You may use ifelse in place of `if` in case you don't like quotes.
  •  if ... then ... is a statement. It may or may not return a value. It may or may not have an else clause.

Yes, you can make an assignment using `if` (or any other procedure call) before the call to SetProperty.

@brian bovril Odd. Do you have Maple 2018 initial release, or release 1? I have release 1, and the code still works for me. I thought that my use of thismodule with an abstract index was too good to be true! I'll post corrected code in a few minutes. 

And here it is: FoxesAndRabbits.mw

First 299 300 301 302 303 304 305 Last Page 301 of 711