コード例 #1
0
 public void AddToNumeratorDe(Summand summ, bool index)
 {
     if(index)
     {
         Stack_Numerator.Push(summ);
     }
     else
     {
         Stack_Denominator.Push(summ);
     }
 }
コード例 #2
0
 public Numerator_Form(Interface_Limit_calculator limit_calc, bool index, string formName)
 {
     InitializeComponent();
     Limits = limit_calc;
     SumTextBox.Enabled = false;
     All_Functions = new Summand();
     SumTextBox.Text = "";
     Index = index;
     this.Text = formName;
     Coefficient_Text.Text = "1.0";
 }
コード例 #3
0
        private static Summand ConvertToSummand(string stringToParse)
        {
            Summand summand = new Summand();
            summand.Coefficient = FindCoefficient(stringToParse);
            summand.PolynomialDegree = FindPolynomialDegree(stringToParse);

            var elementaryFunctionList = FindElementaryFunction(stringToParse);

            foreach (var function in elementaryFunctionList)
            {
                summand.Multiplicands.Add(ConvertToElementaryFunction(function));
            }

            var sumsRaisedToPowerList = FindSumRaisedToPower(stringToParse);

            foreach (var sum in sumsRaisedToPowerList)
            {
                SumRaisedToPower sumRaisedToPower = new SumRaisedToPower();
                sumRaisedToPower.Degree = GetSumsRaisedToPowerDegree(sum);
                sumRaisedToPower.Sum = Parse(EliminateDegree(sum));
                summand.SumsRaisedToPower.Add(sumRaisedToPower);
            }

            return summand;
        }
コード例 #4
0
 private static Summand SimpleSummandProduct(Summand s1, Summand s2)
 {
     var denominator = s1.PolynomialDegreeDenominator * s2.PolynomialDegreeDenominator;
     var numerator = s1.PolynomialDegree * s2.PolynomialDegreeDenominator +
                     s2.PolynomialDegree * s1.PolynomialDegreeDenominator;
     var gcd = MathHelper.GreatestCommonDivisor(numerator, denominator);
     return new Summand
     {
         Coefficient = s1.Coefficient * s2.Coefficient,
         PolynomialDegree = numerator / gcd,
         PolynomialDegreeDenominator = denominator / gcd,
         LittleODegree = s1.LittleODegree + s2.LittleODegree
     };
 }
コード例 #5
0
        private static IEnumerable<Summand> ReplaceSummandWithExpansion(Summand summand, int maxTaylorDegree)
        {
            if (MathHelper.IsZero(summand.Coefficient))
            {
                return new List<Summand>();
            }

            if (summand.Multiplicands.Count == 0)
            {
                return new List<Summand> { summand };
            }

            var returnedList = summand.Multiplicands[0].ToTaylorExpansion(maxTaylorDegree);

            for (var i = 1; i < summand.Multiplicands.Count; i++)
            {
                var nextExpansion = summand.Multiplicands[i].ToTaylorExpansion(maxTaylorDegree);
                returnedList = Distribute(returnedList, nextExpansion);
            }

            var multiplied =
                    returnedList.Select(s =>
                    {
                        s.Coefficient *= summand.Coefficient;
                        s.PolynomialDegree += summand.PolynomialDegree * s.PolynomialDegreeDenominator;
                        var gcd = MathHelper.GreatestCommonDivisor(s.PolynomialDegree, s.PolynomialDegreeDenominator);
                        s.PolynomialDegree /= gcd;
                        s.PolynomialDegreeDenominator /= gcd;
                        return s;
                    });

            return multiplied.OrderBy(s => s.LittleODegree).ThenBy(s => s.PolynomialDegree / (double)s.PolynomialDegreeDenominator);
        }
コード例 #6
0
        private static IEnumerable<Summand> RaiseSumsToPower(Summand summand)
        {
            var returned = new List<Summand> { summand };

            summand.SumsRaisedToPower.ForEach(
                sum => returned = DistributeIncludingElementaryFunctions(returned, RaiseSumToPower(sum)).ToList());

            return returned;
        }
コード例 #7
0
 public void AddToNumeratorDe(Summand summ, bool index)
 {
     //if (Sum_To_Power.Sum == null)
     //    Sum_To_Power.Sum = new List<Summand>();
     Stack_Sum.Push(summ);
 }