First time here? Check out the FAQ!

Ask Your Question
1

How could I work with polynomial fields?

asked 10 years ago

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?

Preview: (hide)

Comments

Thank you all!

Matcos gravatar imageMatcos ( 10 years ago )

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 ( 10 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 10 years ago

tmonteil gravatar image

updated 10 years ago

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.

Preview: (hide)
link
1

answered 10 years ago

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.

Preview: (hide)
link

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: 10 years ago

Seen: 443 times

Last updated: Feb 05 '15