# Unable to find the determinant of a square matrix R despite being full rank

ClearAll["Global*"];
Clear[b]
(*This programis working for a frame which is connected at right \
angles*)

i = 1;
L = 1;
z1 = L/2;
Y = 2.06*10^11;
aa = 12.7*0.001;
bb = aa;
Iyy = (aa*bb^3)/12;
A = aa*bb;
a = Sqrt[Iyy/(A*L^2)];
\[Rho] = 7800;
\[Lambda] = a*b^2;
w1 = A1*Sin[b*x1] + B1*Cos[b*x1] + C1*Sinh[b*x1] + E1*Cosh[b*x1];
w2 = A2*Sin[b*x2] + B2*Cos[b*x2] + C2*Sinh[b*x2] + E2*Cosh[b*x2];
w3 = A3*Sin[b*(x1 - z1)] + B3*Cos[b*(x1 - z1)] +
C3*Sinh[b*(x1 - z1)] + E3*Cosh[b*(x1 - z1)];
u1 = F1*Cos[\[Lambda]*x1] + G1*Sin[\[Lambda]*x1];
u2 = F2*Cos[\[Lambda]*x2] + G2*Sin[\[Lambda]*x2];
u3 = F3*Cos[\[Lambda]*(x1 - z1)] + G3*Sin[\[Lambda]*(x1 - z1)];

(*Boundary condition*)
e1 = FullSimplify[N[(w1 /. x1 -> 0)]];
e2 = FullSimplify[N[(u1 /. x1 -> 0)]];
e3 = FullSimplify[N[((D[w1, {x1, 1}]) /. x1 -> 0)]];
e4 = FullSimplify[N[(w2 /. x2 -> 0)]];
e5 = FullSimplify[N[(u2 /. x2 -> 0)]];
e6 = FullSimplify[N[((D[w2, {x2, 1}]) /. x2 -> 0)]];
e7 = FullSimplify[N[(w3 /. x1 -> L)]];
e8 = FullSimplify[N[(u3 /. x1 -> L)]];
e9 = FullSimplify[N[((D[w3, {x1, 1}]) /. x1 -> L)]];

(*Displacement contunity*)
e10 = FullSimplify[N[(u1 /. x1 -> z1) - (u3 /. x1 -> z1)]];
e11 = FullSimplify[N[(u2 /. x2 -> z1) - (w1 /. x1 -> z1)]];
e12 = FullSimplify[N[(w1 /. x1 -> z1) - (w3 /. x1 -> z1)]];
e13 = FullSimplify[N[(w2 /. x2 -> z1) - (u1 /. x1 -> z1)]];

(*Slope continuity*)
e14 = FullSimplify[
N[((D[w1, {x1, 1}]) /. x1 -> z1) - ((D[w2, {x2, 1}]) /. x2 -> z1)]];
e15 = FullSimplify[
N[((D[w1, {x1, 1}]) /. x1 -> z1) - ((D[w3, {x1, 1}]) /. x1 -> z1)]];

(*Force contunity*)
e16 = FullSimplify[
N[((D[w3, {x1, 3}]) /. x1 -> z1) + ((A*L^2)/
Iyy ((D[u2, {x2, 1}]) /. x2 -> z1)) - ((D[w1, {x1, 3}]) /.
x1 -> z1)]];
e17 = FullSimplify[
N[((D[u3, {x1, 1}]) /. x1 -> z1) - (Iyy/(
A*L^2) ((D[w2, {x2, 3}]) /. x2 -> z1)) - ((D[u1, {x1, 1}]) /.
x1 -> z1)]];
(*Moment balance*)
e18 = FullSimplify[
N[((D[w3, {x1, 2}]) /. x1 -> z1) + ((D[w2, {x2, 2}]) /.
x2 -> z1) - ((D[w1, {x1, 2}]) /. x1 -> z1)]];
(*Solving*)
R = Normal@
CoefficientArrays[{e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11,
e12, e13, e14, e15, e16, e17, e18}, {A1, B1, C1, E1, F1, G1, A2,
B2, C2, E2, F2, G2, A3, B3, C3, E3, F3, G3}][];
MatrixForm[R]
MatrixRank[R]
P = FullSimplify[Det[R]]


I have a matrix R of dimensions 18*18. I am trying to find the determinant of the matrix, but unable to compute. The rank of the matrix is happened to be full rank. The matrix I am trying to solve contains lots of zeros on it, probably it is ** ill conditioned** I guess. How to overcome this?

• If you remove the last FullSimplify and even consider removing the N and the decimal points so that everything is exactly calculated then Mathematica seems happy to produce the determinant in a reasonable amount of time. FullSimplify can take an extremely long time when given a very large and complicated expression. – Bill Jul 26 '18 at 5:26
• Remove FullSimplify and N wrappers as Bill suggested and use Y = Rationalize[2.06]*10^11;aa = Rationalize[12.7*0.001]; – kglr Jul 26 '18 at 5:30
• I Understood your comments on full simplify. But why on N ?. Mathematica deals with numbers easily than some trig expressions right? – acoustics Jul 26 '18 at 5:34
• Mathematica uses its own ideas about accuracy and precision. Other languages see 2.6 and give you the best 64 bit precision floating point approximation of that. Mathematica sees a number with 2 digits of precision. If your matrix is ill conditioned you may end up with results that only have two or one or even fewer digits of precision. Removing all the decimal points and all the N and doing the entire calculation with exact rationals completes fairly quickly and then you can decide what precision to give the result. Perhaps the subject should be "Can't FullSimplify extremely large expression" – Bill Jul 26 '18 at 5:53
• @vijay if and when this solves your problem, it would be nice if you post an answer to your own question that explains and implements the solutions provided by Bill and kglr. That way people can learn from this solution and probably elaborate further. . The site depends on participation, as you receive, please give back: vote and answer questions, keep the site useful, be kind, correct mistakes and always share what you have learned. – rhermans Jul 26 '18 at 8:20

Basically, I have 18 homogenous equations associated with 18 unknowns and I wanted to solve these equations. All these equations are having a dependence on a variable b. Below are some simple steps I followed to overcome the issues after getting inputs from above discussion/comments.

first I converted these equations into matrix using

R = Normal@
CoefficientArrays[{e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11,
e12, e13, e14, e15, e16, e17, e18}, {A1, B1, C1, E1, F1, G1, A2,
B2, C2, E2, F2, G2, A3, B3, C3, E3, F3, G3}][];
MatrixForm[R]


Then I was trying to find the determinant of the matrix R. But I was trying to simplify the determinant using FullSimplify and it was taking lot of time.So I tried with just Det[R] instead.

P = Det[R]


After I found the roots of P using

NSolve[P == 0 && 0 < b < 30];


Once I found roots of P, All I did was back substitution to find the Unknown coefficients using.

NN = Flatten[NullSpace[R /. b]]


End of struggle.

Note: When dealing with a matrix of big size with trig terms involved, And to find the determinant function better not to go for FullSimplify,TrigExpand,TrigReduce`. Because it will consume time. Just plot your determinant function you can at least get the rough idea of the interval in which the roots lie.