Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You should be able to search through the whole folder with the standard Windows File Explorer.

I could easily (oh, say, 3 lines of Maple code) write for you an operator constructor such that P(2,1) would be an operator that switches the 1st and 2nd operands of its argument, the X(...), which needn't be specified until time-of-use. You'd be able to replace (2,1) with any permutation on any finite number of symbols using any of the standard list-of-(lists-of)-distinct-small-positive-integers syntaxes that are commonly used for permutations. The easiest-for-me-to-program end-use syntaxes could be either

  1. P(2,1, ...)(X(i, j, k, ...)), or
  2. P(2,1, ...) &* X(i, j, k, ...),

where I've used ... to indicate that there'd be no limits on the number of arguments, and &* could be replaced with nearly any operator symbol, provided it begins with &. In either case, the P(2, 1, ...can be preconstructed (independently of X) and assigned to a variable.

It'd also be possible to use the standard multiplication operator *, but it's significantly more work (rough estimate: 40 lines of code) to overload existing operators, especially when they're commutative and associative and already have default meaning for the given expressions.

So, would something from the 1st paragraph be sufficient for your purpose?

There is some bug with your Maple 2015 GUI display such that the prettyprinted GUI display (only) of the 2nd set in your list is not shown in the order that the set is actually stored. That bug has since been corrected. Once you realize that the bug is in the way that the 2nd set is prettyprinted, everything else you show is consistent. And, as you realize, the way to "see around" such prettyprinting bugs is to use lprint.

Regarding the set order: For some strange reason, Maple's set order places the 2nd derivative of g before the 1st, yet the 1st derivative of Theta before the 2nd (in both Maple 2015 and 2022). By "set order", I mean the order in which the elements are actually stored, regardless of display. This order can't be controlled.

Once a set is stored in a Maple session, its order will never change. I think that Tom's Answer may give the impression that it may change, but that's absolutely false.

The basic command to get numeric values is evalf. In this case, you can replace solve with fsolve or with (evalf@[solve]). The fsolve will return both roots because the equation is polynomial. The other method will work more generally, but requires that the equation can be symbolically solved (which, of course, is true in this case).

Unfortunately, the direction angles are measured in degrees.

Use e:= exp(1) somewhere in your code, preferably early. Otherwise, e is just an unassigned variable.

The generalized problem can be solved like this:

restart:
s:= {"a", "b", "c", "d", "e", "f"}:
B:= [3,3]: L:= ListTools:-PartialSums([0,B[]]): m:= nops(B):
{seq}(
    {seq}(s[[seq](j[1+L[k]..L[k+1]])], k= 1..m), 
    j= Iterator:-SetPartitionFixedSize(B)
); 
             {{{"a", "b", "c"}, {"d", "e", "f"}}, 
               {{"a", "b", "d"}, {"c", "e", "f"}}, 
               {{"a", "b", "e"}, {"c", "d", "f"}}, 
               {{"a", "b", "f"}, {"c", "d", "e"}}, 
               {{"a", "c", "d"}, {"b", "e", "f"}}, 
               {{"a", "c", "e"}, {"b", "d", "f"}}, 
               {{"a", "c", "f"}, {"b", "d", "e"}}, 
               {{"a", "d", "e"}, {"b", "c", "f"}}, 
               {{"a", "d", "f"}, {"b", "c", "e"}}, 
               {{"a", "e", "f"}, {"b", "c", "d"}}}

 

The names that you use for the coordinate variables (such as rthetaphi) are irrelevant; you can use any names. The important thing is to use coords= spherical

You should use the command CodeTools:-Test.

One, and perhaps both, of your procedures contains indirect references to the parameters NN and MM. A procedure created with proc or -> cannot use indirect references to its parameters. Such procedures should be created with unapply instead:

cstr8:= unapply(G1 - FS, [NN, MM]);

You might need to do this with ATS also. From what you posted, I can't tell whether it has indirect references.

It can be done like this:

C:= <
    1, -0.5, 0.125, -2.449863383, 4.256426329, -1.826788463, 1.38888888e-3, 
    1.984126984e-4, 2.48015873e-5, 2.292633427e-4, -3.43791062e-5, -6.80212248e-5,
    4.06878271e-5, -5.03107054e-5, 3.795993196e-5, -1.28793671e-5, 1.752215748e-6,
    -5.518698119e-12
>:
Y:= unapply(C^%T.x^~<seq(0..17)>, x):
Y~([seq](0.0..1.0, 0.1));
 [1., 0.9492075127, 0.8916268943, 0.8251427077, 0.7534730280, 
   0.6839803183, 0.6254839642, 0.5860748693, 0.5709325210, 
   0.5801448253, 0.6065306590]

Of course, that doesn't match any column of the tables that you showed. No more can be said about that without seeing the original problem.

There are several possible interpretations of your problem. You said "a bunch of (x,y) coordinates". The first distinction that must be made is whether "a bunch" is 4 or more than 4. Possibly a second distinction must be made between one degree-3 polynomial or multiple degree-3 polynomials. All of these situations can be handled by 1 or 2 short Maple commands.

The interpretations:

1. You have exactly 4 points. This is the situation hinted at by Rouben's Answer. There is a unique polynomial of degree at most three that passes exactly through those points. The polynomial's coefficients can be determined by the process outlined by Rouben, or you can simply use the Maple command CurveFitting:-PolynomialInterpolation.

2. You have more than 4 points, but you know that you want a single degree-3 polynomial that goes through them all. This can't necessarily be done, but you can easily check whether it can. If it can be done, any subset of 4 of the points will give the same result (allowing some reasonable bounds for round-off error). Pick any 4, apply case 1, and see if the rest of the points fit.

3. You have more than 4 points, and you want the degree-3 polynomial that "best fits" all of them. The polynomial will not necessarily go exactly through any of the points; indeed, it's likely to not go through any exactly. This is called linear regression; the Maple command is Statistics:-LinearFit.

4. You have more than 4 points, and you want a smooth piecewise curve that goes exactly through them such that each "piece" is a polynomial of degree at most 3. This is called cubic spline interpolation; the Maple command is CurveFitting:-Spline.

Like this:

plots:-display([entries(IP)])

Edit: As pointed out by @mmcdara below, the above should be

plots:-display([entries(IP, nolist)])

Yes, the death of a kernel process due to a simple command with bad syntax is certainly a serious/critical bug. Since your printf command is syntactically nonsense, you should get a simple error message informing you of that.

I am writing this Answer to address your overall, titular Question, which is essentially about generalizing f@@n to situations where f takes many arguments and those arguments are changing for each application of f. Such generalizations are called folding f. You may read about it on help page ?fold; however, in this particular case I'm not going to use the commands foldr or foldl documented on that page but rather a new option to seq that does essentially the same thing more efficiently.

I am not writing this Answer because I think that folding is the best way to implement the particular situation that you present---the Answers by Kitonum and especially Acer have better methods for that situation. Nonetheless, your main Question is essentially about folding.

L:= "[(0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7),"
    " (7, 8), (8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14),"
    " (14, 15), (15, 16)]"
:
#L1 and L2 could be lists, but simple strings are enough in this case:   
L1:= "()[]": L2:= "{}{}":
X:= seq['fold'= (StringTools:-SubstituteAll, L)]('L1[i], L2[i]', i= 1..length(L1)); 
X := "{{0, 1}, {1, 2}, {1, 10}, {2, 3}, {3, 4}, {4, 5}, {4, 9}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {10, 11}, {11, 12}, {11, 16}, {12, 13}, {13, 14}, {14, 15}, {15, 16}}"

This is more efficient than foldr or foldl because seq (ironically) does not create any sequence when used like this; it just feeds arguments to the accumulator procedure SubstituteAll. In contrast, using foldr or foldl requires first constructing the entire sequence of arguments before calling the command. 

First 30 31 32 33 34 35 36 Last Page 32 of 395