Using Directed Graphs to form multivariate recurrence relations

There are items comprising of red cubes, blue cubes, and balls; how many ways can 3 red cubes, 4 blue cubes and 8 balls be arranged in a line so that:

  • No three cubes are consecutive
  • No three balls are consecutive
  • No two red cubes are next to one another
  • No two blue cubes are next to one another

How do we go about finding a general formula for \(r\) red cubes, \(b\) blue cubes and \(c\) balls ?

The answer lies in forming a directed graph / Finite Automaton, as we have seen it in one of the previous posts.

Instead of filling in the number of ways, we use the variable names as weights for the valid transitions.

Hence, we can directly solve for the general case by using the following adjacency matrix:

\begin{equation*} \displaystyle \begin{array}{|l|rrrrrr|}\hline & \mathrm{I} & \mathrm{R} & \mathrm{B} & \mathrm{C} & \mathrm{BR} & \mathrm{CC} \\ \hline \mathrm{I} & 0 & r & b & c & 0 & 0 \\ \mathrm{R} & 0 & 0 & 0 & c & b & 0 \\ \mathrm{B} & 0 & 0 & 0 & c & r & 0 \\ \mathrm{C} & 0 & r & b & 0 & 0 & c \\ \mathrm{BR} & 0 & 0 & 0 & c & 0 & 0 \\ \mathrm{CC} & 0 & r & b & 0 & 0 & 0 \\ \hline \end{array} \end{equation*}

which is for the constraints that there's no \(RR, BB, RBR, BRB\) or \(CCC\).

Therefore, for 15 items, we compute

\begin{equation*} \displaystyle \left(\begin{array}{rrrrrr} 0 & r & b & c & 0 & 0 \\ 0 & 0 & 0 & c & b & 0 \\ 0 & 0 & 0 & c & r & 0 \\ 0 & r & b & 0 & 0 & c \\ 0 & 0 & 0 & c & 0 & 0 \\ 0 & r & b & 0 & 0 & 0 \end{array}\right)^{15} \end{equation*}

and extract \([c^8 b^4 r^3]\) from the sum of the first row, which is \(11394\).

We may also compute the characteristic polynomial of the matrix to get the structure of its multivariate recurrence relation:

\begin{equation*} \displaystyle x^6 - (bc + cr)x^4 - (bc^2 + 2bcr + c^2r)x^3 - 2bc^2rx^2 = 0 \end{equation*}

which is just like the characteristic equation of a recurrence relation, which is:

\begin{equation*} \displaystyle f_{b,c,r} = f_{b-1,c-1,r}+f_{b,c-1,r-1}+f_{b-1,c-2,r}+f_{b,c-2,r-1}+2 \left(f_{b-1,c-1,r-1}+f_{b-1,c-2,r-1}\right) \end{equation*}

and set the required boundary conditions.

Computing the regular expression from the minimized DFA gives us the following multivariate generating function:

\begin{equation*} \displaystyle G(r,b,c) = \frac{\left(1+c+c^2\right)\left(1+b+r+2br\right)}{1-c\left(1+c\right)\left(b+r+2br\right)} \end{equation*}

Reference:

Putting objects in a line

FriCAS -- an introduction

There are quite a few different free computer algebra systems around \(-\) Sage, maxima, sympy, FriCAS/Axiom etc. \(-\) each having its strengths and lack of something. Having choices and access to source code are good, since we are not at mercy of vendors like those big M developers for bug fixes and feature additions (along with outrageous licence costs).

I have been using FriCAS for a while mainly for its number sequence guessing routines, an indispensable part when working on enumeration problems. But recently, when I tried other operations which I mostly do in Sage or maxima, like integration and solving equations, I was surprised to see it could give simpler and more complete answers than Sage/maxima.

One more good thing is that it comes with a fricas mode for emacs, which has many more features compared to running from a terminal. E.g. it gives features like auto-completion, matched-parenthesis highlighting, shortcut keys for navigating through the input, yanking text etc., and of course, we can define our own shortcuts since it's emacs! Let us see how to set FriCAS up and run from emacs in linux. The latest version at the time is 1.2.3, and I have only tried amd64 binary version.

Make a directory $HOME/bin/ if not already there, and add to the $PATH environment variable. Extract the components to $HOME/bin/. To run it, we need to modify a few paths in its files. Go to $HOME/bin/usr/local/bin, in fricas file, update the variable exec_prefix to

