Jarekkk

454 Reputation

13 Badges

19 years, 180 days

MaplePrimes Activity


These are answers submitted by Jarekkk

I see no one has responded yet to your question. However, I am not sure about what you want. Maple does understand the prime symbol, so you can use it. I inserted also two different plot commands to show how you can type them with legend specification.



 

The plots:


plot([x^2, 2*x], x = -3 .. 3, legend = ["f(x)", "f'(x)"])plot([x^2, 2*x], x = -3 .. 3, legend = [typeset('f(x)'), typeset('diff(f(x), x)')])

I asked a similar question (and was not the first one).

Then, look also at ?Statistics/Rank and pay attention to OrderByRank as well.

Another way is to use ?numboccur:

M := LinearAlgebra:-RandomMatrix(5, generator = 0 .. 2);


numboccur(M, 0);
                               6

but also possible:

expr := -2*Pi*sin(Pi*a)/(-1+cos(2*Pi*a)):
1/simplify(subs({cos(2*Pi*a)=cos(Pi*a)^2-sin(Pi*a)^2},1/expr));

                              Pi    
                           ---------
                           sin(Pi a)

or this:

1/simplify(expand(1/expr));
                              Pi    
                           ---------
                           sin(Pi a)

For example like this?

assign((cat(E,0..2,1..3,M),cat(M0,1..3,M)) = seq(Matrix(node),i=1..12));

According to ?Grid I created some example. I did it for the first time (ever), so it doesn't have to be the best way. Maybe, someone will improve it. I suppose, that the iterations in a for-loop are dependent.

In the following example: the result should be a matrix (Nx2) where the first row contains some random numbers and each other row is made by the sum of the elements in the previous row and the difference between them. Such task would be probably faster when solving sequentially, but this is just for illustration.

M:=7:
res1 := Vector(M):
res2 := Vector(M):
paralel:=proc(N::integer)
  uses Grid, RandomTools;
  global res1, res2;
  local i,thisNode:
  thisNode := MyNode();

  # generate first elements of vectors res1 and res2
  if thisNode = 0 then res1[1]:=Generate(integer(range = 1 .. 15)); Send(1,res1);
  elif thisNode = 1 then res2[1]:=Generate(integer(range = 1 .. 10)); res1:=Receive(0);
  end if;

  # compute the i-th elements by the means of the (i-1)-th elements
  for i from 2 to N do
    if thisNode = 0 then
       res2:=Receive(1);
       res1[i]:=res1[i-1]+res2[i-1];
       Send(1,res1);          
    else
       res2[i]:=res1[i-1]-res2[i-1];
       Send(0, res2);
       res1:=Receive(0);
    end if;
  end do;
 
  # get res2 from node 1
  if thisNode = 1 then
     Send(0,res2);
  else
     res2:=Receive(1);
     return <res1|res2>;
  end if;
end proc:

Grid[Launch](paralel,M,numnodes=2,imports=['res1','res2']);


is denoted in Maple by I (big letter).

You forgot to put a comma in the solve call. It should be

solve({eq||(1..10)} , {a0, a1, a2, b0, b1, b2, c, g1, g2, k});

You can achieve the same result with ?seq as well.

[seq(seq([i, j], j = 0 .. 2), i = 0 .. 2)];

[[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1],   [2, 2]]

Another possibility can be defining the Jacobian as a function.

# points denoted as P1, ..., P4
P1 := 0, 0: P2 := 0, b/d: P3 := beta/delta, 0:
P4 := (-d*beta+b*gamma)/(-delta*d+gamma*c), (beta*c-delta*b)/(delta*d-gamma*c):

Jf := (x, y) -> Matrix(2, 2, {(1, 1) = beta-2*delta*x-gamma*y, (1, 2) = -x*gamma, (2, 1) = -y*c, (2, 2) = b-2*d*y-c*x}):

for i to 4 do Jf(P||i) end do;

simplify(%);

You should try to search first. Similar questions were asked a lot, for example here. When you don't want the single points but a line conecting them, simply don't use an option style=point, e.g.:

x := <0, 0.150754e-1, 0.376884e-1, 0.829146e-1, 0.527638e-1, .120603, .173367, .203518, .241206, .286432, .316583, .354271, .39196, .437186, .474874, .550251, .58794, .625628, .678392, .746231, .708543, .81407, .949749, 1.1005, 1.17588, 1.33417, 1.59045, 1.91457, 2.25377>:

y := <1, 1.20603, 1.53769, 1.6, 1.77889, 2.74372, 3.49749, 3.9196, 4.43216, 5.06533, 5.45729, 5.90955, 6.39196, 6.87437, 7.29648, 7.59799, 7.98995, 8.29146, 8.56281, 8.89447, 9.22613, 9.07538, 9.49749, 9.79899, 9.94975, 9.9799, 9.9799, 10.0101, 10.0101>:

plot(<x|y>);

In this example I removed the last value from y since it had one more value than x.

I see the problem in Maple 15. You have allvalues there, but you actually don't use the output of it. In first case you get a list of two lists (=solutions), while in the second case you get a list of one list (where both solutions are "hidden in the RootOf structure"). You can replace

allvalues(%);

with

if nops(sol)=1 then sol:=[allvalues(op(sol))] else sol:=allvalues(sol) fi;

That should work for both cases.

This is the corrected code:

with(DEtools):
DEplot3d({diff(x(t), t) = -10*x(t)+10*y(t), diff(y(t), t) = 25*x(t)-y(t)-x(t)*z(t), diff(z(t), t) = (-8/3)*z(t)+x(t)*y(t)}, {x(t), y(t), z(t)}, t = 0 .. 60, [[x(0) = -1, y(0) = -1, z(0) = 1]], stepsize = .5);

However, the result doesn't say much, so you can play with it a little. You can add the option animatecurves = true (to make an animation), with which you can also set the number of animation frames. Maybe, the DEplot command (for 2D plots) can be also useful. For more info look at  ?DEtools/DEplot and  ?DEtools/DEplot3d.

You should also decrease the stepsize, since the result is not a smooth line (but it has to be).

with(Statistics):
rows := 5:
M := LinearAlgebra[RandomMatrix](rows, 2);


Vector([seq(Mean(M[i]), i = 1 .. rows)]);


Have you read the error message? You typed "z(x)" instead of "z(t)" when specifying the variables in the dsolve call.

You also used "w" instead of "w(t)" in difI and difC.

I expect you assigned some numeric values to the parameters before (you're using type=numeric without parameters option).

1 2 3 4 5 6 7 Page 1 of 7