def eval(self, e): rule = self.rule if e.ty in (expr.VAR, expr.CONST): return rule.eval(e) elif e.ty == expr.OP: args = [self.eval(arg) for arg in e.args] return rule.eval(expr.Op(e.op, *args)) elif e.ty == expr.FUN: args = [self.eval(arg) for arg in e.args] return rule.eval(expr.Fun(e.func_name, *args)) elif e.ty == expr.DERIV: return rule.eval(expr.Deriv(e.var, self.eval(e.body))) elif e.ty == expr.INTEGRAL: return rule.eval(expr.Integral(e.var, self.eval(e.lower), self.eval(e.upper), self.eval(e.body))) elif e.ty == expr.EVAL_AT: return rule.eval(expr.EvalAt(e.var, self.eval(e.lower), self.eval(e.upper), self.eval(e.body))) elif e.ty == expr.LIMIT: return rule.eval(expr.Limit(e.var, e.lim, self.eval(e.body))) else: raise NotImplementedError
def gen_lim_expr(var, lim, lower, upper): return expr.Limit(new_var, lim, expr.Integral(e.var, lower, upper, e.body))
def limit_r_expr(self, var, lim, body): return expr.Limit(str(var), lim, body, d="-")
def limit_inf_expr(self, var, lim, body): return expr.Limit(str(var), lim, body)