How to force Matlab to be consistent with trigonometric expressions

1 vue (au cours des 30 derniers jours)
Bandar
Bandar le 24 Avr 2022
I have two symbolic matrices. They are identical, but the simplifications of their trigonometric expressions are not. Therefore, the appearance of the outcome is not similar in latex format. Matlab shortens one matrix for some reason but leaves extended expressions for the other. The following script illustrates this problem. The simplify() is not providing a consistent outcome. I've checked the equality of the two matrices by using isAlways() and numerical substitutions. I'm not sure if my question is a tall order, but how can Matlab be consistent with the outcome?
clear
clc
syms a1 a2 a3 a4 a5 a6 a7 L1 L2 L3 W1
M = [ 1, 0, 0, 0;
0, 1, 0, 0;
0, 0, 1, (L1+L2+L3);
0, 0, 0, 1];
es1 =[
cos(a1), -sin(a1), 0, 0;
sin(a1), cos(a1), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
es2 =[
cos(a2), 0, sin(a2), 0;
0, 1, 0, 0;
-sin(a2), 0, cos(a2), 0;
0, 0, 0, 1];
es3 =[
cos(a3), -sin(a3), 0, 0;
sin(a3), cos(a3), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
es4 = [
cos(a4), 0, sin(a4), - L1*sin(a4) - W1*(cos(a4) - 1);
0, 1, 0, 0;
-sin(a4), 0, cos(a4), W1*sin(a4) - L1*(cos(a4) - 1);
0, 0, 0, 1];
es5 =[
cos(a5), -sin(a5), 0, 0;
sin(a5), cos(a5), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
es6 =[
cos(a6), 0, sin(a6), -sin(a6)*(L1 + L2);
0, 1, 0, 0;
-sin(a6), 0, cos(a6), -(cos(a6) - 1)*(L1 + L2);
0, 0, 0, 1];
es7 =[
cos(a7), -sin(a7), 0, 0;
sin(a7), cos(a7), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
Tsb1=simplify(es1*es2*es3*es4*es5*es6*es7*M),
Tsb1 = 
latex(Tsb1)
ans = '\left(\begin{array}{cccc} -\sin\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\cos\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right) & \sin\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right)-\cos\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right) & -\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right) & \left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)\,\left(L_{1}\,\sin\left(a_{4}\right)+W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)-\left(\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right)\,\left(L_{1}+L_{2}+L_{3}\right)+\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)\,\left(L_{1}+L_{2}\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(W_{1}\,\sin\left(a_{4}\right)-L_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)+\left(\cos\left(a_{6}\right)-1\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\,\left(L_{1}+L_{2}\right)\\ \sin\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right) & \cos\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right) & \sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right) & \left(\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right)\,\left(L_{1}+L_{2}+L_{3}\right)-\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)\,\left(L_{1}\,\sin\left(a_{4}\right)+W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)\,\left(L_{1}+L_{2}\right)+\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(W_{1}\,\sin\left(a_{4}\right)-L_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)-\left(\cos\left(a_{6}\right)-1\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\,\left(L_{1}+L_{2}\right)\\ \sin\left(a_{7}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)+\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\cos\left(a_{7}\right)\,\left(\sin\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)+\cos\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\right) & \sin\left(a_{7}\right)\,\left(\sin\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)+\cos\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\right)+\cos\left(a_{7}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)+\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\right) & \cos\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)-\sin\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right) & L_{1}\,\cos\left(a_{2}\right)+L_{2}\,\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-W_{1}\,\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)+W_{1}\,\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+W_{1}\,\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)-L_{2}\,\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)+L_{3}\,\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)\,\cos\left(a_{6}\right)-L_{3}\,\cos\left(a_{3}\right)\,\cos\left(a_{6}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)-L_{3}\,\cos\left(a_{2}\right)\,\cos\left(a_{5}\right)\,\sin\left(a_{4}\right)\,\sin\left(a_{6}\right)+L_{3}\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\,\sin\left(a_{6}\right)-L_{3}\,\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{6}\right)\\ 0 & 0 & 0 & 1 \end{array}\right)'
eb1 =[
cos(a1), -sin(a1), 0, 0;
sin(a1), cos(a1), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
eb2 =[
cos(a2), 0, sin(a2), sin(a2)*(L1 + L2 + L3);
0, 1, 0, 0;
-sin(a2), 0, cos(a2), (cos(a2) - 1)*(L1 + L2 + L3);
0, 0, 0, 1];
eb3 =[
cos(a3), -sin(a3), 0, 0;
sin(a3), cos(a3), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
eb4 =[
cos(a4), 0, sin(a4), sin(a4)*(L2 + L3) - W1*(cos(a4) - 1);
0, 1, 0, 0;
-sin(a4), 0, cos(a4), (cos(a4) - 1)*(L2 + L3) + W1*sin(a4);
0, 0, 0, 1];
eb5 =[
cos(a5), -sin(a5), 0, 0;
sin(a5), cos(a5), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
eb6 =[
cos(a6), 0, sin(a6), L3*sin(a6);
0, 1, 0, 0;
-sin(a6), 0, cos(a6), L3*(cos(a6) - 1);
0, 0, 0, 1];
eb7 =[
cos(a7), -sin(a7), 0, 0;
sin(a7), cos(a7), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
Tsb2=simplify(M*eb1*eb2*eb3*eb4*eb5*eb6*eb7),
Tsb2 = 
latex(Tsb2)
ans = '\left(\begin{array}{cccc} -\sin\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\cos\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right) & \sin\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right)-\cos\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right) & -\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right) & \cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(L_{1}+L_{2}+L_{3}\right)-L_{3}\,\left(\cos\left(a_{6}\right)-1\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)\,\left(\sin\left(a_{4}\right)\,\left(L_{2}+L_{3}\right)-W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(\left(\cos\left(a_{4}\right)-1\right)\,\left(L_{2}+L_{3}\right)+W_{1}\,\sin\left(a_{4}\right)\right)-L_{3}\,\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)\\ \sin\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right) & \cos\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right) & \sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right) & \left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)\,\left(\sin\left(a_{4}\right)\,\left(L_{2}+L_{3}\right)-W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)+L_{3}\,\left(\cos\left(a_{6}\right)-1\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)+\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(L_{1}+L_{2}+L_{3}\right)+\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(\left(\cos\left(a_{4}\right)-1\right)\,\left(L_{2}+L_{3}\right)+W_{1}\,\sin\left(a_{4}\right)\right)+L_{3}\,\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)\\ \sin\left(a_{7}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)+\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\cos\left(a_{7}\right)\,\left(\sin\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)+\cos\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\right) & \sin\left(a_{7}\right)\,\left(\sin\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)+\cos\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\right)+\cos\left(a_{7}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)+\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\right) & \cos\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)-\sin\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right) & L_{1}+L_{2}+L_{3}+\cos\left(a_{2}\right)\,\left(\left(\cos\left(a_{4}\right)-1\right)\,\left(L_{2}+L_{3}\right)+W_{1}\,\sin\left(a_{4}\right)\right)+\left(\cos\left(a_{2}\right)-1\right)\,\left(L_{1}+L_{2}+L_{3}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\left(\sin\left(a_{4}\right)\,\left(L_{2}+L_{3}\right)-W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)+L_{3}\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\,\left(\cos\left(a_{6}\right)-1\right)-L_{3}\,\sin\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\\ 0 & 0 & 0 & 1 \end{array}\right)'
isAlways(Tsb1 == Tsb2)
ans = 4×4 logical array
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Réponses (1)

Sachin Lodhi
Sachin Lodhi le 20 Déc 2023
Hi Bandar,
For this problem, where you need consistent simplification across two symbolic matrices that are equivalent and contain trigonometric expressions, I recommend using the ‘simplifyFraction’ function for both expressions.
Here's how you can apply it to your matrices:
Tsb1 = simplifyFraction(es1*es2*es3*es4*es5*es6*es7*M);
Tsb2 = simplifyFraction(M*eb1*eb2*eb3*eb4*eb5*eb6*eb7);
By applying ‘simplifyFraction’ to both ‘Tsb1’ and ‘Tsb2’, you can obtain a more uniform simplification, which will be reflected in the LaTeX formatted output.
Please refer to the following MATLAB documentation page for more information on ‘simplifyFraction’ function : https://www.mathworks.com/help/symbolic/sym.simplifyfraction.html
I hope this helps.
Best Regards,
Sachin

Tags

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by