Joe Riel

9530 Reputation

23 Badges

20 years, 29 days

MaplePrimes Activity


These are answers submitted by Joe Riel

How 'bout plotting a mold for it:

cylx := y^2+z^2-1:
cyly := z^2+x^2-1:
cylz := x^2+y^2-1:

expr := cylx*cyly*cylz;
plots:-implicitplot3d(expr, x=-1..1, y=-1..1, z=-1..1, numpoints=10\000);

A minimal example that demonstrates the problem would be helpful.

The problem is that you are attempting to assign to a parameter. That generally is not allowed in Maple.  What do you hope to accomplish with this procedure?  If you merely want to assign to the global variable x, then you could do

testproc(x0,y0)
global x;
    x := y0;
end proc:

 

While you could use ?assigned to determine whether a name is assigned, you might be better off using ?PolynomialTools[CoefficientList] and directly combining multiple calls.  Say

polys := { a2*x^2 + a1, b2*x^2+b1, c1*x }:
eqs := {seq(PolynomialTools:-CoefficientList(p,x)[], p in polys)};

You can use ?expand to handle this.  However, calling expand directly does not do what you want:

y := cos(2*x+(Pi/6)):
expand(y);
                                      1/2
                       1/2       2   3
                      3    cos(x)  - ---- - sin(x) cos(x)
                                      2

The problem is that expand was too aggressive.  To dampen its enthusiasm, you can pass it optional arguments that tell it what not to expand:

expand(y, 2*x);
                                     1/2
                       1/2 cos(2 x) 3    - 1/2 sin(2 x)

The reason sum does not work here is that the expression being summed, specifically the derivative, is evaluated before the index has been assigned a value.  You could use sum, though add is the better choice, if you delay the evaluation of the diff function.  That can be achieved with forward quotes:

sum('diff'(f, B[j])^2, j = 1 .. 2);
                                     2    2
                                    b  + a

If the signal is in degrees, then divide by 0.3, use the Real-To-Integer block, then scale the output by 0.3.  Generally an angle will be in radians, so you will want to adjust the scale factors accordingly.

By assigning a neutral operator for the ?apply procedure, Maple 13's tilde can be used to separately process expression sequences, which are then recombined with a multiplication:

expr := -(1/12)*(-g*vb-g+z*g-g^(2/3)*z+g^(2/3)*vb)*(g^(1/3)+1)^5/g^(2/3):
`&apply` := apply:
`*`((expand, x->x) &apply~ selectremove(has, expr, {2/3,-2/3}));
                (1/3)       (1/3)    (1/3)               (1/3)     5
             (-g      vb - g      + g      z - z + vb) (g      + 1)
           - -------------------------------------------------------
                                       12

Using ?ArrayTools[IsEqual] avoids creating the intermediate array.

There is no need for the inner seq here, instead you can use the optional third argument to ?seq to have it step by 2:

L := [seq(1..12)]:
[seq([L[i..i+1], i=1..nops(L), 2)];
              [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]

While it presumably isn't what your instructor wants, the ?ListTools[LengthSplit] command can do most of the work:

[ListTools:-LengthSplit(L,2)];
               [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]

Do you want to simulate the game, that is, use a monte-carlo approach?  Or analyze it? 

What strategy maximizes the expected score of a turn?  This is a straight-forward, simple computation.

Here's are some possibly interesting variants:

  1. Two players each take one turn.  The player with the higher score after that turn is the winner.  Neither player knows the others score until the end.  Is there an optimal strategy? 
  2. Same as 1, but this time player 2 knows player 1's score.  What is player 1's optimal strategy? 

The do-loop as formulated is O(nops(a)^2) because it generates n versions of a list of n-elements.

 

One way is to terminate them with colons, see ?separators.

I didn't realize that there was a difference in evaluation using programmer indexing (see ?rtable_indexing); probably that is a bug. Change gradV(1,1) to gradV[1,1].  Note that the backquotes used around distributed do nothing; they should be forward quotes to delay evalution.

Use seq to create the list:

L := [seq(1..5)]:

You could use a for loop to print them

for item in L do
    print(item);
end do:

Simpler is to map print over the list (here I use lprint):

map(lprint, L):

In Maple13 I do

lprint~(L):
First 78 79 80 81 82 83 84 Last Page 80 of 114