Bendesarts

450 Reputation

10 Badges

14 years, 114 days

MaplePrimes Activity


These are replies submitted by Bendesarts

@Kitonum 

Ouhhhhh !

Thank you but the code is a bit complex and could be a bit complex to automatize.

For example, when I try this code on this similar expression, it doesn't work :

-cos(gamma0(t))*cos(beta0(t)) = -(sin(psi[1](t))*cos(theta[1](t))*sin(gamma[1](t))-sin(psi[1](t))*sin(theta[1](t))*cos(gamma[1](t))+cos(theta[1](t))*cos(psi[1](t))*cos(gamma[1](t))+cos(psi[1](t))*sin(theta[1](t))*sin(gamma[1](t)))*cos(beta[1](t))

Do you have ideas so as to make a automatic procedure so as to treat this kind of equations ?

@Kitonum 

@vv 

@Joe Riel 

@Carl Love 

Hello, 

I could do the automatic procedure with the help of the forum.

Thanks a lot for your help.

Here my code :

TrigoTransform:= proc(Eq)
local S,S1,tt,pp,Eq2,ListVariables,ListVariablesMod,Subs,size;
#Flatten the substitutions list#
ListVariables:=indets(Eq, function(identical(t)));
ListVariables:=[op(ListVariables)];
ListVariablesMod:=map(f->cat(op(0,f),_),ListVariables);
Subs:=ListVariables=~ListVariablesMod;
#Variables changement#
Eq2:=Eq:
Eq2:=subs(Subs, Eq2);
#Trigonometric transformations#
S:=indets(Eq2);
S1:=indets(select(t->has(t, sin) or has(t, cos), S));
tt:=S minus S1;
Eq2:=add(
applyrule([
cos(u::anything)*cos(v::anything)-sin(u::anything)*sin(v::anything)=cos(u+v),
cos(u::anything)*sin (v::anything)+sin(u::anything)*cos(v::anything)=sin(u+v),
sin(u::anything)*sin(v::anything)-cos(u::anything)*cos(v::anything)=-cos(u+v),
-sin(v::anything)*cos(u::anything)-sin(u::anything)*cos(v::anything)=-sin(u+v)], simplify(coeff(lhs(Eq2),pp), size))*pp, pp=tt)=add(
applyrule([
cos(u::anything)*cos(v::anything)-sin(u::anything)*sin(v::anything)=cos(u+v),
cos(u::anything)*sin (v::anything)+sin(u::anything)*cos(v::anything)=sin(u+v),
sin(u::anything)*sin(v::anything)-cos(u::anything)*cos(v::anything)=-cos(u+v),
-sin(v::anything)*cos(u::anything)-sin(u::anything)*cos(v::anything)=-sin(u+v)], simplify(coeff(rhs(Eq2),pp), size))*pp, pp=tt);
#Variables changement#
Eq2:=subs(map(t->rhs(t)=lhs(t),Subs),Eq2)
end proc:

However, my procedure doesn't work when the expression doesn't have terms. Consequently, the following equation can not be treated with the procedure :

eq:=sin(gamma0(t))*cos(beta0(t)) = -(sin(psi[1](t))*cos(theta[1](t))*cos(gamma[1](t))+sin(psi[1](t))*sin(theta[1](t))*sin(gamma[1](t))-cos(theta[1](t))*cos(psi[1](t))*sin(gamma[1](t))+cos(psi[1](t))*sin(theta[1](t))*cos(gamma[1](t)))*cos(beta[1](t))=0

Can you help me so as to improve the procedure for treating also this kind of equation ?

Thanks a lot for your help

@Joe Riel 

@Carl Love 

Very good!

This code works well.

The only problem is that I have noticed that the order of the variables of my two lists is not the same. I guess that it should come from the fact that sometimes grec symbols are written in letters and sometimes with grec letters

eq:= x0(t)+sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))*xb[1]-sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))*zb[1]-sin(alpha0(t))*cos(beta0(t))*yb[1]+cos(alpha0(t))*sin(gamma0(t))*zb[1]+cos(alpha0(t))*cos(gamma0(t))*xb[1]-l2[1]*(sin(psi[1](t))*sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))-cos(psi[1](t))*sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))+sin(psi[1](t))*cos(alpha0(t))*cos(gamma0(t))+cos(psi[1](t))*cos(alpha0(t))*sin(gamma0(t)))-l3[1]*(sin(theta[1](t))*sin(psi[1](t))*sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))+sin(theta[1](t))*cos(psi[1](t))*sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))+cos(theta[1](t))*sin(psi[1](t))*sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))-cos(theta[1](t))*cos(psi[1](t))*sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))-sin(theta[1](t))*sin(psi[1](t))*cos(alpha0(t))*sin(gamma0(t))+sin(theta[1](t))*cos(psi[1](t))*cos(alpha0(t))*cos(gamma0(t))+cos(theta[1](t))*sin(psi[1](t))*cos(alpha0(t))*cos(gamma0(t))+cos(theta[1](t))*cos(psi[1](t))*cos(alpha0(t))*sin(gamma0(t)))-xp[1](t) = 0;
ListVariables:=indets([eq], function(identical(t)));

ListVariablesMod:=map(f->cat(op(0,f),_),ListVariables);

Do you have a idea so as to sort well the 2 list before creating the list of the substitutions ?

Thanks a lot for your help

@Carl Love 

Perfect ! Thank you

Just a small question but very linked to the previous one :

ListVariables:=indets([eq], function(identical(t)));
ListVariablesMod:=map(f->cat(op(0,f),_),ListVariables);

