Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@djmotion Your usage Y(s) := 100/s is a bit strange in that it can be interpreted in two ways.  Presumably you are using 2D math input, so Y is assigned the function s -> 100/s.  However, when using Maple input, this assigns to the remember table of the otherwise undefined procedure Y.  So Y(s) will return 100/s, but Y(t) will return Y(t). That's probably not what you want.  I'd avoid the issue by using the arrow notation to assign the procedure,  Y := s -> 100/s.   The same issue exists with X2(s) and x2(t). For x2(t) you certainly want to use x2 := unapply(...).  Modify the references to x2 to omit the unneeded t argument.

@Ramakrishnan As acer pointed out, ChangeE must be an export, not a local, to the module. The other issue, minor in comparison, is that a radio button really isn't the right component type for a single press button.  It will work, but looks wrong and doesn't make sense (it always appears to be selected). Radio buttons are used to select one of several options.  Replace it with a regular button. It would also be a good idea to label your components, either by adding external text or a label component.  Doing so makes it easier on the user and helps with the debugging. 

@Carl Love By way of explanation, the call to sort with the 'output = permutation' option returns a permutation of the indices of the list.  That permutation is then applied to S by using S[ permutation_of_indices ].  For example

[a,b,c][[1,3,2]];
    [a,c,b]

Note that using a list of indices as the index to a list is a rather general operation that has other uses. It isn't restricted to being a permutation.

[a,b,c][[2,2,1,3,3]];
             [b, b, a, c, c]

@vv For this application you are probably correct.  There is a difference in that your method produces the Matrix directly, while with Carl's method an existing Matrix is modified (this may not be clear to the beginner in that Carl wrote a one-liner). The choice may then depend on whether one is producing a new matrix or modifying a given matrix.

@Carl Love This makes me think that 

V := Vector([a,b,c]):
apply(V,t);

should produce a Vector of function calls of t, rather than raising the error, unsupported type of index, t. I can understand why the error is raised in that apply(f,t) is equivalent to f(t) and, with the introduction of programming indices (quite a few releases ago) f(t), with f an rtable, is interpreted as an indexing operation. However, given that apply is supposed to create functions (function calls), it makes more sense to distribute the application over the content of the rtable.

As a counterexample to the current operation, consider

L := [[f,g],<f,g>]:
apply(L,1);
        [[f(1),g(1)], f]

I doubt anyone would ever want that.

@dharr That isn't clear to me; at best I'd say the help page is confusing.  For an rtable, the number of elements seq returns equals the rectangular size of the rtable, regardless the actual storage.

@tomleslie Because the desired result, apparently, is merely a side-effect (printed output), I'd probably want to use a for loop rather than a sequence; no sense producing any real Maple expressions if they won't be used.  The annoying part is handling the last term so there is no dangling comma.  With that in mind, it might be simpler to do 

printf("%Q\n", seq(sprintf("op(S[%d])", i), i=1..5)):

Alternatively, and shorter

printf("%q\n", seq('op'('S'[i]), i=1..5)):

@tomleslie The error comes from a call to iratrecon with the fourth argument, D, equal to zero, which is not valid.  Haven't looked at why that occurs.

@aaeerr The model you uploaded doesn't run here (System in underdetermined).  Regardless, one way to lock a rotational joint, but to allow it to be freely initialized, is to connect a constant speed source (1D Mechanical > Rotational > Speed Drivers > Constant Speed) with the velocity set to zero, to the b-flange of the joint.  Attached is an example using the Double Pendulum. LockedJoint.msim

What do you mean by lock links?  Prevent the rotational joint from turning?  If so, at what angle do you want it fixed?

@Kitonum Note that the empty-name wrapper function isn't needed around the k, just using the dot operator suffices. Actually that is kind of surprising; because the dot operator does Matrix/Vector products, I expected it to expand a scalar-Matrix product, but it does not. It will if the scalar is numeric.

@acer The special symbol _nparams is rarely used in Maple code.  A quick search of the Maple archive maple.mla indicates it isn't used at all, for any practical application.  It is used in some conversions to/from inert procedures, but that is only to handle it's (non)occurrence in code being transformed.  Curiously, since you mentioned it is not specific to the debugger, the one place where I have used it, and found it invaluable, is in code that is used in the Emacs/Maple debugger to better display the arguments of a given procedure. In that application it is necessary to know how many of the arguments were declared, etc.

@bmartin Note that you can directly apply this permutation to the list to verify it:

(**) L := [8,1,7,12]:
(**) P := sort(L, `>`, output=permutation);
                                        P := [4, 1, 3, 2]

(**) L[P];
                                     [12, 8, 7, 1]

@vv Thanks.  That's a better approach; I've incorporated it into the worksheet.  Note that the peak of that curve is where the target rating matches your rating (but not your strength).

@vv Am not sure.  I suspect there are multiple solutions and fsolve is picking the wrong one, at times.  Restricting the range to r1 .. 1700 should help, but the call to fsolve is returning unevaluted for r1 > 1673.

Followup: Here's a fix that better limits the solution space

Ept := Glicko:-ExpectedDelta(1700, r1, r2):
dEpt := diff(Ept,r2):
r2vsr1 := r -> fsolve(eval(dEpt,r1=r), r2, r/2..1700):
plot(r2vsr1, 1000..1700, 'numpoints' = 30);

I updated the worksheet to use this code, but otherwise left the post alone

First 20 21 22 23 24 25 26 Last Page 22 of 195