## 2 Materials and Methods
### Computational Efficiency Improvements  
The following improvements were implemented to enhance the computational efficiency of the model:  
1. Since the model is applied to slow movements in rehabilitation exercises, the inertial forces are considered negligible compared to gravitational and external ones. Therefore, we assume a quasi-static model that does not depend on velocities and accelerations. As a result, the equation of motion expressed by Equation (1) can be represented by the following simple equation: \[\overset{\rightarrow}{\tau}_{Mus}=-\left(\overset{\rightarrow}{\tau}_{G}+ \overset{\rightarrow}{\tau}_{Ext}\right)\] (2)  
The generalized forces that correspond to weight and external forces, respectively, simply are:  
\[\tau_{G}=J_{G_{Fam}}^{T}\overset{\rightarrow}{W}_{Fem}^{T}+J_{G_{Th}}^{T} \overset{\rightarrow}{W}_{Tib}^{T}+J_{G_{Fact}}^{T}\overset{\rightarrow}{W} _{Foot}^{T} \tag{3}\]  
and:  
\[\tau_{Ext}=J_{P_{Ext}}^{T}\overset{\rightarrow}{F}_{Ext}+J_{\omega_{Fact}}^{T }\overset{\rightarrow}{M}_{Ext} \tag{4}\]  
where \(J_{G_{Fam}}^{T}\), \(J_{G_{Th}}^{T}\), \(J_{G_{Fact}}^{T}\), \(J_{P_{Ext}}^{T}\) and \(J_{\omega_{Fact}}^{T}\) are the Jacobian matrices relating the generalized coordinates to the gravitational forces of the femur \(\overset{\rightarrow}{W}_{Fem}\), tibia \(\overset{\rightarrow}{W}_{Tib}\), the foot \(\overset{\rightarrow}{W}_{Foot}\), the external force \(\overset{\rightarrow}{F}_{Ext}\), and moment \(\overset{\rightarrow}{M}_{Ext}\), respectively. 2. We solve the redundancy problem by minimizing the squared sum of muscle stress. Therefore, the associated optimization procedure has a direct analytical solution by using Lagrange multipliers [2]. Thus, Equation (2) can be rewritten as follows: \[-\left(\tau_{G}+\tau_{Ext}\right)=\tau_{Mus}=C_{1}F_{1}+C_{2}F_{2}+\cdots+C_{n}F _{n}\] (5)where, \(F_{i}\) represents the \(i\)-th muscle force, and \(C_{i}\) its coefficient or its contribution to the generalized force, which is calculated using the direct Jacobian transformation. The result of the optimization process is equivalent to Equation (6), extracted using Lagrange multipliers  
\[F_{i}=\frac{A_{i}^{2}C_{i}\tau_{Mus}}{\sum_{j=1}^{n}\left(A_{j}C_{j}\right)^{2}} \tag{6}\]  
where \(A_{i}\) represents the \(i\)-th muscle cross-sectional area as measured in [14]. It appeared here as a result of minimizing the squared sum of muscle stresses, as mentioned previously. Hence, the optimization process can be omitted from the formulation of the dynamic model. 3. The calculation of the muscle's coefficients \(C_{i}\)--or moment arms--is a computationally high-cost procedure. This issue arises due to the number of muscles under consideration, their modeling, insertion points, and the corresponding Jacobian calculations. Fortunately, these coefficients are exclusively dependent on bone geometry and the current position. Therefore, they can be calculated in an offline process for all the possible combinations of the generalized coordinates in the dynamic system [2]. In this way, the muscle force calculation in the online stage is carried out directly using Equation (6) from the corresponding generalized muscle force value. 4. The number of combinations associated with 5 DOF is too large. For example, for the squat exercise and assuming a discretization with a step of 1% of the range of each of the generalized coordinates, 3.2 \(\times\) 10\({}^{11}\) possible combinations are obtained. However, this number can be drastically decreased by assuming a reduced number of functional degrees of freedom. Indeed, due to motor coordination, generalized variables do not change independently in repetitive movements. As a result, the number of independent parameters needed to describe this motion is lower than the total number of generalized coordinates. These independent parameters are called functional degrees of freedom (fDOF) [38].