ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 29 Jul 2016 07:04:51 -0500More digits from octavehttp://ask.sagemath.org/question/34187/more-digits-from-octave/ Hi, how can I get all the 15/16 digits from a command like pi = octave('pi')?
Fri, 22 Jul 2016 05:37:53 -0500http://ask.sagemath.org/question/34187/more-digits-from-octave/Answer by Marco Caliari for <p>Hi, how can I get all the 15/16 digits from a command like pi = octave('pi')?</p>
http://ask.sagemath.org/question/34187/more-digits-from-octave/?answer=34273#post-id-34273Hi, I found myself a solution, for instance:
a=Matrix(RR,octave('sprintf("%.16e ",rand(1,4))'))
Fri, 29 Jul 2016 07:04:51 -0500http://ask.sagemath.org/question/34187/more-digits-from-octave/?answer=34273#post-id-34273Answer by nbruin for <p>Hi, how can I get all the 15/16 digits from a command like pi = octave('pi')?</p>
http://ask.sagemath.org/question/34187/more-digits-from-octave/?answer=34196#post-id-34196As far as I know, the "octave" command really just gets you an interface that allows you to pass strings as "typed in to octave" and get you back strings as printed by octave. So:
octave:1> 0.123456789
ans = 0.12346
suggests octave is naturally stingy with printing digits. In order to get more digits back via the octave interface, you should do whatever you do to normally coerce octave to print more digits. Perhaps https://www.gnu.org/software/octave/doc/v4.0.1/Matrices.html#XREFoutput_005fprecision helps.Fri, 22 Jul 2016 13:12:46 -0500http://ask.sagemath.org/question/34187/more-digits-from-octave/?answer=34196#post-id-34196Answer by slelievre for <p>Hi, how can I get all the 15/16 digits from a command like pi = octave('pi')?</p>
http://ask.sagemath.org/question/34187/more-digits-from-octave/?answer=34189#post-id-34189Starting Octave just to get a numerical value of pi is unnecessarily slow.
If you need a floating-point approximation to pi, I would suggest:
sage: pi = RDF.pi()
sage: pi
3.141592653589793
But maybe you have other reasons to use Octave?
Fri, 22 Jul 2016 06:45:42 -0500http://ask.sagemath.org/question/34187/more-digits-from-octave/?answer=34189#post-id-34189Comment by Marco Caliari for <p>Starting Octave just to get a numerical value of pi is unnecessarily slow.</p>
<p>If you need a floating-point approximation to pi, I would suggest:</p>
<pre><code>sage: pi = RDF.pi()
sage: pi
3.141592653589793
</code></pre>
<p>But maybe you have other reasons to use Octave?</p>
http://ask.sagemath.org/question/34187/more-digits-from-octave/?comment=34192#post-id-34192Sorry, try this instead a=octave('0.123456789'). I chose pi just to be short. I get a=0.123457, lost two digits.Fri, 22 Jul 2016 07:56:39 -0500http://ask.sagemath.org/question/34187/more-digits-from-octave/?comment=34192#post-id-34192