MaplePrimes Questions

Hi everyone,

I just started using Maple which is part of a class I am taking. 

We are asked to write a procedure which returns two random values (think two dice).

What I would like to do is:

dice := proc()
    local a,b;
    a := rand(1..6);
    b := rand(1..6);
    
    return a,b;
end proc:

That doesn't work and I don't understand why. How does rand work? Also, how can I call rand in a loop, i.e. repeat rand n times and add the values?

I really hope you can help me here, really struggling.

I am trying to solve improper integrals using Maple. I need to choose at least one from attached and I am leaning towards number 26 but I am having trouble. I am new to Maple and have no idea where to even begin. Please provide the correct steps needed to get to the right answer.

Hi there:

i use Grid:-Map() to run some code on many cores. When I set

Grid:-Setup(numnodes=23);

everything runs fine. When I set (note I have 28 logical cores present):

Grid:-Setup(numnodes=24);

I get the "stack limit reached" message (see attached image below). I've explored setting stack limits to 'unlimited' at the OS level (ubuntu 18.04), as well as setting

kernelopts(stacklimit=infinity)

However, these do not help, and I still end up with the same message.

Any ideas what could be the problem? Also, I am assuming that kernelopts settings get passed to other, spawned kernels, but even if not, I experimented with setting this directly inside the function that gets passed to Grid:-Map()

thanks

 

 

 

 

chosen1 := [[1,2],[1,20],[3,4]]:
chosen2 := [[2,3],[20,3],[3,4]]:
chosen3 := [[3,4],[5,7]]:
chosen4 := [[4,5],[5,6]]:
chosen5 := [[5,6],[7,9]]:
 
hashtable can not work 
 
for example
[1,2]'s 2 as key to find 3 in chosen2 [2,3] then use 3 to find 4 in [3,4] then use 4 to find 5 in [4,5]
 
 

