Demonstration: Plots (short version)

<span id="demo-plot-short"></span>


<p>Some nice plots:</p>

{{{id=0|
plot(sin(x), -pi, pi, fill = 'axis')
///
}}}

<p>Taylor approximation:</p>

{{{id=1|
%hide
var('x')
&#64;interact
def g(f=sin(x), c=0, n=(1..30),
         xinterval=range_slider(-10, 10, 1, default=(-8,8), label=&quot;x-interval&quot;),
         yinterval=range_slider(-50, 50, 1, default=(-3,3), label=&quot;y-interval&quot;)):
     x0 = c
     degree = n
     xmin,xmax = xinterval
     ymin,ymax = yinterval
     p   = plot(f, xmin, xmax, thickness=4)
     dot = point((x0,f(x=x0)),pointsize=80,rgbcolor=(1,0,0))
     ft = f.taylor(x,x0,degree)
     pt = plot(ft, xmin, xmax, color='red', thickness=2, fill=f)
     show(dot + p + pt, ymin=ymin, ymax=ymax, xmin=xmin, xmax=xmax)
     html('$f(x)\;=\;%s$'%latex(f))
     html('$P_{%s}(x)\;=\;%s+R_{%s}(x)$'%(degree,latex(ft),degree))
///
}}}

