Items tagged with expression expression Tagged Items Feed

Hi, I am completely new to Maple, and I need to use it to optimize my equations in order to make my PLC codes more compressed. I am calculating forward kinematics with the Denavit-Hartenberg method and as such I get long expressions. After a lot of google'ing and frustration, I thought I'd ask here in the hope that one of you might be able to assist me.

I have the following equations;

X := L10*cos(q5) - L16*(sin(q10)*(sin(q5)*sin(q8) - cos(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7))) - cos(q10)*(sin(q9)*(cos(q8)*sin(q5) + sin(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7))) + cos(q9)*(cos(q5)*cos(q6)*sin(q7) + cos(q5)*cos(q7)*sin(q6)))) - d2*(cos(q10)*(sin(q5)*sin(q8) - cos(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7))) + sin(q10)*(sin(q9)*(cos(q8)*sin(q5) + sin(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7))) + cos(q9)*(cos(q5)*cos(q6)*sin(q7) + cos(q5)*cos(q7)*sin(q6)))) + L15*(sin(q9)*(cos(q8)*sin(q5) + sin(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7))) + cos(q9)*(cos(q5)*cos(q6)*sin(q7) + cos(q5)*cos(q7)*sin(q6))) - L11*cos(q5)*sin(q6) + d1*cos(q5)*cos(q6) - L13*sin(q5)*sin(q8) + L14*cos(q9)*(cos(q8)*sin(q5) + sin(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7))) + L13*cos(q8)*(cos(q5)*cos(q6)*cos(q7) - cos(q5)*sin(q6)*sin(q7)) - L14*sin(q9)*(cos(q5)*cos(q6)*sin(q7) + cos(q5)*cos(q7)*sin(q6)) + L12*cos(q5)*cos(q6)*cos(q7) - L12*cos(q5)*sin(q6)*sin(q7);

Y := L10*sin(q5) - L9 + L16*(sin(q10)*(cos(q5)*sin(q8) - cos(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5))) - cos(q10)*(sin(q9)*(cos(q5)*cos(q8) + sin(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5))) - cos(q9)*(cos(q6)*sin(q5)*sin(q7) + cos(q7)*sin(q5)*sin(q6)))) + d2*(cos(q10)*(cos(q5)*sin(q8) - cos(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5))) + sin(q10)*(sin(q9)*(cos(q5)*cos(q8) + sin(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5))) - cos(q9)*(cos(q6)*sin(q5)*sin(q7) + cos(q7)*sin(q5)*sin(q6)))) - L15*(sin(q9)*(cos(q5)*cos(q8) + sin(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5))) - cos(q9)*(cos(q6)*sin(q5)*sin(q7) + cos(q7)*sin(q5)*sin(q6))) + L13*cos(q5)*sin(q8) - L11*sin(q5)*sin(q6) + d1*cos(q6)*sin(q5) - L14*cos(q9)*(cos(q5)*cos(q8) + sin(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5))) - L13*cos(q8)*(sin(q5)*sin(q6)*sin(q7) - cos(q6)*cos(q7)*sin(q5)) - L14*sin(q9)*(cos(q6)*sin(q5)*sin(q7) + cos(q7)*sin(q5)*sin(q6)) + L12*cos(q6)*cos(q7)*sin(q5) - L12*sin(q5)*sin(q6)*sin(q7);

Z := L15*(cos(q9)*(cos(q6)*cos(q7) - sin(q6)*sin(q7)) - sin(q8)*sin(q9)*(cos(q6)*sin(q7) + cos(q7)*sin(q6))) - L11*cos(q6) - L8 - d1*sin(q6) + L16*(cos(q10)*(cos(q9)*(cos(q6)*cos(q7) - sin(q6)*sin(q7)) - sin(q8)*sin(q9)*(cos(q6)*sin(q7) + cos(q7)*sin(q6))) - cos(q8)*sin(q10)*(cos(q6)*sin(q7) + cos(q7)*sin(q6))) - d2*(sin(q10)*(cos(q9)*(cos(q6)*cos(q7) - sin(q6)*sin(q7)) - sin(q8)*sin(q9)*(cos(q6)*sin(q7) + cos(q7)*sin(q6))) + cos(q8)*cos(q10)*(cos(q6)*sin(q7) + cos(q7)*sin(q6))) - L13*cos(q8)*(cos(q6)*sin(q7) + cos(q7)*sin(q6)) - L14*sin(q9)*(cos(q6)*cos(q7) - sin(q6)*sin(q7)) - L12*cos(q6)*sin(q7) - L12*cos(q7)*sin(q6) - L14*cos(q9)*sin(q8)*(cos(q6)*sin(q7) + cos(q7)*sin(q6));


I need to optimize these equations, but still keep them separate. I would like to use mutual expressions for the calculations within, but still as I said keep the outputs of X, Y and Z separate.

This is MATLAB code.


Thanks in advance for any help.

Often, I'd like to use variable names that look like expressions. Is there a way to convert them to some form of inert form or as some sort of literal (so that they are not a mathematical expression) ?

