On Mon, Mar 5, 2012 at 7:17 AM, P Purkayastha <ppu...@gmail.com> wrote: > > > On Monday, March 5, 2012 9:22:14 PM UTC+8, William wrote: >> >> >> >> On Sunday, March 4, 2012, Irucka Embry <iruc...@mail2world.com> wrote: >> >> > It would be very helpful to have an option to have a decimal answer when >> > performing calculations, especially when solving complex linear and/or >> > nonlinear equations, such as is possible with Matlab, GNU Octave, Scilab, >> > etc. It is very difficult to find any answers online, in the Sage search >> > engine, etc. to that question. >> > >> >> Sage output is always displayed in decimal by default, so I do not >> understand your question at all. > > > I think what (s)he meant is that by default stuff is not printed in > decimals, example: > > sage: log(3,2) > log(3)/log(2) > > To the OP: > To get the numerical result at the end, simply use .n() like: > > sage: log(3,2).n() > 1.58496250072116 > > This is very useful since Sage can do exact computations, and does so by > default (always?). There are some inherent precision problems if you use > Matlab or Octave and you want accurate results
If you have an expression in Sage and want to get it in decimal where every digit it prints (except the last) is *definitely* correct, use RIF(...). For example, sage: RIF(log(3,2)) 1.584962500721156? If you don't care -- and just want something quick, use numerical_approx (same as .n() suggested above): sage: a = sin((1e10+1e-10)*pi) sage: a sin(1.00000000000000e10*pi) sage: numerical_approx(a) # don't care -- not so good since all printed digits wrong -2.23936276195592e-6 sage: RIF(a) # every displayed digit (except possibly the last) is guaranteed correct 0.00000? sage: RealIntervalField(200)(a) # get up to 200 bits correct 0.?e-49 -- William -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org