# Can Mathematica evaluate a continued fraction using Gauss's $K$ operator?

I don't know a whole lot about Mathematica, and this is a fairly uncommon notation, so here goes:

How do I tell Mathematica to evaluate this? $$1+\underset{i=1}{\overset{\infty}{K}}\frac{(-1)^{i-1}}{i+1}$$

where $$\underset{i=1}{\overset{\infty}{K}}\frac{a_i}{b_i}=\cfrac{a_{1}}{b_{1}+\cfrac{a_{2}}{b_{2}+\cfrac{a_{3}}{b_{3}+\cfrac{a_{4}}{b_{4}+\ddots{}}}}}$$

Must I convert to a different notation first? Or can I create a custom notation like this? Thanks for your time.

Update: I didn't know the ContinuedFractionK command, but unfortunately:

In[1] = ContinuedFractionK[(-1)^(i-1),i+1,{i,1,Infinity}]


produces only the formula in its proper format. How can I get a numerical value?

P.S. I am working in Wolfram Cloud Open Access in my browser, if that matters.

• I am not familiar with the notation, but is ContinuedFractionK relevant to your problem? Apr 16 '20 at 18:30
• @MarcoB Yes, that is what I am looking for. Thank you very much! Apr 16 '20 at 18:31
• @MarcoB Hold on though, when I use this function, it doesn't actually evaluate it. It just formats in the proper way. How can I evaluate it? Apr 16 '20 at 18:42
• It will evaluate to a value IF it knows / can calculate the value of the infinite sum. If not, it returns unevaluated. Mathematica is not magic :-) For instance,1+ ContinuedFractionK[1, {n, 1, Infinity}] evaluates to GoldenRatio. Apr 16 '20 at 18:52

ContinuedFractionK[a[i], b[i], {i, 1, 5}]


cf = 1 + ContinuedFractionK[(-1)^(i - 1), i + 1, {i, 1, Infinity}]


With 25 terms this converges to 50 decimal places

(seq = Table[
1 + ContinuedFractionK[(-1)^(i - 1), i + 1, {i, 1, m}],
{m, 20, 25}]) // N[#, 50] &

(* {1.5904911352531017312102344422665947246625994232424, \
1.5904911352531017312102344422665947246626211968387, \
1.5904911352531017312102344422665947246626212398613, \
1.5904911352531017312102344422665947246626212397833, \
1.5904911352531017312102344422665947246626212397832, \
1.5904911352531017312102344422665947246626212397832} *)

cfn = seq // Last

(* 574085431771810544409993183/360948526557146668699034326 *)