public void Constructor_Variable() { PolynomialTerm v = 'a'; (v == 0).AssertIsFalse(); v.IsConstant.AssertIsFalse(); v.PowerSum.AssertIsEqualTo(1u); v.GreatestPowerIndeterminate.Variable.AssertIsEqualTo('a'); v.GreatestPowerIndeterminate.Power.AssertIsEqualTo(1); v.ToString().AssertIsEqualTo("a"); ('b' == v).AssertIsFalse(); v.DerivativeBy('a').Single().AssertIsEqualTo(1); v.DerivativeBy('b').AssertIsEmpty(); (2 * v).AssertIsEqualTo(2 * Term.a); (v / 2).AssertIsEqualTo(0.5 * Term.a); v.GetOperation('a').Value(5).AssertIsEqualTo(5); }
public void Constructor_PolynomialVariable() { PolynomialTerm v = 2.1 * Term.a * Term.c.ToPower(3); (v == 0).AssertIsFalse(); v.IsConstant.AssertIsFalse(); v.ToString().AssertIsEqualTo("2.1ac³"); v.PowerSum.AssertIsEqualTo(4u); v.GreatestPowerIndeterminate.Variable.AssertIsEqualTo('c'); v.GreatestPowerIndeterminate.Power.AssertIsEqualTo(3); v.DerivativeBy('a').Single().AssertIsEqualTo(2.1 * Term.c.ToPower(3)); v.DerivativeBy('b').AssertIsEmpty(); v.DerivativeBy('c').Single().AssertIsEqualTo(6.3 * Term.c.ToPower(2) * Term.a.ToPower(1)); v.DerivativeBy('a').DerivativeBy('c').Single().AssertIsEqualTo(6.3 * Term.c.ToPower(2)); (-2 * v).AssertIsEqualTo(-4.2 * Term.a * Term.c.ToPower(3)); v.GetOperation('a', 'c').Value(5, 2).AssertIsEqualTo(2.1 * 5 * 8); }
public void Constructor_Default() { PolynomialTerm v = default; (v == 0).AssertIsTrue(); v.IsConstant.AssertIsTrue(); v.ToString().AssertIsEqualTo("0"); v.PowerSum.AssertIsEqualTo(0u); v.GreatestPowerIndeterminate.Variable.AssertIsEqualTo((char)0); v.GreatestPowerIndeterminate.Power.AssertIsEqualTo(0); v.AssertIsEqualTo(0); (1 == v).AssertIsFalse(); v.DerivativeBy('a').AssertIsEmpty(); (2 * v).AssertIsEqualTo(0); (v / 2).AssertIsEqualTo(0); v.GetOperation().Value().AssertIsEqualTo(0); }