public SubstExp(Variable @var, Algebraic expr) { this.@var = @var; ArrayList v = new ArrayList(); (new GetExpVars2(v)).SymEval(expr); this.gcd = Exponential.exp_gcd(v, @var); if (gcd.Equals(Symbolic.ZERO)) { t = @var; } }
public virtual Algebraic ratsubst(Algebraic expr) { if (gcd.Equals(Symbolic.ZERO)) { return(expr); } if (!expr.Depends(@var)) { return(expr); } if (expr is Rational) { return(ratsubst((( Rational )expr).nom) / ratsubst((( Rational )expr).den)); } if (expr is Polynomial && ((Polynomial)expr)._v is FunctionVariable && ((FunctionVariable)((Polynomial)expr)._v).Name.Equals("exp") && ((FunctionVariable)((Polynomial)expr)._v).Var is Polynomial && ((Polynomial)((FunctionVariable)((Polynomial)expr)._v).Var)._v.Equals(@var) && ((Polynomial)((FunctionVariable)((Polynomial)expr)._v).Var).Degree() == 1 && ((Polynomial)((FunctionVariable)((Polynomial)expr)._v).Var)[0].Equals(Symbolic.ZERO)) { Polynomial pexpr = (Polynomial)expr; int degree = pexpr.Degree(); Algebraic[] a = new Algebraic[degree + 1]; for (int i = 0; i <= degree; i++) { Algebraic cf = pexpr[i]; if (cf.Depends(@var)) { throw new JasymcaException("Rationalize failed: 2"); } a[i] = cf; } return(new Polynomial(t, a)); } throw new JasymcaException("Could not rationalize " + expr); }