exec_prefix="${FRICAS_PREFIX:-/home/bin/usr/local}"

In file efricas, update FRICASCMD to

FRICASCMD='/home/bin/fricas'

and also update the line which calls emacs.

Update the function fricas \(-\) run in $HOME/bin/usr/local/lib/fricas/emacs/fricas.el to

1
2
3
4
5
6
(defun fricas-run ()
  "Run FriCAS in the current BUFFER."
  (message "Starting FriCAS...")
  (start-process-shell-command "fricas" (current-buffer)
                               fricas-run-command
                               "-noclef" "2>/dev/null"))

Otherwise, FriCAS won't start within emacs.

Next, create two bash scripts within $HOME/bin/ with filenames "fricas" \(-\) which is to execute $HOME/bin/usr/local/bin/fricas, and "efricas" to execute $HOME/bin/usr/local/bin/efricas. Make those two newly created files as executable. There, we are all set now. Simply open the terminal, and enter "efricas" to run fricas within emacs. If everything goes well, we will have fricas running within emacs.

Now, let us have a brief overview of its commands (some are examples taken from the axiom book), and its advantages to other free CAS, and probably even the paid ones.

  1. INTEGRATION

    integrate(tan(atan(x)/3),x)
    

    This integral is an example mentioned in their document, which is instantly solved by fricas, but Sage/maxima fails after trying for a long time.

  2. integrate((x+a)^(1/2)/x,x)
    

    This gives two results, for negative and non-negative a.

    Hence, besides having a good capability, another advantage over Sage and maxima is that we need not declare the symbols which will be used in operations. It also computes the results for all possible cases, and doesn't nag us to make assumptions like in the case of Sage/maxima. (sometimes it keeps asking for the same assumption even if we have already done so!)

  3. SOLVING EQUATIONS

    1
    2
    3
    4
    solve(x^3+x+1,1/1000)
    solve(x^3+x+1,1/1000.0)
    radicalSolve(x^3+x+1)
    complexSolve(x^3+x+1,1/1000.0)
    

    etc. All of the above call the same algorithm to compute the roots, but the result is returned depending on the data type.

    It can also solve non-linear simultaneous equations.

  4. 1
    2
    3
    solve([x+y^2-4,x^2+y-2],1.E-10)
    solve([x+y^2-4,x^2+y-2],1/10^10)
    radicalSolve([x+y^2-4,x^2+y-2])
    

    We can see that it can give all the exact results also effortlessly. In Sage/maxima, there is currently no way of making itto output all results in form of radicals.

  5. RECURRENCE RELATIONS

    The recursions are transformed into iterated code and compiled! And since it can also symbolically compute, this proves very useful to examine sequences.

    1
    2
    3
    fib(0)==0
    fib(1)==1
    fib(n)==fib(n-1)+fib(n-2)
    

    This automatically compiles and computes the fibonacci numbers as an iterated code.

  6. 1
    2
    3
    4
    5
    6
    7
    8
    a(0)==1
    a(1)==1
    a(2)==1
    b(0)==0
    b(1)==0
    b(2)==0
    a(n)==a(n-1)+b(n-1)
    b(n)==a(n-3)+b(n-3)
    

    This simultaneous recurrence is actually narayana's cows sequence, and this kind of recurrence is compiled as well! Using this, we will make use of the guessing routines.

  7. GUESS

    The guessing routine in FriCAS can give us the likely generating function, recurrence relation, functional equation etc.

    Using the above simultaneous recurrence, the generating function can be obtained as:

    guessAlg [a(i)+b(i) for i in 0..20]
    
  8. Try for the recurrence relation.

    guessPRec [a(i)+b(i) for i in 0..20]
    

    This command gives a single recurrence relation! Hence, we may solve a problem our way and use the guessing routines for simplification. Series expansion

    Working with series is also in a way different and easy.

  9. series(x/(1-x-x^2),x=0)
    

    or like this

    x:=series 'x
    x/(1-x-x^2)
    
  10. If we require only the list of coefficients of the series

    cf:=coefficients x/(1-x-x^2)
    

    If we want the \([x^{100}]\)

    coefficient(x/(1-x-x^2),100)
    

    or

    cf.200

  11. SOME MISCELLANEOUS INFO

    Since the output is always pretty-printed and does not provide a way to turn it off (though there are options to output different formats like TeX, fortran, html etc.), we can obtain an unparsed output the following way:

    k:=(-b)^(1/3)/(1+b)
    unparse(k :: InputForm)
    
  12. Shell commands can be executed within it:

    )system pwd
    )system date
    

    etc.

  13. CHANGE OUTPUT FORMAT

    )set output tex on
    )set output tex abc.tex
    
  14. SHOW TIME FOR EXECUTION

    )set messages time on
    
  15. Sage provides an interface to FriCAS, so we may even run it within Sage.

    fricas('series(1/sqrt(1-x),x=0)')
    

