Tilting Pencil problem

Okay, my friend any I are working on a calculus project where we must use calculus in every day life. Unfortunately, we chose a topic that is much more complicated then we should have done. We must find the time it takes a pencil to fall to the ground if it was standing on its tip.
We did the first part, but became stuck at one of the steps. I found this guide online, but it skips so many steps that it wasn't that useful.

We got stuck on number 3 where it says "To arrive at a more easily evaluated expression, we can first consider only the initial interval of time, during which the pencil just begins to tip from nearly a vertical position. Differentiating (1) and dividing through by 2(dq/dt)"

Tilting Pencils
If a pencil is carefully balanced on its point, how long will it take to fall over? Neglecting all external disturbances and non-ideal effects, this can be modeled as an inverted pendulum of length L and mass m, released from an initial position making an angle of q0 relative to vertical, as illustrated below.
The simple equation of motion for this tilting pencil can be found by either equating the torque with the product of the moment of inertia and the angular acceleration, or by an energy balance. If the mass per unit length is r = m/L, then the kinetic energy of an incremental segment dr of the rod is dK = (1/2) r dr v2 where v = wr. Hence the total kinetic energy of the rod is
The potential energy P can be expressed as the product of the acceleration of gravity times the total mass of the pencil times the height of the mid-point of the pencil, so we have P = rLg(L/2)cos(q) where g is the acceleration of gravity. Setting the sum of the kinetic and potential energies to a constant C gives the equation of motion
Dividing through by rL3/6, we arrive at
This implies
so we have
Consequently the time for the pencil to fall to the horizontal position from an initial angle of q0 beginning with an initial angular speed of is given by the integral
There is no simple closed-form expression for this integral, although it can be converted to the standard form of an elliptic integral. However, for extremely small initial angles q0 (e.g., 10-10 degrees) the integral is very ill-conditioned and not easily evaluated.
To arrive at a more easily evaluated expression, we can first consider only the initial interval of time, during which the pencil just begins to tip from nearly a vertical position. Differentiating (1) and dividing through by 2(dq/dt) gives
This is the same equation of motion we would derive directly from equating the torque to the product of angular acceleration and moment of inertia mL2/3 of a slender rod about its end point. Note that as long as the angle q is extremely small, the value of sin(q) is essentially equal to q itself. (This is the same "small angle approximation" that we commonly use for an ordinary non-inverted pendulum to predict simple harmonic motion.) Therefore, as long as the pencil is very near vertical its motion essentially satisfies the linear equation
This simple second-order linear equation has the solution
where k is the square root of 3g/(2L), and the constants A,B are determined by the initial conditions. If the pencil is initially at rest at an angle q0 from vertical, then A = B = q0/2, and the solution is
Solving for the time t1 when the pencil has reached an angle of q1, we find that
The angular velocity of the pencil at this instant is given by differentiating the expression for q(t) and substituting this value for t. The result is
Now we can use equation (2) to give the time required to tip from q1 to q2 = p/2, and we can add this to the time t1 required to tip from q0 to q1 to give the total time. By equation (2) we have
For very small values of q0 we can neglect the q02 in this expression, and we can expand the expression under the square root as
Since we are taking a small value of q1, the higher order terms can be neglected, and the argument of the square root is simply 1 - cos(q) = 2sin(q/2)2. Making this substitution, the integral can be evaluated in closed form as
Returning to the expression for t1, notice that for arguments much greater than 1 the inverse of the hyperbolic cosine is essentially equal to the natural log of twice the argument, so we have
Adding this to the previous expression gives a very close approximation to the total time for the pencil to tip from q0 to p/2
Recall that q1 is really just an intermediate small angle, which can be chosen small enough so that sin(q1/2) is essentially equal to q1/2, and so that 1 + cos(q1/2) is essentially equal to 2. Therefore the above expression can be simplified to
As an example, if the pencil is L = 0.2 m long, and if we take g = 9.8 m/sec2, then the total time for the pencil to tip over from an initial stationary position of q0 = 10-10 degrees (which equals (p/180)10-10 radians) is 3.29773... seconds. On the other hand, if we imagine that the initial pencil position is just q0 = 10-100 degrees, then the time to tip over is 27.469838205... seconds. In general, the time to tip over from an initial stationary position of 10-n degrees is
This idealized pencil would take 1 year = 31557600 seconds to tip over (theoretically) if its initial stationary position is q0 = 10-117498396 degrees from vertical.