a:=sin(theta3(t))*(diff(theta3(t), t))^2*cos(theta1(t))*l1*l3*m3+sin(theta3(t))*(diff(theta3(t), t))^2*cos(theta1(t))*l1*l3*mi+sin(theta3(t))*(diff(theta3(t), t))^2*cos(theta1(t))*l1*l3*m4+l1^2*m2*(diff(theta1(t), t, t))-sin(theta3(t))*(diff(theta3(t), t))^2*cos(theta1(t))*l1*lc3*m3+sin(theta4(t))*(diff(theta4(t), t))^2*cos(theta1(t))*l1*l4*mi+sin(theta4(t))*(diff(theta4(t), t))^2*cos(theta1(t))*l1*l4*m4-sin(theta4(t))*(diff(theta4(t), t))^2*cos(theta1(t))*l1*lc4*m4+sin(theta6(t))*(diff(theta6(t), t))^2*cos(theta1(t))*h2*l1*ml+sin(theta6(t))*(diff(theta6(t), t))^2*cos(theta1(t))*h2*l1*m3+l1^2*ml*(diff(theta1(t), t, t))+l1^2*mr*(diff(theta1(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*l2*ml*(diff(theta2(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*l2*mc*(diff(theta2(t), t, t))+sin(theta5(t))*sin(theta1(t))*h2*l1*mi*(diff(theta5(t), t, t))-cos(theta3(t))*cos(theta1(t))*l1*l3*m4*(diff(theta3(t), t, t))+cos(theta5(t))*cos(theta1(t))*h2*l1*mc*(diff(theta5(t), t, t))+sin(theta6(t))*(diff(theta6(t), t))^2*cos(theta1(t))*h2*l1*mi+sin(theta6(t))*(diff(theta6(t), t))^2*cos(theta1(t))*h2*l1*m4-sin(theta5(t))*(diff(theta5(t), t))^2*cos(theta1(t))*h2*l1*mi-sin(theta5(t))*(diff(theta5(t), t))^2*cos(theta1(t))*h2*l1*m4-sin(theta5(t))*(diff(theta5(t), t))^2*cos(theta1(t))*h2*l1*m3-sin(theta5(t))*(diff(theta5(t), t))^2*cos(theta1(t))*h2*l1*mr-sin(theta5(t))*(diff(theta5(t), t))^2*cos(theta1(t))*h2*l1*mc-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*l2*m3-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*lc2*m2-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*l2*mr+sin(theta2(t))*sin(theta1(t))*l1*l2*ml*(diff(theta2(t), t, t))+cos(theta5(t))*cos(theta1(t))*h2*l1*mi*(diff(theta5(t), t, t))+l1^2*m4*(diff(theta1(t), t, t))+sin(theta5(t))*sin(theta1(t))*h2*l1*m3*(diff(theta5(t), t, t))+cos(theta3(t))*cos(theta1(t))*l1*lc3*m3*(diff(theta3(t), t, t))-sin(theta3(t))*sin(theta1(t))*l1*l3*m4*(diff(theta3(t), t, t))-cos(theta6(t))*cos(theta1(t))*h2*l1*m4*(diff(theta6(t), t, t))-sin(theta4(t))*sin(theta1(t))*l1*l4*m4*(diff(theta4(t), t, t))-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*l2*mi-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*l2*mc-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*l2*ml-sin(theta2(t))*(diff(theta2(t), t))^2*cos(theta1(t))*l1*l2*m4-sin(theta7(t))*(diff(theta7(t), t))^2*cos(theta1(t))*h3*l1*mc-cos(theta4(t))*cos(theta1(t))*l1*l4*mi*(diff(theta4(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*l2*mr*(diff(theta2(t), t, t))-cos(theta6(t))*(diff(theta6(t), t))^2*sin(theta1(t))*h2*l1*mi-cos(theta6(t))*(diff(theta6(t), t))^2*sin(theta1(t))*h2*l1*m4+cos(theta5(t))*(diff(theta5(t), t))^2*sin(theta1(t))*h2*l1*m3+cos(theta5(t))*(diff(theta5(t), t))^2*sin(theta1(t))*h2*l1*mi+cos(theta5(t))*(diff(theta5(t), t))^2*sin(theta1(t))*h2*l1*mc+cos(theta5(t))*(diff(theta5(t), t))^2*sin(theta1(t))*h2*l1*mr+cos(q2(t))*sin(theta1(t))*l1*l2*mi*(diff(theta2(t), t))*(diff(theta1(t), t))+cos(q2(t))*sin(theta1(t))*l1*l2*m4*(diff(theta2(t), t))*(diff(theta1(t), t))+cos(q2(t))*sin(theta1(t))*l1*lc2*m2*(diff(theta2(t), t))*(diff(theta1(t), t))+cos(q2(t))*sin(theta1(t))*l1*l2*m3*(diff(theta2(t), t))*(diff(theta1(t), t))+cos(q2(t))*sin(theta1(t))*l1*l2*mc*(diff(theta2(t), t))*(diff(theta1(t), t))+cos(q2(t))*sin(theta1(t))*l1*l2*ml*(diff(theta2(t), t))*(diff(theta1(t), t))+cos(q2(t))*sin(theta1(t))*l1*l2*mr*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*l2*mc*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*l2*m4*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*l2*mr*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*l2*m3*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*l2*mi*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*l2*ml*(diff(theta2(t), t))*(diff(theta1(t), t))-sin(q2(t))*cos(theta1(t))*l1*lc2*m2*(diff(theta2(t), t))*(diff(theta1(t), t))-cos(theta3(t))*(diff(theta3(t), t))^2*sin(theta1(t))*l1*l3*mi+cos(theta3(t))*(diff(theta3(t), t))^2*sin(theta1(t))*l1*lc3*m3-cos(theta4(t))*(diff(theta4(t), t))^2*sin(theta1(t))*l1*l4*m4-cos(theta4(t))*(diff(theta4(t), t))^2*sin(theta1(t))*l1*l4*mi+cos(theta4(t))*(diff(theta4(t), t))^2*sin(theta1(t))*l1*lc4*m4-cos(theta6(t))*(diff(theta6(t), t))^2*sin(theta1(t))*h2*l1*ml-cos(theta6(t))*(diff(theta6(t), t))^2*sin(theta1(t))*h2*l1*m3-cos(theta3(t))*(diff(theta3(t), t))^2*sin(theta1(t))*l1*l3*m4-cos(theta3(t))*(diff(theta3(t), t))^2*sin(theta1(t))*l1*l3*m3+l1^2*mc*(diff(theta1(t), t, t))-cos(theta4(t))*cos(theta1(t))*l1*l4*m4*(diff(theta4(t), t, t))+cos(theta5(t))*cos(theta1(t))*h2*l1*mr*(diff(theta5(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*lc2*m2*(diff(theta2(t), t, t))+cos(theta1(t))*g*l1*mr+cos(theta1(t))*g*l1*m3+cos(theta1(t))*g*l1*m2+cos(theta1(t))*g*l1*m4+cos(theta1(t))*g*l1*ml+cos(theta1(t))*g*l1*mc+m1*g*lc1*cos(theta1(t))+cos(theta1(t))*g*l1*mi+cos(theta5(t))*cos(theta1(t))*h2*l1*m3*(diff(theta5(t), t, t))-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*l2*m4*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*l2*mc+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*l2*mc*(diff(theta2(t), t))+cos(theta7(t))*(diff(theta7(t), t))^2*sin(theta1(t))*h3*l1*mc+l1^2*m3*(diff(theta1(t), t, t))+l1^2*mi*(diff(theta1(t), t, t))+cos(theta5(t))*(diff(theta5(t), t))^2*sin(theta1(t))*h2*l1*m4-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*l2*m3*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*l2*ml+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*l2*ml*(diff(theta2(t), t))-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*lc2*m2*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*l2*mr+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*l2*mr*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*l2*m4+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*l2*m4*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*l2*mi+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*l2*mi*(diff(theta2(t), t))-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*l2*mr*(diff(theta2(t), t))-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*l2*mi*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*l2*m3+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*l2*m3*(diff(theta2(t), t))-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*l2*mc*(diff(theta2(t), t))-cos(theta2(t))*sin(theta1(t))*(diff(theta1(t), t))*l1*l2*ml*(diff(theta2(t), t))+cos(theta2(t))*(diff(theta2(t), t))^2*sin(theta1(t))*l1*lc2*m2+sin(theta2(t))*cos(theta1(t))*(diff(theta1(t), t))*l1*lc2*m2*(diff(theta2(t), t))+sin(theta2(t))*sin(theta1(t))*l1*l2*m3*(diff(theta2(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*l2*m3*(diff(theta2(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*l2*mi*(diff(theta2(t), t, t))+cos(theta5(t))*cos(theta1(t))*h2*l1*m4*(diff(theta5(t), t, t))+sin(theta2(t))*sin(theta1(t))*l1*l2*mr*(diff(theta2(t), t, t))+m1*lc1^2*(diff(theta1(t), t, t))-sin(theta6(t))*sin(theta1(t))*h2*l1*m4*(diff(theta6(t), t, t))+sin(theta5(t))*sin(theta1(t))*h2*l1*mr*(diff(theta5(t), t, t))+sin(theta5(t))*sin(theta1(t))*h2*l1*mc*(diff(theta5(t), t, t))-cos(theta6(t))*cos(theta1(t))*h2*l1*mi*(diff(theta6(t), t, t))-sin(theta6(t))*sin(theta1(t))*h2*l1*mi*(diff(theta6(t), t, t))-cos(theta6(t))*cos(theta1(t))*h2*l1*m3*(diff(theta6(t), t, t))-sin(theta6(t))*sin(theta1(t))*h2*l1*m3*(diff(theta6(t), t, t))+sin(theta2(t))*sin(theta1(t))*l1*lc2*m2*(diff(theta2(t), t, t))+cos(theta2(t))*cos(theta1(t))*l1*l2*m4*(diff(theta2(t), t, t))+sin(theta2(t))*sin(theta1(t))*l1*l2*mc*(diff(theta2(t), t, t))+sin(theta3(t))*sin(theta1(t))*l1*lc3*m3*(diff(theta3(t), t, t))-cos(theta3(t))*cos(theta1(t))*l1*l3*mi*(diff(theta3(t), t, t))-sin(theta3(t))*sin(theta1(t))*l1*l3*mi*(diff(theta3(t), t, t))-cos(theta3(t))*cos(theta1(t))*l1*l3*m3*(diff(theta3(t), t, t))-sin(theta3(t))*sin(theta1(t))*l1*l3*m3*(diff(theta3(t), t, t))+cos(theta7(t))*cos(theta1(t))*h3*l1*mc*(diff(theta7(t), t, t))-cos(theta6(t))*cos(theta1(t))*h2*l1*ml*(diff(theta6(t), t, t))+sin(theta7(t))*sin(theta1(t))*h3*l1*mc*(diff(theta7(t), t, t))-sin(theta6(t))*sin(theta1(t))*h2*l1*ml*(diff(theta6(t), t, t))+sin(theta4(t))*sin(theta1(t))*l1*lc4*m4*(diff(theta4(t), t, t))+cos(theta4(t))*cos(theta1(t))*l1*lc4*m4*(diff(theta4(t), t, t))-sin(theta4(t))*sin(theta1(t))*l1*l4*mi*(diff(theta4(t), t, t))+sin(theta2(t))*sin(theta1(t))*l1*l2*m4*(diff(theta2(t), t, t))+sin(theta2(t))*sin(theta1(t))*l1*l2*mi*(diff(theta2(t), t, t))+sin(theta5(t))*sin(theta1(t))*h2*l1*m4*(diff(theta5(t), t, t))

I want to manipulate polynomials in two non-commuting variables, over the field of rational numbers.  I read some of the help concerning Ore algebras, and also some of the help concerning the Physics package (where there are non-commuting variables), but unfortunately I could not understand much of what I read!  For someone who is not a Maple virtuoso, is there a simple way to work with non-commutative polynomials?  

 
I also tried the “do-it-yourself” approach, i.e., defining a non-commutative multiplication via a neutral operator &*.  This time I had some success, but I ran into problems when I tried to extract the coefficient of a given monomial in a given polynomial.  In the file  NonCommutPolynomials.mw  you can see that the Maple command “coeff” gives me the correct answer only when the degree of the monomial is strictly greater than 1.  I have no idea how to extract the coefficient of x, or of y, or how to get the constant term of the polynomial — and extracting coefficients is something I need to do!
 
Thanks!
 

Hi all,

I wanted to know if there's a tool in Maple for solving (globally) non convex optimization problems?

specifically, I need to solve the following problem:

min||Ax-b||_1 s.t. ||x||_2=1

where A is a given matrix of size nxd

b is a given vector of size nx1

x is an unkown vector of size dx1 that should be a unit vector (hence the contraint ||x||_2=1).

The closest function I found in Maple is LSSolve but this function is intended for convex problems.

I'm able to solve the problem using Yalmip in matlab.

Here's an example code in matlab+yalmip that finds the unit vector x that globally minimizes ||Ax-b||_1.

clear;
close all;
clc;

n = 10;
d = 3;

A = rand(n,d);
b = rand(n,1);
x = sdpvar(d,1);

Objective = norm(A*x-b,1);
cons = x'*x==1;
options = sdpsettings('solver','bmibnb');
sol= optimize(cons,Objective, options);

x_sol = value(x)

 

Is there a way to write a similar code in Maple?

 

Thanks

 

I'm a student and I've recently been introduced to Maple. I've been given the task to create a polynomial in Maple that goes through the following points: 

[2, 2], [12, 6], [37, 42], [49, 21], [73, 49], [91, 2]

Once the polynomial has been created, I would like to know the formula. 

What do I need to do to solve this task?

I'm looking for the specific commands etc.

Thanks.

 

Hello

If 0 occurs in the first element, I want to remove the list containing zero and the associated number.

example

p := [[[0, 5], [3, 10], [1, 20], [0, 50]], [[2, 5], [0, 10], [2, 20], [0, 50]]]

after processing:

[[[3, 10], [1, 20]], [[2, 5], [2, 20]]]

I tried in vain...

select(i -> (subs(p,p[1,i,1])>0), [$1..nops(p)]);
 

 

[[1,2],[5,7]]intersect [[1,2]]

return [1,2]

there is error when run this.

search start from a, b, c, ... for each sequence if input a,b,c,d,e,f,g,h,i,j,k

is there a function like accumulate in haskell in maple instead of using for loop?

would like to search something if found, then return the length of it searched from the starting position

when start from a search a from b to g whether is a,  if find , return the length from c to the found position,

when start from b search b from c to h whether is b,  if find , return the length from c to the found position

....

then save the length into a list

a b c d e f g

   b c d e f g h

      c d e f g h i

         d e f g h i j

            ef g h i j k

 

I am trying to calculate the pressure required for a specific bend angle produced by my actuator
But when evaluating the triple integral for calculating the moment the error of too many level recursions is recieved
Any help or advice is appreciated

Code:
a = 0.11e-1;

b = 0.25e-2;

t = 0.25e-2;

theeta = (1/180)*pi;

L = 0.17e-1;

R = L/theeta;

shearmodulus = 314000;

0.011 = 0.011 0.0025 = 0.0025 0.0025 = 0.0025 1 1 --- Pi = --- pi 180 180 0.017 = 0.017 R = 0.9740282516 314000 = 314000 eq0 := Ma = int(int((x*sin(O)+b)*x^2*(cos(O)*cos(O)), O = 0 .. (1/2)*Pi), x = 0.9e-2 .. 0.11e-1); -9 eq0 := Ma = 1.067341412 10 assign(('t', 'b', 'L', 'shearmodulus', 'theeta', 'a') = (0.25e-2, 0.25e-2, 0.17e-1, 314000, (1/180)*Pi, 0.11e-1));

eq4 := Mo1 = int(int(2*shearmodulus*(1+Beeta*theeta/L-1/(1+Beeta*theeta/L)^3)*(O+t)*L, O = 0.9e-2 .. 0.11e-1), Beeta = 0 .. b);

eq4 := Mo1 = 0.000003416445428 simplify(Mo1 = int(int(2*shearmodulus*(1+Beeta*theeta/L-1/(1+Beeta*theeta/L)^3)*(O+t)*L, O = 0.9e-2 .. 0.11e-1), Beeta = 0 .. b)); Mo1 = 0.000003416445428 simplify(Mo1 = int(int(2*shearmodulus*(1+Beeta*theeta/L-1/(1+Beeta*theeta/L)^3)*(O+t)*L, O = 0.9e-2 .. 0.11e-1), Beeta = 0 .. b));

Mo1 = 0.000003416445428 Mo2 = 2*(int(int(int(shearmodulus*((R+b+sin(Phi)*(A+tao))/R-1/((R+b+sin(Phi)*(A+tao))/R)^3)*((A+tao)^2*sin(Phi)+b*(A+tao))*L, Phi = 0 .. (1/2)*Pi), A = 0.9e-2 .. 0.11e-1), tao = 0 .. t));

Error, (in depends) too many levels of recursion eq5 := Pressure = Mo/Ma; Mo eq5 := Pressure = -- Ma 

I am not interested in the mapleprime group, so I want to delete my account in this group.

Hi, I ran the following code:

solve({a > 0, b*d*(abs(c)^2-abs(a)^2) = 0, -a*c*(abs(b)^2-abs(d)^2) = 0, -abs(b)^2*a*d+abs(d)^2*b*c = 0, abs(c)^2*a*d-abs(a)^2*b*c = 0}, {a, b, c, d})

and we can easily see that a=a, b=0, c=0, d=d, should be a solution but Maple does not give me that answer. The result is:

{b = 0, c = 0, d = 0, 0 < a}, {b = 0, c = a, d = 0, 0 < a}, {b = d, c = a, 0 < a, 0 < d}, {b = 0, c = -a, d = 0, 0 < a}, {b = -d, c = -a, 0 < a, d < 0}, {b = d, c = a, 0 < a, d < 0}, {b = -d, c = -a, 0 < a, 0 < d}

Am I missing something?

First 768 769 770 771 772 773 774 Last Page 770 of 2428