Robert Israel

6567 Reputation

21 Badges

18 years, 83 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are answers submitted by Robert Israel

Especially when you're having trouble, it's a good idea to use ";" rather than ":" so you see the results.
The result of your solve command is a set of equations such as (for x=0)

or a sequence of several such sets if there is more than one solution, e.g. (for x=1)

Notice that these results contain a variable
even though you assigned

The problem here is that θ1dot (which I suspect you entered using the palettes) is not the same thing as theta1dot (which I guess you typed): lprint shows that θ1dot is actually  `θ1dot`.  Either use the typed version or the palette version, but don't mix and match.

Next, presumably you want to save the r3 value in r3a[x+1].  But the solve command doesn't assign a value to variables (and you wouldn't want it to, because then they wouldn't be available as symbolic variables for the next iteration), so it makes no sense to write
r3a[x+1]:= r3; that just uses the symbolic variable r3, not the result of solve.  Instead (considering that there may be two results and you just want the positive one) you can do something like this:

s:= [solve({eq1, eq2, eq3, eq4}, {theta2, theta2dot, r3, r3dot})];
r3results:= select(type, map(subs, s, r3), positive);
if nops(r3results) <> 1 then
  error "Obtained %1 positive results, not one", nops(r3results)
end if:
r3a[x+1]:= op(r3results);

 

I presume you are using the plottools and plots packages.
So a is a "point" that could be displayed in a plot. (Actually the thickness=6 doesn't do anything: if you want something visible you might try

a:= point([1,0,0], color=red, symbol=solidcircle, symbolsize=6);

You can rotate this about some axis by some angle, obtaining another "point", e.g.

rotate(a,1,[[0,0,0],[1,2,3]]);

You could animate this rotation.  Actually animate wants a plot structure, not just a component of a plot structure, so you could try e.g.

c:=animate(rotate, [display(a), Pi, [[0,0,0], [1,2,cos(t)]]], t = 0 .. 2*Pi);

I'm not sure what you're trying to do with op in the next command.  Do you mean you want the x, y and z coordinates of the points that are plotted in this animate command?  You can do something like this:

L:= map(curry(op,[1,1]),convert(op(1,c),list));

cx, cy, cz:= seq(map2(op,i,L), i=1..3);

If you had a curve rather than an animation, it would be somewhat easier: you could use the getdata command.

You declared s as a local variable of U, while Parameters2 refers to the global variable s.  These are not the same, and you shouldn't expect them to be the same.   So evaluating U(c) with the global s=1 will not affect the result. 

On the other hand, if you made s a global variable the situation becomes more subtle, and the sequence in which evaluation takes place becomes important.  In this case what actually happens is that the procedure U is called first, and then the result of that is evaluated with s=1.

One way that almost works is to substitute into the function definition rather than the result of the function call.

> Parameters2 := [ s = 1 ];
   Functions2 := [ U = proc(c) if s = 1 then log(c) else  (c^(1-s)-1)/(1-s)  end if end proc ];
  eval(U(c),subs(Parameters2,Functions2));

Error, numeric exception: division by zero

The problem here is that when s=1 the (c^(1-s)-1)/(1-s) contains a division by 0 (even though that branch is not going to be taken, this causes a problem in trying to define the substituted procedure).  A work-around is to rewrite it so that we don't have an "immediate" division by 0.

> Parameters2 := [ s = 1 ];
   Functions2 := [ U = proc(c) local one; 
           if s = 1 then log(c) else one:= 1; (c^(1-s)-1)/(one-s)  end if end proc ];
   eval(U(c),subs(Parameters2,Functions2));

1) I think you want v to be a function of z and t, not s and t.

2) IBCU and IBCV are lists, so to combine them you want IBC:= [op(IBCU), op(IBCV)].

3) Now the error message is

Error, (in pdsolve/numeric/process_IBCs) initial/boundary conditions can only contain derivatives which are normal to the boundary, got (D[2](u))(1000, t)

