# I need help with Sagetex/Sage (normal form&data file useage) 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

edit retag close merge delete

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. =)

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

Sort by » oldest newest most voted 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'>)


more

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

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