public void Constructor_PolynomialDivision() { PolynomialDivision v = _x / _y; (v == 0).AssertIsFalse(); v.IsPolynomial.AssertIsFalse(); v.IsConstant.AssertIsFalse(); v.GetOperation('x', 'y').Value(10, 2).AssertIsEqualTo(5); }
private static void EqualityAfterTransformation(PolynomialDivision polynomial) { var cartesianPoint = new Number[] { Term.x, Term.y, Term.z }; var sphericalPoint = new HypersphericalCoordinate(Term.r, new Number[] { Term.θ, Term.φ }); PolynomialDivision sphericalPolynomial = polynomial.ToSpherical(cartesianPoint, sphericalPoint); double sqrt2 = Math.Sqrt(2); double sqrt3 = Math.Sqrt(3); Number polynomialResult = polynomial.GetOperation(Term.x, Term.y, Term.z).Value(sqrt2, sqrt2, 2 * sqrt3); double sphericalResult = sphericalPolynomial.GetOperation(Term.r, Term.θ, Term.φ).Value(4, Math.PI / 4, Math.PI / 3); polynomialResult.AssertIsEqualTo(sphericalResult); }
public void Constructor_Default() { PolynomialDivision v = default; v.AssertIsEqualTo(0); (v == 0).AssertIsTrue(); v.IsPolynomial.AssertIsTrue(); v.IsConstant.AssertIsTrue(); v.ToString().AssertIsEqualTo("0"); v.DerivativeBy('a').AssertIsEqualTo(0); (2 * v).AssertIsEqualTo(0); (v / 2).AssertIsEqualTo(0); v.GetOperation().Value().AssertIsEqualTo(0); }
public void Constructor_Variable() { PolynomialDivision v = 'a'; (v == 0).AssertIsFalse(); v.IsConstant.AssertIsFalse(); v.IsPolynomial.AssertIsTrue(); v.ToString().AssertIsEqualTo("a"); ((PolynomialTerm)v).AssertIsEqualTo('a'); v.DerivativeBy('a').AssertIsEqualTo(1); v.DerivativeBy('b').AssertIsEqualTo(0); (2 * v).AssertIsEqualTo(2 * Term.a); (v / 2).AssertIsEqualTo(0.5 * Term.a); v.GetOperation('a').Value(5).AssertIsEqualTo(5); }
public void Constructor_Constant() { PolynomialDivision v = 2; (v == 0).AssertIsFalse(); v.IsPolynomial.AssertIsTrue(); v.IsConstant.AssertIsTrue(); v.ToString().AssertIsEqualTo("2"); v.AssertIsEqualTo(2); (1 == v).AssertIsFalse(); (0 == v).AssertIsFalse(); v.DerivativeBy('a').AssertIsEqualTo(0); (2 * v).AssertIsEqualTo(4); (v / 2).AssertIsEqualTo(1); v.GetOperation().Value().AssertIsEqualTo(2); }