Ejemplo n.º 1
0
 public override string ToString()
 {
     return($"{Coefficient}*{string.Join("*",TermVariables.Select(p => $"{p.Key}^{p.Value}"))}" + (EulerPower != null ? $"*e^({EulerPower.ToString()})" : String.Empty));
 }
Ejemplo n.º 2
0
        public override double Solve(IDictionary <Variable, Operation> values = null)
        {
            values = values ?? new Dictionary <Variable, Operation>();

            if (!TermVariables.All(p => values.ContainsKey(p.Key)))
            {
                throw new InvalidOperationException("All variables must be present for a numeric solution.");
            }

            return(Coefficient.Value * TermVariables.Aggregate <KeyValuePair <Variable, Operation>, double>(0.0, (d, pair) => d * Math.Pow(values[pair.Key].Solve(values), pair.Value.Solve(values))) * (EulerPower != null ? Math.Pow(Math.E, EulerPower.Solve(TermVariables)) : 1));
        }