def compute_stencil(order, n, x_value, h_value, x0=0.):
"""
computes a stencil of Order order
"""
h,x = symbols('h x')
xs = [x+h*cos(i*pi/n) for i in range(n,-1,-1)]
cs = finite_diff_weights(order, xs, x0)[order][n]
cs = [simplify(c) for c in cs]
cs = [simplify(expr.subs(h, h_value)) for expr in cs]
xs = [simplify(expr.subs(h, h_value)) for expr in xs]
cs = [simplify(expr.subs(x, x_value)) for expr in cs]
xs = [simplify(expr.subs(x, x_value)) for expr in xs]
return xs, cs
##############################################
评论列表
文章目录