Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
sage: for i in (1..5):
....:       c = b+1
....:       b = 1/c
....:       print b.simplify_full(),",",c.simplify_full()
....:     
a/(a + 1) , (a + 1)/a
(a + 1)/(2*a + 1) , (2*a + 1)/(a + 1)
(2*a + 1)/(3*a + 2) , (3*a + 2)/(2*a + 1)
(3*a + 2)/(5*a + 3) , (5*a + 3)/(3*a + 2)
(5*a + 3)/(8*a + 5) , (8*a + 5)/(5*a + 3)

That said, I'd use something like this:

sage: L = []
sage: for i in (1..5):
      c = b+1
      b = 1/c
      L.append([b.simplify_full(),c.simplify_full()])
....:     
sage: table(L,header_row=['b','c'])
  b                         c
+-------------------------+-------------------------+
  (8*a + 5)/(13*a + 8)      (13*a + 8)/(8*a + 5)
  (13*a + 8)/(21*a + 13)    (21*a + 13)/(13*a + 8)
  (21*a + 13)/(34*a + 21)   (34*a + 21)/(21*a + 13)
  (34*a + 21)/(55*a + 34)   (55*a + 34)/(34*a + 21)
  (55*a + 34)/(89*a + 55)   (89*a + 55)/(55*a + 34)

In the notebook if you do html(table(...)) and make sure to have everything be in latex() like so

sage: for i in (1..5):
      c = b+1
      b = 1/c
      L.append(['$'+latex(b.simplify_full())+'$','$'+latex(c.simplify_full())+'$'])
....:    
sage: html(table(L,header_row=['b','c']))
<html>
<div class="notruncate">
<table  class="table_form">
<tbody>
<tr>
<th>b</th>
<th>c</th>
</tr>
<tr class ="row-a">
<td><script type="math/tex"> \frac{144 \, a + 89}{233 \, a + 144} </script></td>
<td><script type="math/tex"> \frac{233 \, a + 144}{144 \, a + 89} </script></td>
</tr>
<tr class ="row-b">
<td><script type="math/tex"> \frac{233 \, a + 144}{377 \, a + 233} </script></td>
<td><script type="math/tex"> \frac{377 \, a + 233}{233 \, a + 144} </script></td>
</tr>
<tr class ="row-a">
<td><script type="math/tex"> \frac{377 \, a + 233}{610 \, a + 377} </script></td>
<td><script type="math/tex"> \frac{610 \, a + 377}{377 \, a + 233} </script></td>
</tr>
<tr class ="row-b">
<td><script type="math/tex"> \frac{610 \, a + 377}{987 \, a + 610} </script></td>
<td><script type="math/tex"> \frac{987 \, a + 610}{610 \, a + 377} </script></td>
</tr>
<tr class ="row-a">
<td><script type="math/tex"> \frac{987 \, a + 610}{1597 \, a + 987} </script></td>
<td><script type="math/tex"> \frac{1597 \, a + 987}{987 \, a + 610} </script></td>
</tr>
</tbody>
</table>
</div>
</html>

could be even more awesome. Good luck!

PS naturally I didn't answer about polynomial fields, but this is also possible, I think. See e.g. here.