First time here? Check out the FAQ!

Ask Your Question
1

I need help with Sagetex/Sage (normal form&data file useage)

asked 14 years ago

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Greetings!

I have two questions.

The easier is, how can i "ask" Sagemath to numerically calculate, and use normal form. For example i would like to see sqrt{2}/10 as 1.41 * 10^{-1}. It would be useful to always get the same precision. Like 2/10 as 2.00 * 10^{-1}

The harder question is, i want to make several calculations with the same data (about 10-20 lines, every line with 2-4 records). It is possible to copy and paste it every time, but i rather do it an easier way. Is it possible?

Daniel

Preview: (hide)

Comments

I think if you reverse your order of questions, you will get a better answer. For example, if you tell us what you're trying to calculate, we can help. Then if you want to display the results in a certain format after the calculation, we can help with that too. =)

ccanonc gravatar imageccanonc ( 14 years ago )

Hello! (d/2)*sin(((360-f(344,04,32))/(180))*pi)).n() would be the example calculation. I'd like to get 4.47 e-7. Problem is, the other calculation is{(360-f(351,31,23)+f(8,29,18))/2.n() and it should give 8.48. Ps. f calculates x°y'z'' to simple degrees

Daniel Balog gravatar imageDaniel Balog ( 14 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 14 years ago

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I don't know if scientific notation is available yet, but you can do the following:

sage: a = 2/10; a
1/5
sage: (parent(a), type(a))
(Rational Field, <type 'sage.rings.rational.Rational'>)
sage: a.n(4)
0.20
sage: (parent(a.n(4)), type(a.n(4)))
(Real Field with 4 bits of precision, <type 'sage.rings.real_mpfr.RealNumber'>)
sage: (a.n(), parent(a.n()), type(a.n()))
(0.200000000000000, Real Field with 53 bits of precision, <type 'sage.rings.real_mpfr.RealNumber'>)

Preview: (hide)
link

Comments

Hello! I was aware of that trick, but still thanks. Any idea how could i ask for two digits precision instead of like four bits? Daniel

Daniel Balog gravatar imageDaniel Balog ( 14 years ago )

a.n(digits=2) will do this.

Jason Bandlow gravatar imageJason Bandlow ( 14 years ago )

Thanks! Still 1/9.n(digits=2) gets 0.11 and 10/9.n(digits=2) gets 1.1, but it's nearly perfect!

Daniel Balog gravatar imageDaniel Balog ( 14 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 14 years ago

Seen: 1,251 times

Last updated: Oct 29 '10