| 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 asked Oct 27 '10 This post is a wiki. Anyone with karma >150 is welcome to improve it.
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 (Oct 29 '10)
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 (Nov 01 '10) |
| 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'>) answered Oct 28 '10 This post is a wiki. Anyone with karma >150 is welcome to improve it.
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 (Oct 29 '10)
a.n(digits=2) will do this.
Jason Bandlow (Oct 29 '10)
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 (Oct 30 '10) |
Asked: Oct 27 '10
Seen: 124 times
Last updated: Oct 28 '10
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.