Such as,


Can't type it here, but I wanted 'a' subscript 1 superscript (2). I'd like it to not be a1 squared.

Basically, I'd like the subscripts and superscript to not mean anything mathematically . . . And, I use a1^(3), a1^(1), a2^(1), a2^(2), a2^(3), b2^(3), etc.


Thanks, for any suggests.


Cheers !!

Hi there

I'm trying to isolate (y1-3)2+(x1-1)in the equation 25(y1-3)2+200+100(x1-1)2=0.

I have tried isolate and solve, but solve coplains about solving for expressions (but when inputting i:=(x1,y1)->(y1-3)2+(x1-1)2 it still doesn't work), and isolate can only isolate either (y1-3)2 or (x1-1). Not both.

How can I do this with as few lines as possible?


- Alex

When I write in maple the following:



What do I need to write to make maple make the operation that will evaluate the expression and show the following?




simplify(%) or evaluate(%) only shows it the same way it was inputted to start with.

let m3 = [[0; 1; 0]; [1; 0; 1]; [0; 1; 0]]

1. Firstly, express this matrix into sequence function expression

2. how to express this matrix in terms of forloop code

3. for complicated case such as 1 is not in easy pattern, can it intelligently express the matrix in terms of for loop code


is there exist extra tools to express matrix in terms of for loop code or sequence function code?

I was trying to see if Maple contains equivalent to Mathematica FreeQ command to check inside a proc if an input expression contains an "x" or not.  I could not find such command in Maple. So now I call indets(), which is a nice function, that tells me all the symbols in the expression, then use member() to check.

Would this be correct way to do this? Here is an example

if member(x,s) then
   print(`yes, x is there`);

I can't use patmatch() for this, as I do not know what the expression will look like yet, I just needed to know if it contains an "x" (in this case), a free symbol "x", and that is all.

I thought to ask if there is a better way to do this.

Dear all:

I wisth to replace in an expression that contains several sums:

sum(a[i],i=1..n+1) and sum(w[i],i=1..n+1)

and replace them with a single command into:

a[n+1]+sum([i],i=1..n) and w[n+1]+sum(w[n],1..n)

everywhere in the expression

Thank you


Sorry for basic question, Maple newbie here and I could not find answer using google.

I understand in Maple one uses the back quote key (or rather the apostrophe, 0X27) to prevent one time evaluation of expression. Hence when writing

'sin(Pi)'; #this remain sin(Pi)
%; # now we get 0

But when I tried it on fraction, it did not hold it:

'16/4'; #maple replied with 4

This might indicate that the front end parser did this simplification before the main evaluator got hold of it, so it was too late?

Either way, how would one make Maple return 16/4 when the input is '16/4'?

Hi everyone,


I have a question regarding the use of the applyrule function. I have an expression that contains a polynomial. The expression looks something like:


Y := (a0 + a_1*x + a_2*x^2 + ... a_n*x^n)*f(y) + b_0 + b_1*x + b_2*x^2 + ... b_n*x^n)*g(y):


I would like to express this as y(x) = P_1*f(y) + P_2*g(y).


So far I have tried applyrule([a0 + a_1*x + a_2*x^2 + ... a_n*x^n = P_1, b_0 + b_1*x + b_2*x^2 + ... b_n*x^n) = P_2],Y):


This doesn't seem to work. Any suggestions?





I have a long expression with different order derrivatives, that is written in form like that:

-(D[1](f))(x, y)

I'd like to transform it into standard maple form like:


Is there any special procedure to achieve this goal?

how to add another line in this template of formula

use the expression template  

how to add another line like


thank you in advance for your help

Hi Everyone,

I have an expression that contains a second order derivative: EXPR:=ay''(x) + bz'(x) + cf'(x)+... The variable y  obeys an ordinary differential equation, y''(x) = f(y,x). I would like to replace the second order deriavtive in my expression with f(y,x). So far I have tried applyrule([y''(x)=f(y,x)],EXPR), subs(y''(x)=f(y,x),EXPR) and algsubs(y''(x)=f(y,x),EXPR) and nothing seems to work. Any helpful suggestions?


I have question about how to write the expression to get the order in the sequence?

For exmple, if I have this sequence,


I want to write a procedure that tells me the location of any input,x in the sequence E.

For example, if I choose x:=3, then the number 3 is actually between 2 and 7, so it will give me the answer C(x)=3 (because 7 is the third elemet).

I try to write the procedure but there always wrong! I do not know what expression should I write!

for i from 1 to nops(E) do
if x<=E[i] then

Please help! 

Successively transform the expression x + y + z into x ∗ y ∗ z and [x, y, z], using Maple commands.

it is not a maple question, but i need it before running in maple

could you give a help?

how to get a list of terms of expression such as x+z^2 in gap system?

how to convert to a list [x, z^2] for for loop to get each terms?


expected output for for loop

for i in List(x+2*y+z^2) do

1 2 3 4 5 6 7 Page 1 of 8