Thus for a boundary condition at z=1000 you can have something depending on u(1000,t) and D[1](u)(1000,t), but not D[2](u)(1000,t).

It's not clear to me just what you mean by joining the curves.  Do you mean you want line segments from the end of the first to the start of the second, and from the end of the second to the start of the third?  Something like this?

> plot([[cos(t),sin(t), t=0 .. Pi/3],
           [cos(t),sin(t), t=2*Pi/3 .. Pi],
           [cos(t),sin(t), t=4*Pi/3 .. 5*Pi/3]]);
   P1:= %:

> C:= select(type,P1,specfunc(anything,CURVES));
   PLOT(subsop(1=[seq(op(op([i,1],C)),i=1..3)],op(1,C)),op(4..-1,P1));

 

It's not so hard.  Here is my worksheet that gets an optimal solution quite quickly.

cutstock.mw

Note that you might be able to reverse the effect of the delete using Undo from the Edit menu (or Ctrl-Z, at least under Windows).

A quick Google search yields several free utilities that claim to convert .wav files to .mp3 format. 

The screen was cleared?  Do you mean you're using the command-line interface?  I would strongly recommend not doing any significant programming on the command line.  You can edit an input file in your favourite editor and read it in to Maple using the read command.

It is possible to use subs in a procedure body with expressions that don't contain local variables or formal parameters, but I don't think you can use it with expressions that do.  You might use ToInert and FromInert, but finding the exact expression to substitute in a large procedure might not be so easy.  

As Markiyan remarked, there is indeed an error in the definition of restante: presumably you left something out after the "-".  But that's not relevant to the other error. 
I'm not quite sure what you're trying to do here.   qd has been defined as a vector whose components are expressions:

But then you try to use qd(1) and qd(2) as functions, e.g.

What is the t supposed to do here?

 

You can indeed make changes to Maple's commands.  Of course this is at your own risk - there may be a danger that this could break something else that calls the same procedure.  But something like the following should be reasonably safe:

> unprotect(ArrayTools[RandomArray]);
   ArrayTools[RandomArray]:= subs(Normal(0,1) = Normal(mu,sigma),
      eval(ArrayTools[RandomArray]));
   protect(ArrayTools[RandomArray]);

(and then assign numerical values to mu and sigma before calling ArrayTools[RandomArray])

If pointplot is returning unevaluated, your line

with(plots);

must somehow not have been executed. 

You did not include a worksheet file.  All you have in your message is a link to an html file that refers to another file 10171.html, which we can't see because it doesn't exist on our machines.

First of all, note that there are two quite different i's in your expression: one is the index variable for the sum, and the other is the index of the variable with respect to which you are differentiating.  This is a bad idea, as it's not clear which i is which.  It would have been better to use a different name, say j, for the index in the sum.  Unfortunately

diff(sum((1/2)*q[j], j=1..n), q[i]);

also doesn't work.  The problem here is that there is literally no "q[i]" in the expression.  diffisn't smart enough to realize that (if i is a positive integer

diff(sum((1/2)*q[j], j=1..n), q[1]) assuming n::posint;

doesn't work.  As a matter of fact, although a person can easily see what the right answer ought to be in this case, it's not hard to construct slightly more complicated examples where things are not so obvious.  Consider

diff(sum(sum(q[i^3 + j^3], i=1..n), j=1..n), q[k^3]) assuming k::posint, n::posint, n > k;

The answer is 0, but only because the sum of two cubes is never a cube (a special case of Fermat's Last Theorem).

More precisely, using (as Maple does) the principal branch of the logarithm (i.e. the imaginary part of ln(z) is in the interval (-Pi, Pi]), we have ln(exp(z)) = z if and only if -Pi < Im(z)<=Pi.  The correct identity is ln(exp(z)) = z + 2*Pi*I*n where n = floor(1/2 - Im(z)/(2*Pi)).

4 5 6 7 8 9 10 Last Page 6 of 138