An infinite continued fraction of $x^n$
I coded in SageMath to compute the 50th convergent of $f(x)$ and plot for integers $x=1,\dots,50$:
def f(x, n_terms):
result = []
for i in range(n_terms):
result.extend([x**i, x**i])
return continued_fraction([0] + result).n()
list_plot(([f(x,50) for x in range(1,50)]), title='$f(x)=\\dfrac{x}{x+\\dfrac{x^2}{x^2+\\dfrac{x^3}{x^3+\\ddots}}}$')
My question is to make a continuous plot of $f(x)$.
I have difficulty in that continued_fraction
only support integer values of $x$.
Your function
f
cannot be evaluated at non-integer valuesx
sincecontinued_fraction()
expects a list with integer elements. Hence,f
(as defined) is not a continuous function and cannot be plotted as such. Do you mean a continuous interpolation off
from its values at integer points or something else?Yes, the built-in function
continued_fraction()
expects a list of integers, but I want to compute $$f(x)=\cfrac{x}{x+\cfrac{x^2}{x^2+\cfrac{x^3}{x^3+\cdots}}}$$ $f$ is a continuous function for real number $x>1$. Does SageMath have built-in function to compute continued fractions of real numbers?