Carl Love

Carl Love

26381 Reputation

25 Badges

11 years, 138 days
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity

These are answers submitted by Carl Love

It's MatrixInverse (with capital I), not Matrixinverse.

In addition to Kitonum's Answer, numpoints = 10 seems much too low. The system can easily handle 10,000points (100 x 100 grid).

It is much, much easier to just use ?Threads,Map or ?Threads,Seq rather than Task. Let Maple worry about how many pieces to break it into.

Putting it in simple English: You can't Continue what you didn't Start.

Your code doesn't work because you are trying to use the variables c, d, and e as both symbolics (variables without an assigned value) and as loop indices (the variables after for). You need to use different variables and then subs one for the other within the loop, like this:

N := [];
for _c in poss_for_v(1) do  
     for _d in poss_for_v(2) do  
          for _e in poss_for_v(3) do
               N := [op(N), subs([c= _c, d= _d, e= _e, M[6])]

(The code above is only meant to correct your primary problem and does not represent my opinion as to the best way to perform the operation. For the best way, see ?combinat,cartprod and store the results in a ?table , not a list, and ?convert,list the table to a list when the loop is finished.)

You can avoid the need (and expense) of a conditional evaluation at every loop iteration by using the in form of for. For the example at hand, the code would be

for i in $1..2, $4..8 do
end do;

It can be used symbolically. Here's an example:

point(X, a, b, c):
point(Y, d, e, f):
line(L, [X, Y]):
Equation(L, t);
         [a + (d - a) t, b + (e - b) t, c + (f - c) t]

You can extract the maximum function value from the original plot and use it to modify that plot like this:

f:= randpoly(x);
P:= plot(f, x= -10..10);
A:= op([1,1], P);  #The curve's point matrix
F:= A[.., 2];  #The function values
m:= max(F);
subsindets(P, Matrix, A-> < A[.., 1] | F /~ m >);

I do not get the warning in Maple 17.01/64 (Windows 8). I just get 10 solutions. What version of Maple are you using? I've attached my execution of your worksheet. So, if you got 10 solutions in your Maple, I guess that no solutions were actually lost.


If T is a table, then op(2, eval(T)) will return the list of equations "inside" T. With that knowledge, we can write a one-line procedure to merge any number of tables:

merge_tables:= ()->
     table(map((T::table)-> op(2, eval(T))[], [args]))

To apply it to your loop, you need to initialize T with T:= table():

sol[2] := [[2, 1], [3, 4]];
T:= table():
for i from 1 to nops(sol[2]) do
     sol[2][i] := [seq(op(k,sol[2][i]), k=nops(sol[2][i])..1, -1)];
     T:= merge_tables(
               seq(op(k,sol[2][i])=op(k-1,sol[2][i]), k=2..nops(sol[2][i])),

I must say though that this is a very inefficient process (O(n^2)), as is any iterative concatenation. I understand what you are trying to do is convert a permutation from disjoint cycle form (disjcyc) into table form. It is better to create one table as a "seq of seqs" rather than using concatenation. I do this in the procedure in the Reply below.

Note that the fixed points are not represented in disjcyc, so the converter needs to be told the highest number (since it may be a fixed point), which is called the degree of the permutation. You can default the degree to the highest number that appears in the disjcyc, which is what I do in the procedure below.

You are mixing up the assignment operator := with the equality operator =. The code sample that you gave could not possibly work like you said because the parser will immediatey reject a statement beginning if a:= with the message "Error, `:=` unexpected."

You can have any number of statements between the then and elif, else, or end if as long as they are separated with colons or semicolons.

if a = 3 then   # = not :=
     b:= 4;
     c:= 2032;
     h:= 7
elif a = 4 then
     b:= 5;  c:= 1003;  h:= 42
     b, c, h:= 7, 25, 62
end if;

After the else I've shown a multiple assignment statement.

I doubt that the Asker was looking for any solution with r^4 appearing on the right side.

I prefer to use eliminate over isolate when possible. It handles multiple solutions nicely.


eq1:= (r^2*sin(t)^2+r^2*cos(t)^2)^2 = a^2*(r^2*cos(t)^2-r^2*sin(t)^2):

eq2:= algsubs(r^2= R, eq1);

(sin(t)^2*R+cos(t)^2*R)^2 = a^2*(-sin(t)^2*R+cos(t)^2*R)

Regular subs would have worked in this very particular case, but not on an expanded version.


Sol:= eliminate({eq2}, R);

[{R = 0}, {}], [{R = 2*cos(t)^2*a^2-a^2}, {}]

eq3:= subs(R= r^2, Sol[2][1][]);

r^2 = 2*cos(t)^2*a^2-a^2

eq4:= combine(%);

r^2 = a^2*cos(2*t)



You asked:

how to get x and y from left side f(x,y)


and get y and x from right side f(y,x)?


Regarding your title: There is a subtle difference between arguments and parameters. The x and y is this case are arguments. In a procedure definition such as 

f:= (x,y)-> x+y

the x and y are parameters.

Yes, when you assign to an indexed expression as in

A[k]:= x;

where A has not been otherwise defined, you create a hashtable. It can also be explicitly created by

A:= table().

It is one of the most important data structures in Maple. See ?table , ?indices , and ?entries .

Here's how to plot the solutions. In the commands inside the loop that I gave you before, change Sol to Sol[T]:

     Sol[T]:= fsolve(sys3,{a,b,c,d,e,k1,k2,k3}):
     print('T'= T, map(c-> 'X[c]'= eval(X[c], Sol[T]), [CH4, CO2, H2O, H2, CO]))
end do:

Then add after the loop,

          plot([seq]([T, eval(X[c], Sol[T])], T= 600..1200, 50), title= c),
          c= [CH4, CO2, H2O, H2, CO]

First 346 347 348 349 350 351 352 Last Page 348 of 381