and there are many more. It even has its own language \(-\) SPAD.

For more details, see

1. Axiom book

2. FriCAS sandbox

and of course, the source code is available to know "everything" about it!

Probability of a sum being less than 1 (convolution of pdf)

If we choose \(n\) numbers randomly and uniformly from \([0,1]\) and raise each number to \(k\) \((k>0)\), what is the probability that the sum will be less than 1?

i.e. what is

\begin{equation*} \displaystyle \mathbb{P}\left(\Big(\sum_{i=1}^n x_i^k\Big)<1\right)\;\;\; , x_i\in \mathcal{U}\left(0,1\right) \end{equation*}

The answer can be derived by using convolution of probability density functions.

For two pdfs, \(f(x)\) and \(g(y)\), the convolution \(f*g\) is defined as

\begin{align*} \displaystyle \left(f*g\right)(z) &= \int_{-\infty}^{\infty} \, f(z-y)g(y)\, dy\\ &= \int_{-\infty}^{\infty} \, g(z-x) f(x)\, dx \end{align*}

Let \(X_1\) and \(X_2\) be two random variables which represent \(x_1^{1/k}\) and \(x_2^{1/k}\).

The pdf is then given by:

\begin{equation*} \displaystyle f_{X_1}(x)=f_{X_2}(x)=\frac{d}{dx} (x^k)=k\, x^{k-1} \end{equation*}

and the pdf of the sum of two numbers \(f_2(z)\) (in the region \(0\le z \le 1\)) is:

\begin{align*} \displaystyle f_2(z)&= \int_{0}^{z} \, f_{X_1}(z-y) f_{X_2}(y) \, dy\\ &= k^2\cdot z^{2\, k - 1}\cdot \mathrm{B}(k, k) \end{align*}

After this, we can iteratively continue for more terms:

\begin{align*} \displaystyle f_3(z)&= \int_{0}^{z} \, f_{X_1}(z-y) f_{2}(y) \, dy\\ &= k^3\cdot z^{3\, k - 1}\cdot \mathrm{B}(2\, k, k)\cdot \mathrm{B}(k, k) \end{align*}

Continuing in that manner, for sum of \(n\) terms, we will end up with:

\begin{equation*} \displaystyle f_n(z) = k^n\cdot z^{n\, k - 1}\cdot \prod_{i=1}^{n-1} \mathrm{B}(i\, k, k) \end{equation*}

Since we require the probability of the sum to be less than one, we will evaluate that integral and write the beta functions in terms of gamma functions and simplify:

\begin{align*} \displaystyle \mathbb{P}\left(\Big(\sum_{i=1}^n x_i^k\Big)<1\right) &= \int_{0}^{1} \, f_n(z)\, dz\\ &= \frac{k^{n-1}}{n}\prod_{i=1}^{n-1} \mathrm{B}(i\, k, k) \\ &= \frac{k^{n-1}\big(\Gamma(k)\big)^n}{n\, \Gamma(n\, k)} \\ &= \frac{\big(\Gamma(k+1)\big)^n}{\Gamma(n\, k+1)} \end{align*}

That's some formula!

In Sage, it can be written as

var('k y z')
assume(k>0)
assume(2*k-1>0)
f1(z) = diff(z^k,z)
f2(z) = f(z)
for i in range(10):
    f2(z) = integrate(f2(z-y)*f1(y),y,0,z)
    print i+2, f2(z)

f(n,k) = gamma(k+1)^n/gamma(n*k+1)

To verify our answer, we can perform a simulation:

