General formula for the nth derivative of $ \ln(x^2 + x – 2) $

derivatives

I need to find the general formula for the nth derivative of $ y = \ln(x^2 + x – 2) $, and the only thing that I haven't been able to figure out is an expression for the coefficients of the derivative's terms.

I'll explain everything I have tried and achieved so far, sorry if it's way too long and thanks in advance for your patience:

First, I calculated the first six derivatives of the function. I'll go straight to the results:

$$ y' = \frac{2x+1}{x^2+x-2} $$
$$ y'' = \frac{2}{x^2+x-2} – \frac{(2x+1)^2}{(x^2+x-2)^2} $$
$$ y''' = -\frac{6(2x+1)}{(x^2+x-2)^2} + \frac{2(2x+1)^3}{(x^2+x-2)^3} $$
$$ y^{(4)} = -\frac{12}{(x^2+x-2)^2} + \frac{24(2x+1)^2}{(x^2+x-2)^3} – \frac{6(2x+1)^4}{(x^2+x-2)^4} $$
$$ y^{(5)} = \frac{120(2x+1)}{(x^2+x-2)^3} – \frac{120(2x+1)^3}{(x^2+x-2)^4} + \frac{24(2x+1)^5}{(x^2+x-2)^5} $$
$$ y^{(6)} = \frac{240}{(x^2+x-2)^3} – \frac{1080(2x+1)^2}{(x^2+x-2)^4} + \frac{720(2x+1)^4}{(x^2+x-2)^5} – \frac{120(2x+1)^6}{(x^2+x-2)^6} $$

It's evident there's some pattern here. Basically, each derivative is a sum of $ m $ terms with this general shape:
$$ \frac{a(2x+1)^b}{(x^2+x-2)^c} $$

I also noticed that on each derivative, the signs of the terms alternate, but the sign of the first term varies too: $ y'$ and $ y'' $ start with a positive term, then $ y''' $ and $ y^{(4)} $ start with a negative term, then $ y^{(5)} $ and $ y^{(6)} $ start with a positive term, etc. Therefore, the formula must account for the "initial sign" of each derivative and the sign of each term.

Thus, I came up with this basic template for the nth derivative:

$$ y^{(n)} = s_n · \sum_{k=0}^{m-1} s_k · \frac{a(n, k) · (2x+1)^{b(n, k)}}{(x^2+x-2)^{c(n, k)}} $$

To make it easier to see the patterns of each component, I broke it down in a table:

n  m  s_n  s_k      b        c        a                
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
1  1  +    +        1        1        1
2  2  +    +,-      0,2      1,2      2,1
3  2  -    -,+      1,3      2,3      6,2
4  3  -    -,+,-    0,2,4    2,3,4    12,24,6
5  3  +    +,-,+    1,3,5    3,4,5    120,120,4
6  4  +    +,-,+,-  0,2,4,6  3,4,5,6  240,1080,720,120

The number of terms ($ m $) of each derivative varies according to $ n $ following the sequence {1, 2, 2, 3, 3, 4, …}. The corresponding expression is:
$$ m = \left\lfloor\frac{n}{2}\right\rfloor + 1 $$

The initial sign ($ s_n $) of each derivative alternates according to $ n $ following the sequence {+, +, -, -, +, +, …}. The corresponding expression is:
$$ s_n = (-1)^{\left\lfloor\frac{n-1}{2}\right\rfloor} $$

The sign of each term of a derivative ($ s_k $) alternates according to $ k $ following the sequence {+, -, +, -, +, -, …} if $ s_n $ is positive, or {-, +, -, +, -, +, …} if $ s_n $ is negative. The corresponding expression is:
$$ s_k = (-1)^k $$

The exponents of $ 2x + 1 $ in each term's numerator ($ b $) vary according to $ k $ (starting with $ k = 0 $) following the sequence of odd numbers in ascending order {1, 3, 5, …} if $ n $ is odd, or the sequence of even numbers in ascending order {0, 2, 4, 6, …} if $ n $ is even. This is the same as saying that $ b(n, 0) $ is 1 if $ n $ is odd or 0 otherwise, and each subsequent $ b(n, k) $ is just the previous one plus 2. The corresponding expression is therefore:
$$ b(n, k) = \frac{1}{2} [1 + (-1)^{n+1}] + 2k $$

The exponents of $ x^2 + x – 2 $ in each term's denominator ($ c $) vary according to $ k $ (starting with $ k = 0 $) following the sequence of consecutive numbers which have their initial value determined by $ n $ according to the sequence {1, 1, 2, 2, 3, 3, …}. The corresponding expression is therefore:
$$ c(n, k) = \left\lfloor\frac{n+1}{2}\right\rfloor + k $$

