Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

Approximate real numbers by rationals

asked 11 years ago

LMN gravatar image

Does sage have routines to approximate real numbers by fractions:

For example, suppose 13.000000000000000000001 is an approximation of a complicated expression involving pi,e and other transcendental constants. Then it "is probably" a rational number. Can sage tell me what rational number it "probably" is.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
4

answered 11 years ago

vdelecroix gravatar image

You can use the method nearby_rational which works for real numbers. If you do have a symbolic expression, you first have to take a numerical approximation as in

sage: pi.n().nearby_rational()

The term pi may be replaced by any symbolic expression.

Preview: (hide)
link
0

answered 11 years ago

kcrisman gravatar image

See Trac 237 for the closest to this that has been proposed. I'm not sure if there would be anything for just rationals or not.

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

Seen: 1,717 times

Last updated: Aug 23 '13