Joe Riel

9530 Reputation

23 Badges

20 years, 26 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Change S to SR in the call to NLPSolve.

In the code you posted, the variable dur is not assigned, so the call to maximize returns unevaluated.  Also, in the call to plot, you need to prevent maxpoint from evaluating prematurely, that is, with a symbolic value.  One way to do that is with

plot( maxpoint, 0..2, sample=[0,1,2], adaptive=false):

Alternatively, you could right-click on the structure and select Browse.  That lets you check the content, but won't continually display it.

Note that the recurrence is periodic.  You can determine the period with a slight modification:

a := 1: b := 1/sqrt(3):
for n do
    c := simplify((a + b)/(1-a*b)):
    if assigned(trio[a,b,c]) then break; end if;
    trio[a,b,c] := n;
    a := b;
    b := c;
od:
n, trio[a,b,c];

It means Maple is attempting to store an expression that it cannot convert to a float, into an rtable (Matrix, Array, Vector) that is declared as datatype = float[8], meaning it can only store 8 byte hardware floats. For example,

V := Vector(3, datatype=float[8]):
V[1] := 3/4:  # this is okay because Maple will convert to a float
V[2] := sqrt(3):
Error, unable to store '3^(1/2)' when datatype=float[8]

Maple does not automatically convert roots of rationals to hardware floats when writing to such an rtable. In your case, the indexed name KroneckerDelta[1,2] is the issue.

@Christopher2222 I don't know what you mean.  Using PasswordField, in place of TextField, does exactly what you want. 

(**) theta := [seq(k*Pi/4,k=0..4)]; 
                                    Pi    Pi   3 Pi
                      theta := [0, ----, ----, ----, Pi]
                                    4     2     4

(**) P := [seq(2*k,k=0..4)];
                             P := [0, 2, 4, 6, 8]

You can use zip to multiply the sequences term by term

(**) zip(`*`,theta,P);
                               Pi         9 Pi
                          [0, ----, 2 Pi, ----, 8 Pi]
                               2           2

Another way is to use *~

(**) theta *~ P;
                               Pi         9 Pi
                          [0, ----, 2 Pi, ----, 8 Pi]
                               2           2

I'm guessing you did something like

x := fsolve(x^2+x,x);

and then attempted to use x in an expression.  However, since x is assigned an expression sequence of two numbers, that fails.

There are several ways around this one. One is to refer to just one of the solutions using index notation:

x[1];
         -1.
x[2];
          0.

Use sort( poly, x);

On the other hand, do you really want evalf(x^2) to return x^(2.00)?

While it is intended more for searching, you can use the mgrep tool with the -c option.

The transformations are different.  If you use

tr := {y(a) = a+1+1/u(a)}:

you get the same result

I didn't see the call to f in conscongs, but no matter.  The error message that Maple is raising is informative:

final value in for loop must be numeric or character.

In f, the final value of the for loop is the variable numccs. That variable is local to conscongs, so its value will be unknown to f. Actually, in the context of f, numccs is a global variable (because it wasn't declared), one that is different from the variable of the same name that is local to conscongs. You could declare numcss as a global variable inside of conscongs, however, that usually isn't the best way to go. 

To better understand this behavior, consider the following

proc()
local a,v;
global g;
    a := v;
    g := v;
    assume(v,positive);
    subs(v=1,[a,g,v]);
end proc();
                                   [v, 1, 1]

The substitution "works" for the global variable, g, but not the local variable, a. The reason for this is that global variables are fully evaluated, while local variables are not, they are evaluated only one level (cf. ?procedure). Because a is not fully evaluated, in the subs operation it evaluates to v, which is a different variable than v~. The v's in the call to subs evaluate to v~.

The same thing is happening with the substitution into a Vector (more generally, an ?rtable) even though you are doing so at top-level (i.e. not inside a proceure).  For efficiency, the content of an rtable is not fully evaluated unless you force it to be.

 

Are you sure it is the call to A:-Simulate() that is leaving the file handles open?  I haven't been able to reproduce that behavior.  However, repeated calls to MapleSim:-LinkModel() does create more open file handles.  I'll submit this as an SCR.

First 43 44 45 46 47 48 49 Last Page 45 of 114