The final component of the formula is the coefficient of each term ($ a $), which shows no apparent pattern at first glance. See the table:

\ k     0    1    2    3
n \ ::::::::::::::::::::
1 :     1    .    .    . 
2 :     2    1    .    .
3 :     6    2    .    .  
4 :    12   24    6    .
5 :   120  120   24    .
6 :   240 1080  720  120

To figure out its formula, I analyzed the process of obtaining each $ a $ of each derivative:

  • For $ n = 1 $:
    $$ a(1, 0) = 1 $$

  • For $ n = 2 $:
    $$ \begin{align}
    a(2, 0) & = 2 \\
    & = 1·1·(2x+1)' \\
    & = a(1, 0)·b(1, 0)·2 \\
    & = 2·a(n-1, k)·b(n-1, k) \\
    & \\
    a(2, 1) & = 1 \\
    & = 1 · 1 \\
    & = a(1, 0) · c(1, 0) \\
    & = a(n-1, k-1) · c(n-1, k-1) \\
    \end{align} $$

  • For $ n = 3 $:
    $$ \begin{align}
    a(3, 0) & = 6 \\
    & = 2·1 + 1·2·(2x+1)' \\
    & = a(2, 0)·c(2, 0) + a(2, 1)·b(2, 1)·2 \\
    & = a(n-1, k)·c(n-1, k) + 2·a(n-1, k+1)· b(n-1, k+1) \\
    & \\
    a(3, 1) & = 2 \\
    & = 1·2 \\
    & = a(2, 1)·c(2, 1) \\
    & = a(n-1, k)·c(n-1, k)
    \end{align} $$

  • For $ n = 4 $:
    $$ \begin{align}
    a(4, 0) & = 12 \\
    & = 6·1·(2x+1)' \\
    & = a(3, 0)·b(3, 0)·2 \\
    & = 2·a(n-1, k)· b(n-1, k) \\
    & \\
    a(4, 1) & = 24 \\
    & = 6·2 + 2·3·(2x+1)' \\
    & = a(3, 0)·c(3, 0) + a(3, 1)·b(3, 1)·2 \\
    & = a(n-1, k-1)·c(n-1, k-1) + 2·a(n-1, k)· b(n-1, k) \\
    & \\
    a(4, 2) & = 6 \\
    & = 2·3 \\
    & = a(3, 1)·b(3, 1) \\
    & = a(n-1, k-1)·c(n-1, k-1) \\
    \end{align} $$

  • For $ n = 5 $:
    $$ \begin{align}
    a(5, 0) & = 120 \\
    & = 12·2 + 24·2·(2x+1)' \\
    & = a(4, 0)·c(4, 0) + a(4, 1)·b(4, 1)·2 \\
    & = a(n-1, k)·c(n-1, k) + 2·a(n-1, k+1)· b(n-1, k+1) \\
    & \\
    a(5, 1) & = 120 \\
    & = 24·3 + 6·4·(2x+1)' \\
    & = a(4, 1)·c(4, 1) + a(4, 2)·b(4, 2)·2 \\
    & = a(n-1, k)·c(n-1, k) + 2·a(n-1, k+1)· b(n-1, k+1) \\
    & \\
    a(5, 2) & = 24 \\
    & = 6·4 \\
    & = a(4, 2)·b(4, 2) \\
    & = a(n-1, k)·c(n-1, k) \\
    \end{align} $$

  • For $ n = 6 $:
    $$ \begin{align}
    a(6, 0) & = 240 \\
    & = 120·1·(2x+1)' \\
    & = a(5, 0)·b(5, 0)·2 \\
    &= 2·a(n-1, k)·b(n-1, k) \\
    & \\
    a(6, 1) &= 1080 \\
    & = 120·3 + 120·3·(2x+1)' \\
    & = a(5, 0)·c(5, 0) + a(5, 1)·b(5, 1)·2 \\
    & = a(n-1, k-1)·c(n-1, k-1) + 2·a(n-1, k)· b(n-1, k) \\
    & \\
    a(6, 2) & = 720 \\
    & = 120·4 + 24·5·(2x+1)' \\
    & = a(5, 1)·c(5, 1) + a(5, 2)·b(5, 2)·2 \\
    & = a(n-1, k-1)·c(n-1, k-1) + 2·a(n-1, k)· b(n-1, k) \\
    & \\
    a(6, 3) & = 120 \\
    & = 24·5 \\
    & = a(5, 2)·b(5, 2) \\
    & = a(n-1, k-1)·c(n-1, k-1) \\
    \end{align} $$

I'll skip the details and go straight to the generalized recurrent function definition for $ a(n, k) $ that I created from these results:

