public void Constructor_Identity() { IndeterminateExpression v = 'v'; v.IsOne.AssertIsFalse(); v.HasUnaryModifier.AssertIsFalse(); ((char)v).AssertIsEqualTo('v'); v.ToString().AssertIsEqualTo("v"); v.ToPower(2).ToString().AssertIsEqualTo("v²"); v.GetOperation('v').Value(5).AssertIsEqualTo <double>(5); v.ToPower(2).DerivativeBy('v').AssertIsEqualTo(2 * (PolynomialTerm)v); v.SimplifyForConstant(23).AssertIsEqualTo <double>(23); }
public void Constructor_Cos() { IndeterminateExpression v = IndeterminateExpression.Cos('v'); v.IsOne.AssertIsFalse(); v.HasUnaryModifier.AssertIsTrue(); Assert.Throws <InvalidOperationException>(() => { var _ = (char)v; }); v.ToString().AssertIsEqualTo("Cos(v)"); v.ToPower(2).ToString().AssertIsEqualTo("Cos²(v)"); v.GetOperation('v').Value(0).AssertIsEqualTo(1); v.GetOperation('v').Value(Math.PI / 2).AssertIsEqualTo(0); v.ToPower(2).DerivativeBy('v').AssertIsEqualTo(-2 * Cos(Term.v) * Sin(Term.v)); v.SimplifyForConstant(0).AssertIsEqualTo(1); v.SimplifyForConstant(Math.PI / 2).AssertIsEqualTo(0); }
public void Constructor_Default() { IndeterminateExpression v = default; v.IsOne.AssertIsTrue(); v.HasUnaryModifier.AssertIsFalse(); Assert.Throws <InvalidOperationException>(() => { var _ = (char)v; }); v.ToString().AssertIsEqualTo("1"); v.ToPower(2).AssertIsEqualTo(v); v.GetOperation().Value().AssertIsEqualTo(1); Assert.Throws <InvalidOperationException>(() => { var _ = v.DerivativeBy('a'); }); v.SimplifyForConstant(12).AssertIsEqualTo(12); }