public static Factor Get(string function, Factor input)
		{
			if (function == "tan")
			{
				var sin = Get("sin", input);
				var cos = Get("cos", input);
				if (sin != null && cos != null)
				{
					try
					{
						return new ExpressionFactor(new SingleComponentExpression(new ComponentList(new List<ComponentListFactor>
						{
							new ComponentListFactor(sin),
							new ComponentListFactor(cos, false)
						})).Evaluate());
					}
					catch (DivideByZeroException)
					{
						return Factorizer.ToFactor(new UndefinedExpression());
					}
				}
			}

			var identity = Identities.FirstOrDefault(i => i.Function == function && i.Input.Equals(input));
			return identity?.Output;
		}
		internal SingleFactorComponent(Factor factor)
		{
			Factor = factor;
		}
Esempio n. 3
0
		private static Component ToComponent(Factor factor)
		{
			return factor is ExpressionFactor
				? ToComponent(((ExpressionFactor)factor).Expression)
				: new SingleFactorComponent(factor);
		}
		public ComponentListFactor(Factor factor, bool isInNumerator = true)
		{
			Factor = factor;
			IsInNumerator = isInNumerator;
		}
		public TrigonometricIdentity(string function, Factor input, Factor output)
		{
			Function = function;
			Input = input;
			Output = output;
		}
Esempio n. 6
0
		private static Expression ToExpression(Factor factor)
		{
			return factor is ExpressionFactor
				? ToExpression(((ExpressionFactor)factor).Expression)
				: new SingleComponentExpression(new SingleFactorComponent(factor));
		}
		internal DualFactorComponent(Factor leftFactor, Factor rightFactor, bool isMultiply)
		{
			IsMultiply = isMultiply;
			LeftFactor = leftFactor;
			RightFactor = rightFactor;
		}
Esempio n. 8
0
		private static Factor ToFactor(Factor factor)
		{
			return factor is ExpressionFactor
				? ToFactor(((ExpressionFactor)factor).Expression)
				: factor;
		}