sim=: 3 : '1>+/(?6#0)^6'
(+/%#)(sim"0)100000#0 NB. = 0.63926

If we want to perform a simulation in a more verbose language, R is a good candidate.

The code in R looks like:

1
2
3
4
n = 6
k = 6
b = array(runif(n*1e6,0,1),dim=c(n,1e6))
mean(apply(b^k,2,sum)<1)

and if we want to perform using two dimensional arrays in J also, the equivalent code can be written as:

1
2
3
'n k'=: 6 6
a=:(n, 1e6) $ ?(n*1e6)#0
(+/%#)1>+/a^k NB. = 0.637572

The corresponding probability derived analytically is:

\begin{align*} \displaystyle \mathbb{P}\left(\Big(\sum_{i=1}^6 x_i^6\Big)<1\right) = f\left(6,\frac{1}{6}\right) \\ = \Gamma\left(\frac{7}{6}\right)^6 \approx 0.637528558759471 \end{align*}

References:

1. Dartmouth Probability Book

2. An arxiv article

3. Volume of a n-ball

Interesting definite integrals

We will see a list of few integrals which yields to differentiation under the integral sign:

  1. \begin{align*} \displaystyle \int_0^\infty \, \frac{\arctan{(a\,(x^n))}}{x^{n}}\, dx = \frac{a^{1-\frac{1}{n}} {\rm B}\left(\frac{1}{2 \, n}, 1-\frac{1}{2 \, n}\right)}{2 \, {\left({n} - 1\right)}}\\ =\frac{\pi \, a^{1-\frac{1}{n}}}{2 \, {\left({n} - 1\right)} \, \sin\left(\frac{\pi}{2n}\right)} \end{align*}

    or a more general result, for \(k \ge n\)

    \begin{equation*} \displaystyle \int_0^\infty \, \frac{\arctan{(a\,(x^k))}}{x^{n}}\, dx =\frac{\pi \, a^{\frac{n-1}{k}}}{2 \, {\left({n} - 1\right)} \, \sin\left(\frac{k-n+1}{2\, k}\, \pi\right)} \end{equation*}
  2. \begin{equation*} \displaystyle \int_0^{\pi/2} \, \log{\left(1+a\, \sin(x)^{2}\right)}\, dx = \pi\, \log{\left(\frac{\sqrt{a+1}+1}{2}\right)} \end{equation*}
  3. \begin{equation*} \displaystyle \int_0^{\infty} \, e^{-a\sqrt{x}}\, \frac{\sin{\sqrt{x}}}{x}\, dx = \pi - 2\, \arctan{a} \end{equation*}
  4. \begin{equation*} \displaystyle \displaystyle \int_0^{\infty} \, \frac{\log{\left(1+\frac{a}{x^{3}}\right)}}{1+x^{3}}\, dx = \frac{1}{3\, \sqrt{3}} \, {\left(2 \, \sqrt{3} \pi \arctan\left(\frac{1}{\sqrt{3}} \, {\left(2 \, a^{\frac{1}{3}} + 1\right)}\right) + 3 \, \pi \log\left(a^{\frac{2}{3}} + a^{\frac{1}{3}} + 1\right)\right)}-\frac{\pi^{2}}{9} \end{equation*}
  5. \begin{equation*} \displaystyle \displaystyle \int_0^{\infty} \, \frac{x\, \log{\left(1+\frac{a}{x^{3}}\right)}}{1+x^{3}}\, dx = \frac{\pi^{2}}{9}-\frac{1}{3\, \sqrt{3}} \, {\left(2 \, \sqrt{3} \pi \arctan\left(\frac{1}{\sqrt{3}} \, {\left(2 \, a^{\frac{1}{3}} + 1\right)}\right) - 3 \, \pi \log\left(a^{\frac{2}{3}} + a^{\frac{1}{3}} + 1\right)\right)} \end{equation*}
  6. \begin{equation*} \displaystyle \int_0^{\infty} \, \log\left(\frac{a^{2} x^{2} + 1}{a^{2} + 1}\right)\, \frac{1}{1-x^{2} }\, dx = -\arctan(a)^2 \end{equation*}
  7. \begin{equation*} \displaystyle \int_0^{1} \frac{\log\left(1+a x \right)}{x\, \sqrt{1-x^{2}} }\, dx = \frac{1}{2}\, \log{\left(\sqrt{a^2-1}+a\right)}^{2}+\frac{\pi^2}{8} \end{equation*}
  8. \begin{equation*} \displaystyle \int_{0}^{\infty}\, \frac{\log\left(a x + b\right)}{{\left(x + 1\right)}^{2}}\, dx = \frac{a \log\left(a\right) - b \log\left(b\right)}{a - b} \end{equation*}
  9. \begin{equation*} \displaystyle \int_{0}^{\infty}\, \frac{e^{-a x^{2}} \sin\left(b\, x\right)^{2}}{x^{2}}\, dx = \frac{1}{2} \, \sqrt{\pi} {\left(b\, \sqrt{\pi}\, \text{erf}\left(\frac{b}{\sqrt{a}}\right) + \sqrt{a} e^{-b^{2}/a}\right)} - \frac{1}{2} \, \sqrt{\pi\, a} \end{equation*}
  10. This integral is different. The rule is applied twice, and integrated back twice, finding the constant of integration each time.

    \begin{equation*} \displaystyle \int_{0}^{\infty}\, \frac{e^{\left(-a x\right)} \sin\left(b x\right)^{5}}{x^{2}}\, dx = -\frac{3}{16} \, \pi a - \frac{5}{32} \, b {\left(\log\left(25\right) - 3 \, \log\left(9\right)\right)} + \frac{5}{8} \, a \arctan\left(\frac{a}{b}\right) - \frac{5}{16} \, a \arctan\left(\frac{a}{3 \, b}\right) + \frac{1}{16} \, a \arctan\left(\frac{a}{5 \, b}\right) - \frac{5}{32} \, b \log\left(\frac{a^{2} + 25 \, b^{2}}{25 \, b^{2}}\right) + \frac{15}{32} \, b \log\left(\frac{a^{2} + 9 \, b^{2}}{9 \, b^{2}}\right) - \frac{5}{16} \, b \log\left(\frac{a^{2} + b^{2}}{b^{2}}\right) \end{equation*}
  11. More complicated than the previous, the rule is to be applied 5 times:

    \begin{equation*} \displaystyle \int_{0}^{\infty}\, \frac{e^{\left(-a x\right)} \sin\left(b x\right)^{5}}{x^{5}}\, dx = \frac{1}{128} \, \pi a^{4} + \frac{5}{64} \, \pi a^{2} b^{2} + \frac{115}{384} \, \pi b^{4} - \frac{5}{192} \, a^{4} \arctan\left(\frac{a}{b}\right) + \frac{5}{32} \, a^{2} b^{2} \arctan\left(\frac{a}{b}\right) - \frac{5}{192} \, b^{4} \arctan\left(\frac{a}{b}\right) + \frac{5}{384} \, a^{4} \arctan\left(\frac{a}{3 \, b}\right) - \frac{45}{64} \, a^{2} b^{2} \arctan\left(\frac{a}{3 \, b}\right) + \frac{135}{128} \, b^{4} \arctan\left(\frac{a}{3 \, b}\right) - \frac{1}{384} \, a^{4} \arctan\left(\frac{a}{5 \, b}\right) + \frac{25}{64} \, a^{2} b^{2} \arctan\left(\frac{a}{5 \, b}\right) - \frac{625}{384} \, b^{4} \arctan\left(\frac{a}{5 \, b}\right) + \frac{5}{192} \, a^{3} b \log\left(25\right) - \frac{5}{64} \, a^{3} b \log\left(9\right) - \frac{125}{192} \, a b^{3} \log\left(a^{2} + 25 \, b^{2}\right) + \frac{45}{64} \, a b^{3} \log\left(a^{2} + 9 \, b^{2}\right) - \frac{5}{96} \, a b^{3} \log\left(a^{2} + b^{2}\right) + \frac{5}{96} \, a^{3} b \log\left(\frac{a^{2}}{b^{2}} + 1\right) - \frac{5}{64} \, a^{3} b \log\left(\frac{a^{2}}{9 \, b^{2}} + 1\right) + \frac{5}{192} \, a^{3} b \log\left(\frac{a^{2}}{25 \, b^{2}} + 1\right) \end{equation*}

    So, if \(a=0\), it reduces to a simpler form:

    \begin{equation*} \displaystyle \int_{0}^{\infty}\, \frac{\sin\left(b x\right)^{5}}{x^{5}}\, dx =\frac{115}{384} \, \pi b^{4} \end{equation*}

    In Sage, it can be applied as:

    # Takes a few seconds
    var('a b')
    forget()
    assume(a>0)
    intg = e^(-a*x)*sin(b*x)^5/x^5
    tmp = integrate(integrate(diff(intg,a,5),x,0,oo),a)
    h1(a) = tmp-limit(tmp,a=oo)
    tmp = integrate(h1(a),a)
    h2(a) = tmp-limit(tmp,a=oo)
    tmp = integrate(h2(a),a)
    h3(a) = tmp-limit(tmp,a=oo)
    tmp = integrate(h3(a),a)
    h4(a) = tmp-limit(tmp,a=oo)
    tmp = integrate(h4(a),a)
    h5(a) = tmp-limit(tmp,a=oo)
    
  12. \begin{align*} \displaystyle \int_{0}^{\pi/2}\, e^{-b\, \sec{(x)}^{2}} \, \sin{(a\, \tan{x})}^{2} \, dx \\ =\frac{\pi}{4}\left(1 - e^{-2 \, a}\right) -\frac{1}{8} \, \pi {\left({\rm erfc}\left(\frac{a}{\sqrt{b}} + \sqrt{b}\right) e^{\left(4 \, a\right)} + {\rm erfc}\left(-\frac{a}{\sqrt{b}} + \sqrt{b}\right) - 2\right)} e^{\left(-2 \, a\right)} - \frac{1}{4} \, \pi \text{erf}\left(\sqrt{b}\right) \end{align*}

    or in particular, when \(b \to 0\),

    \begin{equation*} \displaystyle \int_{0}^{\pi/2}\, \sin{(a\, \tan{x})}^{2} \, dx =\frac{\pi}{4}\left(1 - e^{-2 \, a}\right) \end{equation*}
  13. \begin{equation*} \displaystyle \int_{0}^{\infty}\, \frac{\log{(1+a\, x^3)}}{(1-x+x^2)}\, dx = \frac{2}{\sqrt{3}} \, \pi \, \log\left(1+ a^{\frac{1}{3}} + a^{\frac{2}{3}} \right) \end{equation*}
  14. \begin{equation*} \displaystyle \int_{0}^{1}\, \frac{\arctan{a\, x}}{x\, \sqrt{1-x^2}}\, dx = \frac{\pi}{2} \, \sinh^{-1}{a} \end{equation*}
  15. \begin{align*} \displaystyle \int_{0}^{1}\, \frac{\log{\left(1+a\, x\, (1-x)\right)}}{x}\, dx = \sum_{i=1}^{\infty}\frac{(-1)^{i-1} a^{i}}{i^{2}\, \binom{2i}{i}} = \frac{1}{2}\, \log\left( \frac{a+2 -\sqrt{a^{2} + 4 \, a}}{2}\right)^{2}\\ \implies \sum_{i=1}^{\infty}\frac{1}{i^{2}\, \binom{2i}{i}} =\frac{\pi^{2}}{18} \\ \phantom{\implies}\sum_{i=1}^{\infty}\frac{2^{i}}{i^{2}\, \binom{2i}{i}} =\frac{\pi^{2}}{8} \text{ etc.} \end{align*}
  16. \begin{equation*} \displaystyle \int_{0}^{\pi}\, \log{\left(1-2\, a\, \cos{x} + a^{2}\right)}\, dx = 2\, \pi\, \log{|a|} \end{equation*}
  17. \begin{equation*} \displaystyle \int_0^{\pi/4} \frac{\left(\log{\tan{\left(\frac{\pi}{4}+ x\right)}}\right)^n}{\tan{(2x)}}\, dx = \frac{n!}{2^n} \left(1-\frac{1}{2^{n + 1}}\right) \zeta(n + 1) \end{equation*}
  18. \begin{equation*} \displaystyle \int_0^1 \log\frac{\big(x+a\, \sqrt{1-x^2}\big)^2}{\big(x-a\, \sqrt{1-x^2}\big)^2} \frac{x\, dx}{1-x^2} = 2\,\pi\arctan{a} \end{equation*}
  19. The functions in the answer are Beta and the Polygamma:

    \begin{equation*} \displaystyle \int_0^{\pi/2}\, \frac{\sin(x)^a\, \log{\sin{x}}}{\sqrt{1+\sin(x)^2}}\, dx = \frac{1}{16} \, {\left(\psi_0\left(\frac{a+1}{4} \right)-\psi_0\left(\frac{a+3}{4} \right) \right)} {\rm B}\left(\frac{a+1}{4},\frac{1}{2}\right) \end{equation*}