コード例 #1
0
 public void DrawMaclaurinSerieFast(GraphDrawer drawer, int order)
 {
     if (order < 1)
     {
         throw new Exception("order must be larger than 0");
     }
     double[] MaclaurinValues = makeMaclaurinList(0, order, null, 0.02);
     drawMaclaurinSerieFastRecursive(1, order, MaclaurinValues, drawer, null);
 }
コード例 #2
0
 public Form1()
 {
     InitializeComponent();
     myFunctions = new List <NodeHolder>();
     myDrawer    = new GraphDrawer(ChartFunction);
     myDrawer.DrawEmptyChart();
     points           = new List <double>();
     appIsDoneLoading = true;
 }
コード例 #3
0
        private Node drawMaclaurinSerieFastRecursive(int counter, int order, double[] maclaurinValues, GraphDrawer drawer, Node prevCompletedNode)
        {
            NodeHolder nh;
            Node       nodeTim   = new NodeTimes();
            Node       nodeDiv   = new NodeDivision();
            Node       nodeFac   = new NodeFactorial();
            Node       nodePow   = new NodePower();
            double     zeroValue = maclaurinValues[counter - 1];

            nodeTim.AddNode1(nodeDiv);
            nodeTim.AddNode2(nodePow);
            nodeDiv.AddNode1(new NodeNumber(false, false, zeroValue));
            nodeDiv.AddNode2(nodeFac);
            nodeFac.AddNode1(new NodeNumber(false, false, counter - 1));
            nodePow.AddNode1(new NodeNumber(true, false, 1)); //X
            nodePow.AddNode2(new NodeNumber(false, false, counter - 1));

            if (counter == order)
            {
                Node nodePlus = new NodePlus();
                if (prevCompletedNode != null)
                {
                    nodePlus.AddNode1(nodeTim);
                    nodePlus.AddNode2(prevCompletedNode);
                    prevCompletedNode = nodePlus.Clone();
                    nh = new NodeHolder(prevCompletedNode);
                }
                else
                {
                    prevCompletedNode = nodeTim;
                    nh = new NodeHolder(prevCompletedNode);
                }
                if (counter == 1)
                {
                    drawer.drawFunction(nh, true);
                }
                else
                {
                    drawer.drawFunction(nh, false);
                }
                return(nodeTim);
            }
            else if (counter < order && counter > 0)
            {
                Node nodePlus = new NodePlus();
                if (prevCompletedNode != null)
                {
                    nodePlus.AddNode1(nodeTim);
                    nodePlus.AddNode2(prevCompletedNode);
                    prevCompletedNode = nodePlus.Clone();
                    nh = new NodeHolder(prevCompletedNode);
                }
                else
                {
                    prevCompletedNode = nodeTim;
                    nh = new NodeHolder(prevCompletedNode);
                }
                if (counter == 1)
                {
                    drawer.drawFunction(nh, true);
                }
                else
                {
                    drawer.drawFunction(nh, false);
                }
                nodePlus.AddNode1(nodeTim);
                nodePlus.AddNode2(drawMaclaurinSerieFastRecursive(counter + 1, order, maclaurinValues, drawer, prevCompletedNode));
                return(nodePlus);
            }
            else
            {
                throw new Exception("Error while making Maclaurin serie: counter problem: " + counter);
            }
        }