$$ a(n, k) =
\begin{cases}
1, & \text{if }n = 1 \land k = 0 \\
a(n-1, k-\frac{1}{2}(1+(-1)^n))·c(n-1, k-\frac{1}{2}(1+(-1)^n)) + 2·a(n-1, k+\frac{1}{2}(1-(-1)^n)), & \text{if }k-\frac{1}{2}(1+(-1)^n) \geq 0 \land n-2(k+1) \geq 0 \\
a(n-1, k-\frac{1}{2}(1+(-1)^n))·c(n-1, k-\frac{1}{2}(1+(-1)^n)), & \text{if }k-\frac{1}{2}(1+(-1)^n) \geq 0 \land n-2(k+1) < 0 \\
2·a(n-1, k+\frac{1}{2}(1-(-1)^n)), & \text{if }k-\frac{1}{2}(1+(-1)^n) < 0 \land n-2(k+1) \geq 0 \\
0, & \text{if }k-\frac{1}{2}(1+(-1)^n) < 0 \land n-2(k+1) < 0
\end{cases} $$

The thing is that I don't want a recurrent definition like that. In a previous exercise I succeeded in converting a recurrent definition into a non-recurrent one by decomposing the numbers and finding out a similarity with the binomial expansion formula. But for this one I haven't been able to find a single formula that reliably generates the correct coefficients.

After many attempts, these are the most promising patterns I've found:

\ k       0      1      2      3
n \ ::::::::::::::::::::::::::::::::::
1 :       1!     .      .      . 
2 :   (1/1)*2!   1!     .      .
3 :       3!     2!     .      .  
4 :   (1/2)*4!  4*3!    3!     .
5 :       5!    5*4!    4!     .
6 :   (1/3)*6!  9*5!    6!     5!

Using the recurrent formula from before, I calculated the coefficients for the 7th degree derivative (I verified the full derivative with Symbolab), and compared them with the apparent pattern of each column:
$$ \begin{align}
a(7, 0) & = 5040
& = 7! \\
a(7, 1) & = 10080
& = 14·6! \\
a(7, 2) & = 5040
& = 7! \\
a(7, 3) & = 720
& = 6!
\end{align} $$

This implies the following formulas for each $ k $:
$$ \begin{align}
a(n, 0) & = \frac{1}{\left(\frac{n}{2}\right)^{\frac{1}{2}(1+(-1)^n)}}·n! \\
a(n, 1) & = \begin{cases}
(n-1)!, & \text{if }n<4 \\
4·(n-1)!, & \text{if }n=4 \\
\left[\frac{a(n-1, 1)}{(n-2)!} + \frac{a(n-2, 1)}{(n-3)!}\right]·(n-1)!, & \text{if }n>4
\end{cases} \\
a(n, 2) & = (n-1)! \\
a(n, 3) & = (n-1)!
\end{align} $$

But how do I synthetize all of that into a single expression? How can I be sure that the patterns will hold for all possible values of $ n $ and $ k$? Am I on the wrong path? After writing all of this, it does seem overkill.

Best Answer

Following the suggestion of player3236, I rewrote the function first: $$ y = \ln(x^2+x-2) \Rightarrow y = \ln(x+2) + \ln(x-1) $$

Then I calculated the first nine derivatives of it: $$ \begin{align} y' &= \frac{1}{x+2} + \frac{1}{x-1} \\ y'' &= -\left[\frac{1}{(x+2)^2} + \frac{1}{(x-1)^2}\right] \\ y''' &= 2·\left[\frac{1}{(x+2)^3} + \frac{1}{(x-1)^3}\right] \\ y^{(4)} &= -6·\left[\frac{1}{(x+2)^4} + \frac{1}{(x-1)^4}\right] \\ y^{(5)} &= 24·\left[\frac{1}{(x+2)^5} + \frac{1}{(x-1)^5}\right] \\ y^{(6)} &= -120·\left[\frac{1}{(x+2)^6} + \frac{1}{(x-1)^6}\right] \\ y^{(7)} &= 720·\left[\frac{1}{(x+2)^7} + \frac{1}{(x-1)^7}\right] \\ y^{(8)} &= -5040·\left[\frac{1}{(x+2)^8} + \frac{1}{(x-1)^8}\right] \\ y^{(9)} &= 40320·\left[\frac{1}{(x+2)^9} + \frac{1}{(x-1)^9}\right] \\ \end{align} $$

And now it's obvious that the nth derivative of $ \ln(x^2+x-2) $ has the following formula: $$ y^{(n)} = (-1)^{n+1}·(n-1)!·\left[\frac{1}{(x+2)^n} + \frac{1}{(x-1)^n}\right] $$

Related Question