# DH matrix for the ABB IRB140 6DOF Robot
The dh paramters can be found in this [paper](https://ieeexplore.ieee.org/document/6907033/)

```python
%autosave 120
#Robot links lengths in meters
L0 = 70e-3
L1 = 352e-3
L2 = 360e-3
L3 = 254e-3
L4 = 126e-3
L5 = 65e-3
d = 0
```

    Autosaving every 120 seconds

```python
import sys
sys.path.append('../')
from dh import dh_solver
#create an object
irb140 = dh_solver()
```

```python
import sympy
from sympy import Symbol

#adding the dh parameters in this order [ d, theta, a, alpha]
irb140.add([L1    ,    Symbol("theta1")+sympy.pi/2,     L0,     sympy.pi/2   ])
irb140.add([0     ,    Symbol("theta2")+sympy.pi/2,     L2,     0            ])
irb140.add([0     ,    Symbol("theta3")           ,     0 ,     sympy.pi/2   ])
irb140.add([L3+L4 ,    Symbol("theta4")           ,     0 ,     -1*sympy.pi/2])
irb140.add([0     ,    Symbol("theta5")           ,     0 ,     sympy.pi/2   ])
irb140.add([L5+d  ,    Symbol("theta6")           ,     0 ,     0            ])

```

```python
#to get the dh matrices in symbolic form
T = irb140.calc_symbolic_matrices()
print(T)
```

    100%|██████████| 6/6 [00:00<00:00, 42.06it/s]

    Matrix([[((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*cos(theta6) + (-(((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*sin(theta6), -((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*sin(theta6)*cos(alpha6) + ((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*cos(alpha5) - (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5)*cos(theta5))*sin(alpha6) + (-(((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*cos(alpha6)*cos(theta6), ((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*sin(alpha6)*sin(theta6) + ((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*cos(alpha5) - (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5)*cos(theta5))*cos(alpha6) - (-(((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*sin(alpha6)*cos(theta6), a1*cos(theta1) - a2*sin(alpha2)*sin(theta1)*cos(alpha1) + a2*cos(theta1)*cos(theta2) + a3*(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + a3*(sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3) + a4*((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + a4*(-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4) + a5*(((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*cos(theta5) + a5*(-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5) + a6*((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*cos(theta6) + a6*(-(((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*sin(alpha6) + d2*sin(alpha1)*sin(theta1) + d3*(sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1)) + d4*((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3)) + d5*(((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4)) + d6*((((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*cos(theta4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(alpha4)*sin(theta4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*cos(alpha4) - (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*sin(alpha4)*cos(theta4))*cos(alpha5) - (-((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*cos(theta3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(theta3))*sin(theta4)*cos(alpha4) + ((-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(alpha3)*sin(theta3) - (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*sin(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*cos(alpha3))*sin(alpha4) + (-(-sin(theta1)*sin(theta2)*cos(alpha1) + cos(theta1)*cos(theta2))*sin(theta3)*cos(alpha3) + (sin(alpha1)*sin(alpha2)*sin(theta1) - sin(theta1)*cos(alpha1)*cos(alpha2)*cos(theta2) - sin(theta2)*cos(alpha2)*cos(theta1))*cos(alpha3)*cos(theta3) + (sin(alpha1)*sin(theta1)*cos(alpha2) + sin(alpha2)*sin(theta1)*cos(alpha1)*cos(theta2) + sin(alpha2)*sin(theta2)*cos(theta1))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5)*cos(theta5))], [((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*cos(theta6) + (-(((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*sin(theta6), -((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*sin(theta6)*cos(alpha6) + ((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*cos(alpha5) - (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5)*cos(theta5))*sin(alpha6) + (-(((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*cos(alpha6)*cos(theta6), ((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*sin(alpha6)*sin(theta6) + ((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*cos(alpha5) - (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5)*cos(theta5))*cos(alpha6) - (-(((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*sin(alpha6)*cos(theta6), a1*sin(alpha1) + a2*sin(alpha2)*cos(alpha1)*cos(theta1) + a2*sin(theta1)*cos(theta2) + a3*(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + a3*(-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3) + a4*((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + a4*(-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4) + a5*(((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*cos(theta5) + a5*(-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5) + a6*((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*cos(theta5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(theta5))*cos(theta6) + a6*(-(((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*sin(alpha5) + (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*cos(alpha5)*cos(theta5))*sin(alpha6) - d2*sin(alpha1)*cos(theta1) + d3*(-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2)) + d4*((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3)) + d5*(((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4)) + d6*((((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*cos(theta4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(alpha4)*sin(theta4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*cos(alpha4) - (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*sin(alpha4)*cos(theta4))*cos(alpha5) - (-((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*cos(theta3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(theta3))*sin(theta4)*cos(alpha4) + ((sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(alpha3)*sin(theta3) - (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*sin(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*cos(alpha3))*sin(alpha4) + (-(sin(theta1)*cos(theta2) + sin(theta2)*cos(alpha1)*cos(theta1))*sin(theta3)*cos(alpha3) + (-sin(alpha1)*sin(alpha2)*cos(theta1) - sin(theta1)*sin(theta2)*cos(alpha2) + cos(alpha1)*cos(alpha2)*cos(theta1)*cos(theta2))*cos(alpha3)*cos(theta3) + (-sin(alpha1)*cos(alpha2)*cos(theta1) + sin(alpha2)*sin(theta1)*sin(theta2) - sin(alpha2)*cos(alpha1)*cos(theta1)*cos(theta2))*sin(alpha3))*cos(alpha4)*cos(theta4))*sin(alpha5)*cos(theta5))], [((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*cos(theta5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(theta5))*cos(theta6) + (-(((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*sin(alpha5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*cos(alpha5)*cos(theta5))*sin(theta6), -((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*cos(theta5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(theta5))*sin(theta6)*cos(alpha6) + ((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*cos(alpha5) - (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(alpha5)*cos(theta5))*sin(alpha6) + (-(((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*sin(alpha5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*cos(alpha5)*cos(theta5))*cos(alpha6)*cos(theta6), ((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*cos(theta5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(theta5))*sin(alpha6)*sin(theta6) + ((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*cos(alpha5) - (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(alpha5)*cos(theta5))*cos(alpha6) - (-(((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*sin(alpha5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*cos(alpha5)*cos(theta5))*sin(alpha6)*cos(theta6), a2*sin(alpha1)*sin(alpha2) + a3*(sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3) + a3*sin(alpha1)*sin(theta2)*cos(theta3) + a4*((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + a4*((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4) + a5*(((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*cos(theta5) + a5*(-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(alpha5) + a6*((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*cos(theta5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(theta5))*cos(theta6) + a6*(-(((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(theta5)*cos(alpha5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*sin(alpha5) + (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*cos(alpha5)*cos(theta5))*sin(alpha6) + d1 + d2*cos(alpha1) + d3*(-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2)) + d4*((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3)) + d5*(((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4)) + d6*((((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(theta4))*sin(alpha5)*sin(theta5) + (((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(alpha4)*sin(theta4) - ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*sin(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*cos(alpha4))*cos(alpha5) - (-((sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(theta3) + sin(alpha1)*sin(theta2)*cos(theta3))*sin(theta4)*cos(alpha4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*sin(alpha3) + (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*cos(alpha3)*cos(theta3) - sin(alpha1)*sin(theta2)*sin(theta3)*cos(alpha3))*cos(alpha4)*cos(theta4) + ((-sin(alpha1)*sin(alpha2)*cos(theta2) + cos(alpha1)*cos(alpha2))*cos(alpha3) - (sin(alpha1)*cos(alpha2)*cos(theta2) + sin(alpha2)*cos(alpha1))*sin(alpha3)*cos(theta3) + sin(alpha1)*sin(alpha3)*sin(theta2)*sin(theta3))*sin(alpha4))*sin(alpha5)*cos(theta5))], [0, 0, 0, 1]])

```python
irb140.T_list
```

    [Matrix([
     [cos(theta1), -sin(theta1)*cos(alpha1),  sin(alpha1)*sin(theta1), a1*cos(theta1)],
     [sin(theta1),  cos(alpha1)*cos(theta1), -sin(alpha1)*cos(theta1), a1*sin(alpha1)],
     [          0,              sin(alpha1),              cos(alpha1),             d1],
     [          0,                        0,                        0,              1]]),
     Matrix([
     [cos(theta2), -sin(theta2)*cos(alpha2),  sin(alpha2)*sin(theta2), a2*cos(theta2)],
     [sin(theta2),  cos(alpha2)*cos(theta2), -sin(alpha2)*cos(theta2), a2*sin(alpha2)],
     [          0,              sin(alpha2),              cos(alpha2),             d2],
     [          0,                        0,                        0,              1]]),
     Matrix([
     [cos(theta3), -sin(theta3)*cos(alpha3),  sin(alpha3)*sin(theta3), a3*cos(theta3)],
     [sin(theta3),  cos(alpha3)*cos(theta3), -sin(alpha3)*cos(theta3), a3*sin(alpha3)],
     [          0,              sin(alpha3),              cos(alpha3),             d3],
     [          0,                        0,                        0,              1]]),
     Matrix([
     [cos(theta4), -sin(theta4)*cos(alpha4),  sin(alpha4)*sin(theta4), a4*cos(theta4)],
     [sin(theta4),  cos(alpha4)*cos(theta4), -sin(alpha4)*cos(theta4), a4*sin(alpha4)],
     [          0,              sin(alpha4),              cos(alpha4),             d4],
     [          0,                        0,                        0,              1]]),
     Matrix([
     [cos(theta5), -sin(theta5)*cos(alpha5),  sin(alpha5)*sin(theta5), a5*cos(theta5)],
     [sin(theta5),  cos(alpha5)*cos(theta5), -sin(alpha5)*cos(theta5), a5*sin(alpha5)],
     [          0,              sin(alpha5),              cos(alpha5),             d5],
     [          0,                        0,                        0,              1]]),
     Matrix([
     [cos(theta6), -sin(theta6)*cos(alpha6),  sin(alpha6)*sin(theta6), a6*cos(theta6)],
     [sin(theta6),  cos(alpha6)*cos(theta6), -sin(alpha6)*cos(theta6), a6*sin(alpha6)],
     [          0,              sin(alpha6),              cos(alpha6),             d6],
     [          0,                        0,                        0,              1]])]

```python
T1 = irb140.calc_dh_matrix()
print(T1)
```

    100%|██████████| 6/6 [00:00<00:00, 2415.84it/s]
    100%|██████████| 6/6 [00:01<00:00,  3.54it/s]

    Matrix([[(((sin(theta1)*sin(theta2)*cos(theta3) + sin(theta1)*sin(theta3)*cos(theta2))*cos(theta4) + sin(theta4)*cos(theta1))*cos(theta5) + (-sin(theta1)*sin(theta2)*sin(theta3) + sin(theta1)*cos(theta2)*cos(theta3))*sin(theta5))*cos(theta6) + (-(sin(theta1)*sin(theta2)*cos(theta3) + sin(theta1)*sin(theta3)*cos(theta2))*sin(theta4) + cos(theta1)*cos(theta4))*sin(theta6), -(((sin(theta1)*sin(theta2)*cos(theta3) + sin(theta1)*sin(theta3)*cos(theta2))*cos(theta4) + sin(theta4)*cos(theta1))*cos(theta5) + (-sin(theta1)*sin(theta2)*sin(theta3) + sin(theta1)*cos(theta2)*cos(theta3))*sin(theta5))*sin(theta6) + (-(sin(theta1)*sin(theta2)*cos(theta3) + sin(theta1)*sin(theta3)*cos(theta2))*sin(theta4) + cos(theta1)*cos(theta4))*cos(theta6), ((sin(theta1)*sin(theta2)*cos(theta3) + sin(theta1)*sin(theta3)*cos(theta2))*cos(theta4) + sin(theta4)*cos(theta1))*sin(theta5) - (-sin(theta1)*sin(theta2)*sin(theta3) + sin(theta1)*cos(theta2)*cos(theta3))*cos(theta5), 0.065*((sin(theta1)*sin(theta2)*cos(theta3) + sin(theta1)*sin(theta3)*cos(theta2))*cos(theta4) + sin(theta4)*cos(theta1))*sin(theta5) - 0.065*(-sin(theta1)*sin(theta2)*sin(theta3) + sin(theta1)*cos(theta2)*cos(theta3))*cos(theta5) + 0.38*sin(theta1)*sin(theta2)*sin(theta3) + 0.36*sin(theta1)*sin(theta2) - 0.38*sin(theta1)*cos(theta2)*cos(theta3) - 0.07*sin(theta1)], [(((-sin(theta2)*cos(theta1)*cos(theta3) - sin(theta3)*cos(theta1)*cos(theta2))*cos(theta4) + sin(theta1)*sin(theta4))*cos(theta5) + (sin(theta2)*sin(theta3)*cos(theta1) - cos(theta1)*cos(theta2)*cos(theta3))*sin(theta5))*cos(theta6) + (-(-sin(theta2)*cos(theta1)*cos(theta3) - sin(theta3)*cos(theta1)*cos(theta2))*sin(theta4) + sin(theta1)*cos(theta4))*sin(theta6), -(((-sin(theta2)*cos(theta1)*cos(theta3) - sin(theta3)*cos(theta1)*cos(theta2))*cos(theta4) + sin(theta1)*sin(theta4))*cos(theta5) + (sin(theta2)*sin(theta3)*cos(theta1) - cos(theta1)*cos(theta2)*cos(theta3))*sin(theta5))*sin(theta6) + (-(-sin(theta2)*cos(theta1)*cos(theta3) - sin(theta3)*cos(theta1)*cos(theta2))*sin(theta4) + sin(theta1)*cos(theta4))*cos(theta6), ((-sin(theta2)*cos(theta1)*cos(theta3) - sin(theta3)*cos(theta1)*cos(theta2))*cos(theta4) + sin(theta1)*sin(theta4))*sin(theta5) - (sin(theta2)*sin(theta3)*cos(theta1) - cos(theta1)*cos(theta2)*cos(theta3))*cos(theta5), 0.065*((-sin(theta2)*cos(theta1)*cos(theta3) - sin(theta3)*cos(theta1)*cos(theta2))*cos(theta4) + sin(theta1)*sin(theta4))*sin(theta5) - 0.065*(sin(theta2)*sin(theta3)*cos(theta1) - cos(theta1)*cos(theta2)*cos(theta3))*cos(theta5) - 0.38*sin(theta2)*sin(theta3)*cos(theta1) - 0.36*sin(theta2)*cos(theta1) + 0.38*cos(theta1)*cos(theta2)*cos(theta3) + 0.07], [-(-sin(theta2)*sin(theta3) + cos(theta2)*cos(theta3))*sin(theta4)*sin(theta6) + ((-sin(theta2)*sin(theta3) + cos(theta2)*cos(theta3))*cos(theta4)*cos(theta5) + (-sin(theta2)*cos(theta3) - sin(theta3)*cos(theta2))*sin(theta5))*cos(theta6), -(-sin(theta2)*sin(theta3) + cos(theta2)*cos(theta3))*sin(theta4)*cos(theta6) - ((-sin(theta2)*sin(theta3) + cos(theta2)*cos(theta3))*cos(theta4)*cos(theta5) + (-sin(theta2)*cos(theta3) - sin(theta3)*cos(theta2))*sin(theta5))*sin(theta6), (-sin(theta2)*sin(theta3) + cos(theta2)*cos(theta3))*sin(theta5)*cos(theta4) - (-sin(theta2)*cos(theta3) - sin(theta3)*cos(theta2))*cos(theta5), 0.065*(-sin(theta2)*sin(theta3) + cos(theta2)*cos(theta3))*sin(theta5)*cos(theta4) - 0.065*(-sin(theta2)*cos(theta3) - sin(theta3)*cos(theta2))*cos(theta5) + 0.38*sin(theta2)*cos(theta3) + 0.38*sin(theta3)*cos(theta2) + 0.352], [0, 0, 0, 1]])

```python
T2 = sympy.simplify(T1)
print(T2)
```

    Matrix([[((sin(theta1)*sin(theta2 + theta3)*cos(theta4) + sin(theta4)*cos(theta1))*cos(theta5) + sin(theta1)*sin(theta5)*cos(theta2 + theta3))*cos(theta6) - (sin(theta1)*sin(theta4)*sin(theta2 + theta3) - cos(theta1)*cos(theta4))*sin(theta6), -((sin(theta1)*sin(theta2 + theta3)*cos(theta4) + sin(theta4)*cos(theta1))*cos(theta5) + sin(theta1)*sin(theta5)*cos(theta2 + theta3))*sin(theta6) - (sin(theta1)*sin(theta4)*sin(theta2 + theta3) - cos(theta1)*cos(theta4))*cos(theta6), (sin(theta1)*sin(theta2 + theta3)*cos(theta4) + sin(theta4)*cos(theta1))*sin(theta5) - sin(theta1)*cos(theta5)*cos(theta2 + theta3), 0.36*sin(theta1)*sin(theta2) + 0.065*sin(theta1)*sin(theta5)*sin(theta2 + theta3)*cos(theta4) - 0.065*sin(theta1)*cos(theta5)*cos(theta2 + theta3) - 0.38*sin(theta1)*cos(theta2 + theta3) - 0.07*sin(theta1) + 0.065*sin(theta4)*sin(theta5)*cos(theta1)], [((sin(theta1)*sin(theta4) - sin(theta2 + theta3)*cos(theta1)*cos(theta4))*cos(theta5) - sin(theta5)*cos(theta1)*cos(theta2 + theta3))*cos(theta6) + (sin(theta1)*cos(theta4) + sin(theta4)*sin(theta2 + theta3)*cos(theta1))*sin(theta6), ((-sin(theta1)*sin(theta4) + sin(theta2 + theta3)*cos(theta1)*cos(theta4))*cos(theta5) + sin(theta5)*cos(theta1)*cos(theta2 + theta3))*sin(theta6) + (sin(theta1)*cos(theta4) + sin(theta4)*sin(theta2 + theta3)*cos(theta1))*cos(theta6), (sin(theta1)*sin(theta4) - sin(theta2 + theta3)*cos(theta1)*cos(theta4))*sin(theta5) + cos(theta1)*cos(theta5)*cos(theta2 + theta3), 0.065*sin(theta1)*sin(theta4)*sin(theta5) - 0.36*sin(theta2)*cos(theta1) - 0.065*sin(theta5)*sin(theta2 + theta3)*cos(theta1)*cos(theta4) + 0.065*cos(theta1)*cos(theta5)*cos(theta2 + theta3) + 0.38*cos(theta1)*cos(theta2 + theta3) + 0.07], [-(sin(theta5)*sin(theta2 + theta3) - cos(theta4)*cos(theta5)*cos(theta2 + theta3))*cos(theta6) - sin(theta4)*sin(theta6)*cos(theta2 + theta3), (sin(theta5)*sin(theta2 + theta3) - cos(theta4)*cos(theta5)*cos(theta2 + theta3))*sin(theta6) - sin(theta4)*cos(theta6)*cos(theta2 + theta3), sin(theta5)*cos(theta4)*cos(theta2 + theta3) + sin(theta2 + theta3)*cos(theta5), 0.065*sin(theta5)*cos(theta4)*cos(theta2 + theta3) + 0.065*sin(theta2 + theta3)*cos(theta5) + 0.38*sin(theta2 + theta3) + 0.352], [0, 0, 0, 1]])

```python
from IPython.display import Latex
a = sympy.latex(T2)
Latex(a)
```

\left[\begin{matrix}\left(\left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{4} \right )} + \sin{\left (\theta_{4} \right )} \cos{\left (\theta_{1} \right )}\right) \cos{\left (\theta_{5} \right )} + \sin{\left (\theta_{1} \right )} \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )}\right) \cos{\left (\theta_{6} \right )} - \left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} - \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )}\right) \sin{\left (\theta_{6} \right )} & - \left(\left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{4} \right )} + \sin{\left (\theta_{4} \right )} \cos{\left (\theta_{1} \right )}\right) \cos{\left (\theta_{5} \right )} + \sin{\left (\theta_{1} \right )} \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )}\right) \sin{\left (\theta_{6} \right )} - \left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} - \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )}\right) \cos{\left (\theta_{6} \right )} & \left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{4} \right )} + \sin{\left (\theta_{4} \right )} \cos{\left (\theta_{1} \right )}\right) \sin{\left (\theta_{5} \right )} - \sin{\left (\theta_{1} \right )} \cos{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} & 0.36 \sin{\left (\theta_{1} \right )} \sin{\left (\theta_{2} \right )} + 0.065 \sin{\left (\theta_{1} \right )} \sin{\left (\theta_{5} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{4} \right )} - 0.065 \sin{\left (\theta_{1} \right )} \cos{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} - 0.38 \sin{\left (\theta_{1} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} - 0.07 \sin{\left (\theta_{1} \right )} + 0.065 \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{1} \right )}\\\left(\left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{4} \right )} - \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )}\right) \cos{\left (\theta_{5} \right )} - \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )}\right) \cos{\left (\theta_{6} \right )} + \left(\sin{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )} + \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{1} \right )}\right) \sin{\left (\theta_{6} \right )} & \left(\left(- \sin{\left (\theta_{1} \right )} \sin{\left (\theta_{4} \right )} + \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )}\right) \cos{\left (\theta_{5} \right )} + \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )}\right) \sin{\left (\theta_{6} \right )} + \left(\sin{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )} + \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{1} \right )}\right) \cos{\left (\theta_{6} \right )} & \left(\sin{\left (\theta_{1} \right )} \sin{\left (\theta_{4} \right )} - \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )}\right) \sin{\left (\theta_{5} \right )} + \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} & 0.065 \sin{\left (\theta_{1} \right )} \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{5} \right )} - 0.36 \sin{\left (\theta_{2} \right )} \cos{\left (\theta_{1} \right )} - 0.065 \sin{\left (\theta_{5} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{4} \right )} + 0.065 \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} + 0.38 \cos{\left (\theta_{1} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} + 0.07\\- \left(\sin{\left (\theta_{5} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} - \cos{\left (\theta_{4} \right )} \cos{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )}\right) \cos{\left (\theta_{6} \right )} - \sin{\left (\theta_{4} \right )} \sin{\left (\theta_{6} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} & \left(\sin{\left (\theta_{5} \right )} \sin{\left (\theta_{2} + \theta_{3} \right )} - \cos{\left (\theta_{4} \right )} \cos{\left (\theta_{5} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )}\right) \sin{\left (\theta_{6} \right )} - \sin{\left (\theta_{4} \right )} \cos{\left (\theta_{6} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} & \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{4} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} + \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{5} \right )} & 0.065 \sin{\left (\theta_{5} \right )} \cos{\left (\theta_{4} \right )} \cos{\left (\theta_{2} + \theta_{3} \right )} + 0.065 \sin{\left (\theta_{2} + \theta_{3} \right )} \cos{\left (\theta_{5} \right )} + 0.38 \sin{\left (\theta_{2} + \theta_{3} \right )} + 0.352\\0 & 0 & 0 & 1\end{matrix}\right]

```python
#makes it easier to copy and paste by each element alone
for i in range(4):
    for j in range(4):
        print("( {} , {} )".format(i,j))
        print(T2[i,j])
```

    ( 0 , 0 )
    ((sin(theta1)*sin(theta2 + theta3)*cos(theta4) + sin(theta4)*cos(theta1))*cos(theta5) + sin(theta1)*sin(theta5)*cos(theta2 + theta3))*cos(theta6) - (sin(theta1)*sin(theta4)*sin(theta2 + theta3) - cos(theta1)*cos(theta4))*sin(theta6)
    ( 0 , 1 )
    -((sin(theta1)*sin(theta2 + theta3)*cos(theta4) + sin(theta4)*cos(theta1))*cos(theta5) + sin(theta1)*sin(theta5)*cos(theta2 + theta3))*sin(theta6) - (sin(theta1)*sin(theta4)*sin(theta2 + theta3) - cos(theta1)*cos(theta4))*cos(theta6)
    ( 0 , 2 )
    (sin(theta1)*sin(theta2 + theta3)*cos(theta4) + sin(theta4)*cos(theta1))*sin(theta5) - sin(theta1)*cos(theta5)*cos(theta2 + theta3)
    ( 0 , 3 )
    0.36*sin(theta1)*sin(theta2) + 0.065*sin(theta1)*sin(theta5)*sin(theta2 + theta3)*cos(theta4) - 0.065*sin(theta1)*cos(theta5)*cos(theta2 + theta3) - 0.38*sin(theta1)*cos(theta2 + theta3) - 0.07*sin(theta1) + 0.065*sin(theta4)*sin(theta5)*cos(theta1)
    ( 1 , 0 )
    ((sin(theta1)*sin(theta4) - sin(theta2 + theta3)*cos(theta1)*cos(theta4))*cos(theta5) - sin(theta5)*cos(theta1)*cos(theta2 + theta3))*cos(theta6) + (sin(theta1)*cos(theta4) + sin(theta4)*sin(theta2 + theta3)*cos(theta1))*sin(theta6)
    ( 1 , 1 )
    ((-sin(theta1)*sin(theta4) + sin(theta2 + theta3)*cos(theta1)*cos(theta4))*cos(theta5) + sin(theta5)*cos(theta1)*cos(theta2 + theta3))*sin(theta6) + (sin(theta1)*cos(theta4) + sin(theta4)*sin(theta2 + theta3)*cos(theta1))*cos(theta6)
    ( 1 , 2 )
    (sin(theta1)*sin(theta4) - sin(theta2 + theta3)*cos(theta1)*cos(theta4))*sin(theta5) + cos(theta1)*cos(theta5)*cos(theta2 + theta3)
    ( 1 , 3 )
    0.065*sin(theta1)*sin(theta4)*sin(theta5) - 0.36*sin(theta2)*cos(theta1) - 0.065*sin(theta5)*sin(theta2 + theta3)*cos(theta1)*cos(theta4) + 0.065*cos(theta1)*cos(theta5)*cos(theta2 + theta3) + 0.38*cos(theta1)*cos(theta2 + theta3) + 0.07
    ( 2 , 0 )
    -(sin(theta5)*sin(theta2 + theta3) - cos(theta4)*cos(theta5)*cos(theta2 + theta3))*cos(theta6) - sin(theta4)*sin(theta6)*cos(theta2 + theta3)
    ( 2 , 1 )
    (sin(theta5)*sin(theta2 + theta3) - cos(theta4)*cos(theta5)*cos(theta2 + theta3))*sin(theta6) - sin(theta4)*cos(theta6)*cos(theta2 + theta3)
    ( 2 , 2 )
    sin(theta5)*cos(theta4)*cos(theta2 + theta3) + sin(theta2 + theta3)*cos(theta5)
    ( 2 , 3 )
    0.065*sin(theta5)*cos(theta4)*cos(theta2 + theta3) + 0.065*sin(theta2 + theta3)*cos(theta5) + 0.38*sin(theta2 + theta3) + 0.352
    ( 3 , 0 )
    0
    ( 3 , 1 )
    0
    ( 3 , 2 )
    0
    ( 3 , 3 )
    1

```python

```