ContinuedFraction
Usage
• ContinuedFraction[x, n] 产生一个在x的连续分数表示中的前 n项的列表。
• ContinuedFraction[x, n] 产生一个给定x的精度可得到的所有项的列表。
Notes
• 连续分数表示  , , , ...  相应于表达式 a1+1/(a2+1/(a3+...))。 • x 或者是一个精确数或者是一个不精确数。 • 例如: ContinuedFraction[Pi, 4]  . • 对精确数,如果 x 是有理数或二次无理数,可以使用ContinuedFraction[x]。 • 由于一个有理数的连续分数表示仅有有限项,在这种情况下ContinuedFraction[x, n]可能产生一个少于 n 个元素的列表。 • 对中断连续函数,  ... , k 总是与  ... , k-1, 1 相等; ContinuedFraction 返回这些形式中的第一个。 • FromContinuedFraction[list]从ContinuedFraction的结果中重新构造一个数。
Further Examples
The result of ContinuedFraction is given as a list.
In[1]:=
|
Out[1]=
|
The continued fraction simplifies to the original fraction.
In[2]:=
|
Out[2]=
|
This gives the continued fraction representation of a quadratic number. The sublist represents the repeated part.
In[3]:=
|
Out[3]=
|
You can go back to the number with FromContinuedFraction.
In[4]:=
|
Out[4]=
|
This gives the first few terms of the continued fraction representation of a transcendental number.
In[5]:=
|
Out[5]=
|
Here is a special case of Pell's equation. In a Diophantine equation like this the parameter m and the variables x and y are assumed to be integers.
In[6]:=
|
PellSolve gives the least positive solution for x and y when m is not a perfect square.
In[7]:=
|
Here is the solution when m is .
In[8]:=
|
Out[8]=
|
In[9]:=
|
Out[9]=
|
In[10]:=
|
同时参见 FromContinuedFraction.
|