2
$\begingroup$

I would like to symbolically determine the rank of a jacobian matrix. In the help, I have seen that the MatrixRank function can be used for this purpose. However, when I use this function, the function doesn't allow to find the different singularities that can occur on my jacobian matrix.

Here a exemple of a jacobian matrix that I obtain on a slidercrank mechanism:

The constraints equations are :

SysCon = {x[t] == l1 Cos[θ[t]] + l2 Sin[β[t]], 
  0 == -l2 Cos[β[t]] + l1 Sin[θ[t]]}

The associated jacobian matrix is :

q = {β[t], x[t], θ[t]}

SysConExpr := SysCon /. lhs_ == rhs_ :> lhs - rhs

(ϕ = D[SysConExpr, {q}]) // MatrixForm

The rank of this jacobian (Phi) (with the MatrixRank function) gives 2 whatever the values of theta(t) and beta(t). However, if the values of theta(t) and beta(t) are :theta(t)=Pi/2,beta(t)=0. The rank shouldn't be 2 but 1.

Is a way to obtain the symbolic calculation of the rank of a jacobian matrix which can distinguish different cases following the values of the parameters ? In others words, my dream will be to have a MatrixRank function (or another algorithm) which can gives : the rank is 2 if theta(t) different of Pi/2 [Pi] and beta(t)=0 [Pi] and otherwise 1 if ... and perhaps 0 if ...

Another idea could be to have a algorithm which helps to give the higher determinants which are not null and analyze little by little all the determinants.

Of course, this example is simple but I will interested to find something general that I could apply on big matrix.

Thanks a lot for your help.

$\endgroup$
3
$\begingroup$

From Mathematica documentation

MatrixRank assumes all symbols to be independent

Thus, you need to delay the evaluation of MatrixRank till the Jacobian is fully expanded.

First, define the Jacobian as a function of t

ϕ[t_] = D[SysConExpr, {q}]

In case β[t], x[t], θ[t] are pre-defined functions, you can enforce the evaluation by

myRank[t_] := MatrixRank[Evaluate @ ϕ[t]]

In case β[t], x[t], θ[t] gets defined later, you can use Hold and ReleaseHold to work around this problem

myRank[t_] = MatrixRank[Hold @ Evaluate @ ϕ[t]]
myRank[t] /. {β[t] -> 0, θ[t] -> π/2} // ReleaseHold // FullSimplify 
$\endgroup$
  • $\begingroup$ I have a similar post,But no solution now. $\endgroup$ – yode Mar 28 '16 at 3:59
  • $\begingroup$ @yode, indeed you are right .. I don't know about a solution for this problem. My answer assumes that the goal is to use this rank on some actual calculation as the presented problem seems to be a solution of some ODE ... But to get a full symbolic solutions with conditional expression is a bit of my reach ... $\endgroup$ – Bichoy Mar 28 '16 at 4:25
0
$\begingroup$

I cannot say I really like the method I show below, but it's the best I have to offer at the moment.

First we set this up.

SysCon = {x[t] == l1 Cos[theta[t]] + l2 Sin[beta[t]], 
   0 == -l2 Cos[beta[t]] + l1 Sin[theta[t]]};
q = {beta[t], x[t], theta[t]};
SysConExpr := SysCon /. lhs_ == rhs_ :> lhs - rhs
phi = D[SysConExpr, {q}];

Augment with an identity matrix on the right, just as if we were computing the inverse in the schoolbook way. We will use the rightmost 2x2 to record the multipliers used in row reduction, and then use that information to deduce special values for which the rank might drop.

newmat = Join[phi, IdentityMatrix[2], 2]

(* Out[2358]= {{-l2 Cos[beta[t]], 1, l1 Sin[theta[t]], 1, 
  0}, {-l2 Sin[beta[t]], 0, -l1 Cos[theta[t]], 0, 1}} *)

Row reduce this and use the marker positions to indicate "bad" values", that is, check to see where they are undefined.

RowReduce[newmat]

(* Out[2359]= {{1, 0, (l1 Cos[theta[t]] Csc[beta[t]])/l2, 
  0, -(Csc[beta[t]]/l2)}, {0, 1, 
  l1 Cos[theta[t]] Cot[beta[t]] + l1 Sin[theta[t]], 1, -Cot[beta[t]]}} *)

We have to now check this in the case that beta[t] vanishes since that's the case where the above result fails.

RowReduce[newmat /. beta[t] -> 0]

(* Out[2360]= {{1, -(1/l2), 0, -(1/l2), -(Tan[theta[t]]/l2)}, {0, 0, 1, 
  0, -(Sec[theta[t]]/l1)}} *)

Rinse and repeat, this time with theta[t]=Pi/2 to make the tangent and secant blow up.

RowReduce[newmat /. {beta[t] -> 0, theta[t] -> Pi/2}]

(* Out[2361]= {{1, -(1/l2), -(l1/l2), -(1/l2), 0}, {0, 0, 0, 0, 1}} *)

Here the rank of phi, with the above substitutions, is clearly going to be 1.

I think this may have come up previously on MSE but I am not certain.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.