Bendesarts

345 Reputation

10 Badges

9 years, 359 days

MaplePrimes Activity


These are replies submitted by Bendesarts

@Markiyan Hirnyk 

1) where is located (which folder ?) the package that I use the save function  ? save(NamePackage,cat(libname[1],"/NamePackage.mla"); 

2) After having used the save function, is the custom package always present in the libname ? If I want to remove it, how can I do it ?

3) When I launch the save function, I receive this mistake :

 

 

Do you have some ideas about this error ? How can I correct it ?

@Markiyan Hirnyk 

Thanks a lot for your help.

So the steps I'm planning to do are the following :

0) Adding at the begin of my worksheet the call of the package LibrariesTools

with(LibraryTools):

1) wrapping my procedures in a table so as to create the package

NamePackage:=table();
NamePackage[NameProcedure1]:= proc(...)
end proc:

2) saving the package, locating them with the other packages

save(NamePackage,cat(libname[1],"/NamePackage.mla");

--> For this step, I have 2 questions : where is located the package that I have save ? Can I see it in the Maple folder with windows explorer ?

--> After having used the save function, is the custom package always present in the libname ? If I want to remove it, how can I do it ?

3) Calling the package in a worksheet

with(NamePackage);

May you have a look to my questions? and let me know if you thing that I have forgotten something important.

Thanks a lot for your help

Thank you for your feedback.

But, is it possible to convert in a easy way your worksheet with components to a worksheet with classic maple input ?

 

Hello,

I find your application very interesting. But, is it possible to obtain this worksheet with only classic maple input ? In fact, I prefer using classic maple input so as to see more clearly the code.

Thank you.

@Kitonum 

Here my attempt to make a procedure to automatize the simplification of this kind of trigonometric equation :

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

Initialisation
restart:
with(LinearAlgebra):
with(Student[MultivariateCalculus]):
with(plots):
with(MathML):
with(ListTools):
constants:= ({constants} minus {gamma})[]:
`evalf/gamma`:= proc() end proc:
`evalf/constant/gamma`:= proc() end proc:
unprotect(gamma);
Angular Constraint equations
eq_liaison:=sin(gamma0(t))*cos(beta0(t)) = -(sin(gamma[1](t))*sin(psi[1](t))*sin(theta[1](t))-sin(gamma[1](t))*cos(theta[1](t))*cos(psi[1](t))+cos(gamma[1](t))*sin(psi[1](t))*cos(theta[1](t))+cos(gamma[1](t))*cos(psi[1](t))*sin(theta[1](t)))*cos(beta[1](t)); 
Traitement
TrigoTransform2:= proc(Eq)
local S,S1,tt,pp,Eq2,ListVariables,ListVariablesMod,Subs,size,rhsEq2,lhsEq2;
#Construit une liste à plat#
ListVariables:=indets(Eq, function(identical(t)));
ListVariables:=[op(ListVariables)];
ListVariablesMod:=map(f->cat(op(0,f),_),ListVariables);
Subs:=ListVariables=~ListVariablesMod;
#Variables Changement#
Eq2:=Eq:
print("Equation traitée=",Eq2): 
Eq2:=subs(Subs, Eq2);
print("Equation après subs=",Eq2): 
#Trigonometric transformations#
lhsEq2:=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(lhs(Eq2), size));
print("Equation lhsEq2 première analyse=",lhsEq2):
rhsEq2:=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(rhs(Eq2), size));
print("Equation rhsEq2 première analyse=",rhsEq2):
try
lhsEq2:=(trigsubs(2*combine(lhsEq2))[])/2;
print("Equation lhsEq2=",lhsEq2):
catch:
lhsEq2:=lhs(Eq2);
end try;
try
rhsEq2:=(trigsubs(-2*combine(rhsEq2))[])/2;
print("Equation rhsEq2=",rhsEq2):
catch:
rhsEq2:=rhs(Eq2);
end try;
Eq2:= lhsEq2=rhsEq2;
#Variables Changement#
Eq2:=subs(map(t->rhs(t)=lhs(t),Subs),Eq2) 
end proc:
TrigoTransform2(eq_liaison);

