x = var('x')
@interact
def taylor_rem(f=input_box(sin(x), label='function ', type=SR), center=input_box(0, label='center', type=SR),
radius=input_box(0.3, label='radius'), order=slider([1..12])):
func = f
taylor_poly = func.taylor(x,center,order)
rem = f - taylor_poly
abs_rem = abs(rem)
pretty_print(html('$f(x)\;=\;%s$'%latex(func)))
pretty_print(html('$\\left|R_{%s}(x)\\right|\;=\;\\left| %s \\right|$'%(order,latex(rem))))
min_x = center - radius
max_x = center + radius
min_y = find_local_minimum(abs_rem, min_x, max_x)[0]
max_y = find_local_maximum(abs_rem, min_x, max_x)[0]
p = plot(abs_rem, min_x, max_x, rgbcolor=(1,0,0), thickness=2)
p.show(xmin = min_x, xmax = max_x, ymin = min_y, ymax = max_y)
|
Click to the left again to hide and once more to show the dynamic interactive window
|