## 420 Reputation

11 years, 323 days

## @Kitonum Ouhhhhh !Thank you but the...

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(t))*cos(theta(t))*sin(gamma(t))-sin(psi(t))*sin(theta(t))*cos(gamma(t))+cos(theta(t))*cos(psi(t))*cos(gamma(t))+cos(psi(t))*sin(theta(t))*sin(gamma(t)))*cos(beta(t))

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

## @Kitonum  @vv  @Joe Riel ...

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;
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),
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(t))*cos(theta(t))*cos(gamma(t))+sin(psi(t))*sin(theta(t))*sin(gamma(t))-cos(theta(t))*cos(psi(t))*sin(gamma(t))+cos(psi(t))*sin(theta(t))*cos(gamma(t)))*cos(beta(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 goo...

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-sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))*zb-sin(alpha0(t))*cos(beta0(t))*yb+cos(alpha0(t))*sin(gamma0(t))*zb+cos(alpha0(t))*cos(gamma0(t))*xb-l2*(sin(psi(t))*sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))-cos(psi(t))*sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))+sin(psi(t))*cos(alpha0(t))*cos(gamma0(t))+cos(psi(t))*cos(alpha0(t))*sin(gamma0(t)))-l3*(sin(theta(t))*sin(psi(t))*sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))+sin(theta(t))*cos(psi(t))*sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))+cos(theta(t))*sin(psi(t))*sin(alpha0(t))*sin(gamma0(t))*sin(beta0(t))-cos(theta(t))*cos(psi(t))*sin(alpha0(t))*sin(beta0(t))*cos(gamma0(t))-sin(theta(t))*sin(psi(t))*cos(alpha0(t))*sin(gamma0(t))+sin(theta(t))*cos(psi(t))*cos(alpha0(t))*cos(gamma0(t))+cos(theta(t))*sin(psi(t))*cos(alpha0(t))*cos(gamma0(t))+cos(theta(t))*cos(psi(t))*cos(alpha0(t))*sin(gamma0(t)))-xp(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 youJust...

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;

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

Thank

## @Joe Riel  Thank you ! You perfectl...

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

## @Kitonum  Perfect! Thanks a lot for...

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;
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.

## @Kitonum  Thank you again for your ...

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(t),xb,yb,zb,l2,l3}

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.

## @vv  Thank you but it is possible t...

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

## @Kitonum  Perfect! Thank you. My on...

Perfect! Thank you.

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

## @Thomas Richard  Thank for your rem...

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)):
eq1:=subs(T, eq1);
eq2:=subs(T, eq2);
Phi:=subs(map(t->rhs(t)=lhs(t),T), Phi);

If you have better, let me know.

## @Kitonum  Great, you answer perfect...

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(t)=psi, theta(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),i), size))*i, i={x0(t),xp(t),xb,yb,zb,l2,l3});

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

## @rlopez  I use worksheets with- Tex...

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.

Exactly

## @Kitonum  OK Thank you. For this ca...

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 thi...

Hello,

It is a new comment to revive this post.

Thanks a lot for your help.

﻿