Strangely, I noticed that the simplification is done only if there is a minus before the combine function. The simplification works but the result is wrong because i didn't obtain the good sign.

Can you help me to correct this point ? and to make the code more general so as to make this simplification in a automatic way ?

Thanks a lot for your help.

Here my attempt to make a procedure to automatize the simplification of this kind of trigonometric equation :

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

Initialisation
restart:
with(LinearAlgebra):
with(Student[MultivariateCalculus]):
with(plots):
with(MathML):
with(ListTools):
constants:= ({constants} minus {gamma})[]:
`evalf/gamma`:= proc() end proc:
`evalf/constant/gamma`:= proc() end proc:
unprotect(gamma);
Angular Constraint equations
eq_liaison:=sin(gamma0(t))*cos(beta0(t)) = -(sin(gamma[1](t))*sin(psi[1](t))*sin(theta[1](t))-sin(gamma[1](t))*cos(theta[1](t))*cos(psi[1](t))+cos(gamma[1](t))*sin(psi[1](t))*cos(theta[1](t))+cos(gamma[1](t))*cos(psi[1](t))*sin(theta[1](t)))*cos(beta[1](t));
Traitement
TrigoTransform2:= proc(Eq)
local S,S1,tt,pp,Eq2,ListVariables,ListVariablesMod,Subs,size,rhsEq2,lhsEq2;
#Construit une liste à plat#
ListVariables:=indets(Eq, function(identical(t)));
ListVariables:=[op(ListVariables)];
ListVariablesMod:=map(f->cat(op(0,f),_),ListVariables);
Subs:=ListVariables=~ListVariablesMod;
#Variables Changement#
Eq2:=Eq:
print("Equation traitée=",Eq2):
Eq2:=subs(Subs, Eq2);
print("Equation après subs=",Eq2):
#Trigonometric transformations#
lhsEq2:=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(lhs(Eq2), size));
print("Equation lhsEq2 première analyse=",lhsEq2):
rhsEq2:=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(rhs(Eq2), size));
print("Equation rhsEq2 première analyse=",rhsEq2):
try
lhsEq2:=(trigsubs(2*combine(lhsEq2))[])/2;
print("Equation lhsEq2=",lhsEq2):
catch:
lhsEq2:=lhs(Eq2);
end try;
try
rhsEq2:=(trigsubs(-2*combine(rhsEq2))[])/2;
print("Equation rhsEq2=",rhsEq2):
catch:
rhsEq2:=rhs(Eq2);
end try;
Eq2:= lhsEq2=rhsEq2;
#Variables Changement#
Eq2:=subs(map(t->rhs(t)=lhs(t),Subs),Eq2)
end proc:
TrigoTransform2(eq_liaison);

Strangely, I noticed that the simplification is done only if there is a minus before the combine function. The simplification works but the result is wrong because i didn't obtain the good sign.

Can you help me to correct this point ? and to make the code more general so as to make this simplification in a automatic way ?

Thanks a lot for your help.

@Markiyan Hirnyk 

Great !

Perfect, it is exactly what I'm looking for, but I used a bad syntax before.

Thank you.

@Kitonum 

Thanks a lot for your help.

You answer to my need for my current mechanical problem.

However as I explain in the post :

http://www.mapleprimes.com/questions/209721-Simplification-Of-Trigonometric-Expressions

I often have to deal with :
- constraint equations for vectorial closure,
- constraint equations for angular closure.

Consequently, I'm really interested to make, as I can do with your help for the constraint equations for vectorial closure, also a procedure to simplify the constraint equations for angular closure with a more general way.

Can you help me to build this procedure ?

The idea is to build a general procedure so as to simplify the trigonometric equations that we can met when dealing mechanical constraint equations.

Thanks a lot for your help

@Kitonum 

Thanks a lot for your help

Here a small example to show what I try to make.

Jacobienne.mw

For the x axis, the labels are well written but not for the y axis.

@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 

3 4 5 6 7 8 9 Last Page 5 of 16