I would like to create my list of substitutions like this :

Substitutions:=ListVariables=ListVariablesMod;

However, i notice that I have to learn more about how to manipulate lists.

Do you have ideas so that I can obtain my list of substitutions ?

Thank

 

@Joe Riel 

Thank you ! You perfectly answer to my questions and better that I imagined.

@Kitonum 

Perfect! Thanks a lot for your help.

May be it is possible to make still another step of automatization with a procedure.

I have tried this :

TrigoTransform := proc(Eq,T)
local S,S1,tt;
#Flatten the substitutions list#
T:=subsindets([T], {set,list}, op);
#Variables changement#
Eq:=subs(T, Eq);
#Trigonometric transformations#
S:=indets(Eq);
S1:=indets(select(t->has(t, sin) or has(t, cos), S));
tt:=S minus S1;
Eq:=add(
applyrule([
cos(u::anything)*cos(v::anything)-sin(u::anything)*sin(v::anything)=cos(u+v),
cos(u::anything)*sin (v::anything)+sin(u::anything)*cos(v::anything)=sin(u+v),
sin(u::anything)*sin(v::anything)-cos(u::anything)*cos(v::anything)=-cos(u+v),
-sin(v::anything)*cos(u::anything)-sin(u::anything)*cos(v::anything)=-sin(u+v)], simplify(coeff(lhs(Eq),pp), size))*pp, pp=tt);
#Variables changement#
Eq:=subs(map(t->rhs(t)=lhs(t),[T]), Eq);
end proc:

1) There is a fault in my procedure. Do you have an idea so as to correct it ?

2) Another point is linked to the variables of substitutions T. May be it is also possible to create directly like you have done with indets functions.

- The idea would be :
a) to select all the variables such as alpha0(t).
b) create the subsitutions like this alpha0(t)=alpha0_ but with the right hand side alpha0 (determine it automatically by removing (t) at the end of alpha0(t) and replace it by a underscore "_".

Do you have ideas to obtain also the substitutions T automatically ? This would enable to create a procedure with only one argument the equation to transform.

Thank you for your help 

@Kitonum 

Thank you again for your answer.

The only problem with this method is that for each constraint equation I have to well identify the terms non trigonometric of each trigonometric expressions.

That is to say for my equation :

{x0(t),xp[1](t),xb[1],yb[1],zb[1],l2[1],l3[1]}

Do you have ideas so as to make an automatic identification of this set ?

The idea is to be able to use this procedure on one constraints equation without being obliged to analyze these terms before.

Thank your for your help

@vv 

Thank you but it is possible to find something shorter with Flatten it will be great

@Kitonum 

Perfect! Thank you.

My only remark is that why Maple doesn't make also the simplification with the minus.

@Thomas Richard 

Thank for your remark but I knew this. But, this time, I was conducting calculations with classic maple sheet. Consequently, I'm very interested by this function Jacobian of the module Student[MultivariateCalculus]

In order to preserve functions in my jacobian matrix, i have used the following code @Kitonum :

restart;
eq1 := l1*cos(theta(t))+l2*sin(beta(t))-x(t):
eq2 := l1*sin(theta(t))-l2*cos(beta(t)):
T:=[theta(t)=thetaDT, beta(t)=betaDT,x(t)=xDT]:
eq1:=subs(T, eq1);
eq2:=subs(T, eq2);
Phi:=VectorCalculus[Jacobian]([eq1,eq2],[thetaDT,xDT,betaDT]);
Phi:=subs(map(t->rhs(t)=lhs(t),T), Phi);

If you have better, let me know.

Thank you for your help.

@Kitonum 

Great, you answer perfectly to my need. It is amazing that there is no function which can do this kind of transformation. You code works fine but was expected to use just one specific function. 

However, the following subsitutions seems mandatory.

T:=[alpha0(t)=alpha, beta0(t)=beta,psi[1](t)=psi, theta[1](t)=theta, gamma0(t)=gamma]:

Indeed, when I launch your code with the subsitutions before not all the groups are created.

add(applyrule([cos(u::anything)*cos(v::anything)-sin(u::anything)*sin(v::anything)=cos(u+v), cos(u::anything)*sin(v::anything)+sin(u::anything)*cos(v::anything)=sin(u+v), sin(u::anything)*sin(v::anything)-cos(u::anything)*cos(v::anything)=-cos(u+v), -sin(v::anything)*cos(u::anything)-sin(u::anything)*cos(v::anything)=-sin(u+v)], simplify(coeff(lhs(eq_liaison[1]),i), size))*i, i={x0(t),xp[1](t),xb[1],yb[1],zb[1],l2[1],l3[1]});

May you explain why I need the subsitutions that you have defined in T variable ? 

Thank you for your help

@rlopez 

I use worksheets with
- Text region (created by T icon) for the text and comments,
- Maple Input (red prompts with lines which are computed).

The point is that I would like to include "typeset math" (equations, symbols but just for the symbols) in the text region so that my worksheet can be easier to read.

Thank you in advance for your ideas.

 

@Markiyan Hirnyk 

Exactly

@Kitonum 

OK Thank you.

For this calculation, there is a third way to my mind : Equate(X,A);

So, It seems that I can do all the operations of tilde operator with map, zip, equate functions.

As I'm not a big fan of using too much symbols in my code, I think that, for the moment, I will use the functions (map, zip, equate ) above which are more explicit for me.

 

 

Hello,

It is a new comment to revive this post.

Thanks a lot for your help.

4 5 6 7 8 9 10 Last Page 6 of 17