Ask Your Question
1

How could I work with polynomial fields?

asked 2015-02-04 21:10:47 -0600

Matcos gravatar image

I have the simple program:

a = var('a')
b = 1/a
for i in (1..5):
  c = b+1
  b = 1/c
  print b,",", c

The result is:

1/(1/a + 1) , 1/a + 1
1/(1/(1/a + 1) + 1) , 1/(1/a + 1) + 1
1/(1/(1/(1/a + 1) + 1) + 1) , 1/(1/(1/a + 1) + 1) + 1
1/(1/(1/(1/(1/a + 1) + 1) + 1) + 1) , 1/(1/(1/(1/a + 1) + 1) + 1) + 1
1/(1/(1/(1/(1/(1/a + 1) + 1) + 1) + 1) + 1) , 1/(1/(1/(1/(1/a + 1) + 1) + 1) + 1) + 1

Is there a way to get simpler expressions?

edit retag flag offensive close merge delete

Comments

Thank you all!

Matcos gravatar imageMatcos ( 2015-02-05 01:24:26 -0600 )edit

You can "accept" one of the answers by clicking the tick mark on the top left of that answer. When you reach 15 karma points, you can also upvote answers.

slelievre gravatar imageslelievre ( 2015-02-05 02:09:30 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2015-02-04 21:31:25 -0600

tmonteil gravatar image

updated 2015-02-04 21:31:59 -0600

First, you can simplify the symbolic expression (which is not an algebraic object, just a formula) you obtained:

sage: b.full_simplify()
(5*a + 3)/(8*a + 5)

Then you can indeed work on the genuine fraction field of a polynomial ring:

sage: R.<a> = QQ[]
sage: F = R.fraction_field()
sage: b = 1/F(a)
sage: for i in (1..5):
....:     c = b+1
....:     b = 1/c
....:     print b,",", c
....:     
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)

You can see this page for a short presentation.

edit flag offensive delete link more
1

answered 2015-02-04 21:26:27 -0600

kcrisman gravatar image
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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-02-04 21:10:47 -0600

Seen: 56 times

Last updated: Feb 05 '15