ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 11 Apr 2017 04:31:37 +0200Precision plots - How do I do those?https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/Hi.
I have a function which varies so slowly, that in the range I'm interested only the 17th decimal changes.
The sws is this:
sage: mp = 139570180.
sage: mm = 105658371.5
sage: mn = 1.
sage: dmp = 350.
sage: dmm = 3.8
sage: dmn = 0.1
sage: l(a,b,c) = a^2 + b^2 + c^2 - 2*( a*b + b*c + c*a )
sage: f(x) = sqrt(l(mp^2, mm^2, x^2))/(2*mp)
sage: R=RealField(100)
sage: g = fast_callable(f, vars=[x], domain=R)
sage: plot( g, (x,0,2))
but I got the following plot, which is unsatisfactory in several ways!
![image description](/upfiles/14400980865379363.png)
How could I possible improve it? (ticks on vertical axis, a "continuous" line, ...)
Thank you!Thu, 20 Aug 2015 21:17:53 +0200https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/Answer by tmonteil for <p>Hi.</p>
<p>I have a function which varies so slowly, that in the range I'm interested only the 17th decimal changes.</p>
<p>The sws is this:</p>
<pre><code>sage: mp = 139570180.
sage: mm = 105658371.5
sage: mn = 1.
sage: dmp = 350.
sage: dmm = 3.8
sage: dmn = 0.1
sage: l(a,b,c) = a^2 + b^2 + c^2 - 2*( a*b + b*c + c*a )
sage: f(x) = sqrt(l(mp^2, mm^2, x^2))/(2*mp)
sage: R=RealField(100)
sage: g = fast_callable(f, vars=[x], domain=R)
sage: plot( g, (x,0,2))
</code></pre>
<p>but I got the following plot, which is unsatisfactory in several ways!</p>
<p><img alt="image description" src="/upfiles/14400980865379363.png"/></p>
<p>How could I possible improve it? (ticks on vertical axis, a "continuous" line, ...)</p>
<p>Thank you!</p>
https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/?answer=29341#post-id-29341I did not check further, but i would say that the `plot` function is using matplotlib and that the latter uses double floating-point numbers (with 53 bits of precision). So, what i temporarly suggest is to shift your finction as follow to get more precision:
sage: ff(x) = f(x)-2.97919787636599e7
sage: g = fast_callable(ff, vars=[x], domain=R)
sage: plot( g, (x,0,2))
This workaround solution is not completely satisfactory, but at least, you will get something much rounder:
![smooth_plot.png](/upfiles/14402492332242769.png)
Sat, 22 Aug 2015 12:50:57 +0200https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/?answer=29341#post-id-29341Comment by Dox for <p>I did not check further, but i would say that the <code>plot</code> function is using matplotlib and that the latter uses double floating-point numbers (with 53 bits of precision). So, what i temporarly suggest is to shift your finction as follow to get more precision:</p>
<pre><code>sage: ff(x) = f(x)-2.97919787636599e7
sage: g = fast_callable(ff, vars=[x], domain=R)
sage: plot( g, (x,0,2))
</code></pre>
<p>This workaround solution is not completely satisfactory, but at least, you will get something much rounder:</p>
<p><img alt="smooth_plot.png" src="/upfiles/14402492332242769.png"/></p>
https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/?comment=29348#post-id-29348@tmonteil Thank you! it was in fact really useful!Mon, 24 Aug 2015 21:40:48 +0200https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/?comment=29348#post-id-29348Comment by tmonteil for <p>I did not check further, but i would say that the <code>plot</code> function is using matplotlib and that the latter uses double floating-point numbers (with 53 bits of precision). So, what i temporarly suggest is to shift your finction as follow to get more precision:</p>
<pre><code>sage: ff(x) = f(x)-2.97919787636599e7
sage: g = fast_callable(ff, vars=[x], domain=R)
sage: plot( g, (x,0,2))
</code></pre>
<p>This workaround solution is not completely satisfactory, but at least, you will get something much rounder:</p>
<p><img alt="smooth_plot.png" src="/upfiles/14402492332242769.png"/></p>
https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/?comment=37257#post-id-37257^_^ .Tue, 11 Apr 2017 04:31:37 +0200https://ask.sagemath.org/question/29231/precision-plots-how-do-i-do-those/?comment=37257#post-id-37257